4 All unit tests are to be placed in the conductor/tests directory,
5 and tests might be organized by tested subsystem. Each subsystem directory
6 must contain a separate blank __init__.py for test discovery to function.
8 An example directory structure illustrating the above:
19 If a given test has no overlapping requirements (variables or same
20 routines) a new test does not need to create a subdirectory under the
26 testrepository - http://pypi.python.org/pypi/testrepository is used to
27 find and run tests, parallelize their runs, and record timing/results.
29 If new dependencies are introduced upon the development of a test, the
30 test-requirements.txt file needs to be updated so that the virtual
31 environment will be able to successfully execute all tests.
36 The advised way of running tests is by using tox:
40 By default, this will run the unit test suite with Python 2.7 and PEP8/HACKING
41 style checks. To run only one type of test you can explicitly invoke tox
42 with the test environment to use.
44 $ tox -epy27 # test suite on python 2.7
45 $ tox -epep8 # run full source code checker
47 To run only a subset of tests, you can provide tox with a regex argument
48 defining which tests to execute.
50 $ tox -epy27 -- FooTests
52 To use a debugger like pdb during the test run, one has to run tests directly
53 with another, non-concurrent test runner instead of using testr.
55 That also presumes you have a virtual env with all conductor dependencies active.
56 Below is an example bash script using the testtools test runner that also allows
57 running single tests by providing a regex.
61 testr list-tests "$1" > $testlist
62 python -m testtools.run --load-list $testlist
64 Another way to use debugger for testing is run tox with command:
65 $ tox -e debug -- conductor.tests.test_foo.FooTest.test_foo_does_something
67 Note: This last approach is mostly useful to run single tests.