Package pytilities :: Module testing
[hide private]
[frames] | no frames]

Module testing

source code


Test utilities

Allows testing whole test hierarchies. 

Note: It involves copying testall.py files around, etc, I'm sure there are
better ways of doing this, for my projects it was good enough though.

Functions:

    - `test_suite_from_package`: Recursively get test suite of all tests in a 
    package

    - `run`: Run test and print results to stderr

Functions [hide private]
 
test_suite_from_package(module_file, module_name)
Recursively get test suite of all tests in a package and its child packages
source code
 
run(test)
Run test and print results to stderr
source code
Variables [hide private]
  _logger = logging.getLogger("pytilities.testing")
  __package__ = 'pytilities'
Function Details [hide private]

test_suite_from_package(module_file, module_name)

source code 

Recursively get test suite of all tests in a package and its child packages

For this to work correctly you must build a specific hierarchy of test
packages. Each package to be test should contain a test package. Each test
package must contain a testall.py file, you can find them all over
pytilities, just copy one of them, no changes are required. For example::

    pytilities
        test
            testall.py
        event
            test
                testall.py
        ...

Note that this may not work as expected::
    proj
        test
        p
            b
                test

Running tests from proj.test will not run tests from b. You must 'fill in 
the gaps', i.e. p needs a test package as well to prevent the recursion to
stop at p.

Parameters:

    `module_file` :: string
        the testall.py file path. (use
        __file__)

    `module_name`:: string
        name of the calling module. (use __name__)

Usage example:
    See pytilities.test (or any other test package)

run(test)

source code 

Run test and print results to stderr

Parameters:

    `test`
        the TestCase to run