mercredi 6 septembre 2017

How dose python test discovery work?

I have a project setup with the following structure:

/
  script.py
  /tests
    __init__.py
    test_some_thing.py
    test_some_other_thing.py

in my script.py file I have the following line of code:

print('just some random text!!!!!!')

When I run:

python -m unittest discover

It runs the tests as expected but also outputs: just some random text!!!!!!

Can anyone explain exactly how test discovery works? I had assumed it would look for classes that were derived from unittest.TestCase and then all functions that are in there, but it appears to be running other code as well.

Aucun commentaire:

Enregistrer un commentaire