Django tests in demo projectsΒΆ

Any given code repository usually corresponds to one Python package and has one test suite.

The test suite of a Python package is defined in setup_info.py.

In most of our projects this contains a single file tests/__init__.py which is if you want the "master file".

A Python package can contain multiple demo projects. A typical test is to run Django's test command in each of them. Something like this (excerpt from the tests/__init__.py of The lino-book package):

from lino.utils.pythontest import TestCase

class ProjectsTests(TestCase):

    def test_min1(self):
        self.run_django_manage_test("lino_book/projects/min1")

You know that there is no way to test several Django applications in a single Python process. Every piece of code which imports Django requires the DJANGO_SETTINGS_MODULE environment variable to be set, and it is not allowed to change that variable at runtime. So it is clear that every call to run_django_manage_test is going to spawn subprocess.