I have a file TestProtocol.py
that has unittests. I can run that script and get test results for my 30 tests as expected. Now I want to run those tests from another file tester.py
that is located in the same directory. Inside tester.py
I tried import TestProtocol
, but it runs 0 tests.
Then I found the documentation which says I should do something like this:
suite = unittest.TestLoader().discover(".", pattern = "*")
unittest.run(suite)
This should go through all files in the current directory .
that match the pattern *
, so all tests in all files. Unfortunately it again runs 0 tests.
There is a related QA that suggests to do
import TestProtocol
suite = unittest.findTestCases(TestProtocol)
unittest.run(suite)
but that also does not find any tests.
How do I import and run my tests?