I have the following typical python project file structure
packageA
+----subpackage1
+----classa.py
+----subpackage2
+----classb.py
+----test
+----subpackage1
+----classa_test.py
+----subpackage2
+----classb_test.py
I am currently trying to organize my unittests and functional tests so I can run unittests and functional tests separately using nose but also have the option to run all tests. The tests would live in packageA/test/subpackage1 and packageA/test/subpackage2.
nose can be integrated with DocTest by using with-doctest option in athe bove command line. The result will be true if the test run is successful, or false if it fails or raises an uncaught exception. nose supports fixtures (setup and teardown methods) at the package, module, class, and test level.
My tests directory structure looks this way:
root
+ --- tests
| + --- unit_tests
| | + --- some_app_tests
| | + --- another_app_tests
| | | run_tests.py
| |
| + --- integrate_tests
| + --- some_app_tests
| + --- another_app_tests
| | run_tests.py
|
+ --- project_root
+ --- some_app
+ --- another_app
For each individual app I create coresponding directory with tests in unit- and integrate- directory. Each is directory is separate django project with custom settings and there's management command used to run tests.
Also placing tests in one directory has one nice advantage - when project is deployed, there's no reason to deploy tests with it. So I just strip one directory and that's all.
(to run tests I use django-sane-testing: https://github.com/Almad/django-sane-testing )
If you are developing Django project, you can try this library: unclebob https://github.com/gabrielfalcao/unclebob
It suggest a way how to organize and run your unit tests and functional tests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With