PyTester

About

This is a small package that facilitates the unit testing process by aggregating PyUnit tests and making them easier to call from the command line and from within other unit tests.

Typical PyUnit tests are written in a 1-1 relationship with the module they test. Module "foo.py" is typically tested with module "test_foo.py". In packages with multiple modules it can become cumbersome to run all of the unit tests from the command line.

One could write an aggregator "test_all.py" module and have it call into each "test_*.py" module to retrieve a TestCase to assemble a suite. However, that approach requires 2 modifications each time a unit test is added (one modification for the test itself, and one modification in test_all.py).

PyTester can run all of the unit tests in a directory via the command line by locating all modules that begin with "test_". Reflection is then used to extract the TestCase class, and a suite is constructed reflecting all test cases.

Additionally, PyTester can be used programmatically in a test_all.py.

Usage

Executing PyTest on the command line:

    $ pytest  `pwd`/

Using PyTest from within a program (e.g. test_all.py):

    from testtool import suitebuilder
    suite = suitebuilder.createSuite()
    runner = unittest.TextTestRunner()
    runner.run(suite)

For more information, see the following projects links:

Contact

Two mailing lists have been created:

To join either list, send an email to majordomo@wxnet.org with the contents "subscribe pytest-users" or "subscribe pytest-devel" in the body of the message.


Christopher Blunck