I have a folder with python scripts that contain doc tests that I want to do unit tests on. When I try to test it with one file like this:
import unittest
suite = unittest.TestSuite()
suite.addTest('/homes/ndeklein/workspace/MS/PyMS/pyMS/baseFunctions.py')
unittest.TextTestRunner().run(suite)
I get this error:
TypeError: the test to add must be callable
However, when I do it from the commandline
python '/homes/ndeklein/workspace/MS/PyMS/pyMS/baseFunctions.py'
it works.
How can I make my file callable?
addTesttakes aTestCaseor aTestSuite– and you’re passing in a string.Have a look at the docs here:
http://docs.python.org/library/unittest.html
It’s not clear exactly what you want to do – but if
baseFunctions.pydefines a subclass ofTestCase, you could try this: