Examples |
docs/INSTALL
.
# suite.py
import unittest
class MyTestCase(unittest.TestCase):
def testFoo(self): pass
def testBar(self): pass
To learn more about writing tests, see the tutorials in the links.
On Unix systems, run the tests from the command-line like this:
prompt> testoob suite.py .. ---------------------------------------------------------------------- Ran 2 tests in 0.002s OK prompt>On Windows, find your Python installation directory. Let’s assume it’s
c:\python
. Then run:
prompt> python c:\python\scripts\testoob suite.py .. ---------------------------------------------------------------------- Ran 2 tests in 0.003s OK prompt>If you prefer, you can add the following at the end of the suite source file:
if __name__ == "__main__":
import testoob
testoob.main()
And then run the tests with:
prompt> python suite.py .. ---------------------------------------------------------------------- Ran 2 tests in 0.002s OK prompt>
You can run test suites you created on your own.
If you have a function like:
def suite():
result = unittest.TestSuite()
# ...
return result
You can run it by giving the function name:
prompt> testoob suite.py suiteYou can also change the call to
testoob.main
:
if __name__ == "__main__":
import testoob
testoob.main(defaultTest="suite")