1

In the docs https://docs.python.org/3/library/unittest.html it suggests:

python -m unittest tests/test_something.py

whereas

python tests/test_something.py

seems to work just as well. Honestly, the output is exactly the same with the basic example. What is the point of "-m" and "unittest" there?

cardamom
  • 6,873
  • 11
  • 48
  • 102

1 Answers1

3

The example contains these lines:

if __name__ == '__main__':
    unittest.main()

which do essentially the same as python -m unittest: discover and run the tests. You may want to have some other logic there which runs for python test_something.py or omit those lines completely. python -m unittest will work the same way in any case.

bereal
  • 32,519
  • 6
  • 58
  • 104