title: How to initialize the database with your test data for each module? Pytest-django
body: <p>For each application in the project, you need to write tests. Also for each application you first need to upload your test data, which, after passing all the module tests, must be deleted. </p>
  
  <p>I found several solutions, but none of them seems to me optimal</p>
  
  <p>First:
  in file <code>conftest.py</code> in each app I override method <code>django_db_setup</code>, but in this case, the data is not deleted after passing the tests in the module, and become available for other applications. 
  In theory, with the help of <code>yield</code> you can delete all the data after passing the tests.</p>
  
  <pre><code>@pytest.fixture(scope='module')
  def django_db_setup(django_db_setup, django_db_blocker):
      with django_db_blocker.unblock():
          call_command('loaddata', './apps/accounts/fixtures/accounts.json')
          call_command('loaddata', './apps/activation/fixtures/activation.json')
          call_command('loaddata', './apps/questionnaire/fixtures/questionnaire.json')
          yield 
          # delete test data
  </code></pre>
  
  <p>Second: in the class with tests write such a setup</p>
  
  <pre><code>@pytest.fixture(autouse=True)
  def setup(self, db):
      call_command('loaddata', './apps/accounts/fixtures/accounts.json')
      call_command('loaddata', './apps/activation/fixtures/activation.json')
      call_command('loaddata', './apps/questionnaire/fixtures/questionnaire.json')
  </code></pre>
  
  <p>In this case, the data will be loaded exactly as many times as there will be tests in the module, which also seems to be not quite correct.</p>