Reputation: 303
I have written a unittest of a program MachineSettings_test.py of mine of the following form:
import unittest
import MachineSettings as MS
class TestMachineSettings(unittest.TestCase):
def setUp(self):
[...]
def testStringRepresentation(self):
[...]
def testCasDict(self):
[...]
if __name__=="__main__":
unittest.main()
I am a little bit confused by the following fact: If I run
python -m unittest -v MachineSettings_test
I get as output
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
i.e. Python does not recognize the tests inside the unittesting module.
But if I just run
python MachineSettings_test.py
Everything works fine and I get as output
..
----------------------------------------------------------------------
Ran 2 tests in 0.000s
OK
This is confusing to me and I could not find any similar question here yet, so I posted it.
The version of Python that I am (forced to be) using is 2.6, but I could not find anything in the documentation that makes this case to be special.
Anyone an idea?
Thanks
Upvotes: 3
Views: 190
Reputation: 2957
From the documentation:
Changed in version 2.7: In earlier versions it was only possible to run individual test methods and not modules or classes.
And you're trying to run tests for whole modules with python 2.6.
Apparently you can't even run from individual test methods with -m unittest
in python 2.6. See this question for details.
You might wanna try nose or nose2.
Upvotes: 4