1. Simple test runner for Python

    If you have the following project layout:

    /src
        /module
            class1.py
            class2.py
            /tests
                 test1.py
                 test2.py
        /module2
            class1.py
            class2.py
            /tests
                 test1.py
                 test2.py
        tests.py
    

    Putting this script into src/tests.py will let you bootstrap your tests.

    Note: To import modules from your test classes, use relative import statements. For example:

    This means, of course, that you need to compartment your tests so they only test things in their parent package. This isn’t a bad thing, as unit tests should be focusing on per-module functionality anyway.

  2. blog comments powered by Disqus