Django unit testing and global fixtures

I am working on a web project in Django and I am using the python unittest framework. For each application, I have some lights. This means that each application has some identical tables in the fixtures. I would like to share fixtures between applications and testcases, because otherwise, if I change the model, I will have to change all the json devices referenced by this particular table.

Can global luminaires be used?

+3
source share
3 answers

Do not use static instruments, this is a poor automatic test model. Use dynamic lights.

Django Dynamic Fixture . Shelve.

+2

Django . TestCase.fixtures; Django-, unittest.

+1

, tearDown ( teardown_test_environment - . ).

, , . , .

  • . - :

    class TestBase(django.test.TestCase):
        fixtures = ['common_fixtures.xml']
    
    class MyTestClass(TestBase):
        fixtures = TestBase.fixtures + ['fixtures_for_this_test.xml']
    
        def test_foo(self):
            # test stuff
    
  • . . , setup_ teardown_test_environment.

+1

Source: https://habr.com/ru/post/1715051/


All Articles