title: Pytest running very slow for project
body: <p>My pytest setup is running very slow, especially during collection phase.</p>
  
  <p>So I have put up a pytest setup for my Django project, and each Django app's test-files are located in its own folder, i.e., the tree looks as follows</p>
  
  <pre><code>root
  |
  +--a
  |  |
  |  +--tests
  |       |
  |       +--conftest.py
  |       +--testAa.py
  |       +--testBa.py
  +--b
  |  |
  |  +--tests
  |       |
  |       +--conftest.py
  |       +--testAb.py
  |       +--testBb.py
  ...
  pytest.ini
  </code></pre>
  
  <p>The pytest.ini file specifies where to look for the tests and has the following content</p>
  
  <pre><code>[pytest]
  DJANGO_SETTINGS_MODULE = project.project.settings.test
  python_files = tests.py test_*.py *_tests.py
  addopts = --reuse-db
  </code></pre>
  
  <p>For each app within the <code>tests</code> folder I have a file called <code>contest.py</code>. This file creates a set of objects that are used multiple times in the test files. For instance if an object of class <code>A</code> is used more than once, a contest creates that variable once and the tests use this conftest as input. Each conftest has the decorator <code>@pytest.fixture(scope="function")</code>, and the tests have the decorator <code>@pytest.mark.django_db</code>.</p>
  
  <p>I don't think the loading times are caused by the conftests, or the decorators discussed in the last paragraph, but rather the tree structure and <code>pytest.ini</code> file I have put up. Are there any rules for what is a good structure for this? As I said, the loading times are extremely high for collecting the tests. To be more accurate, I have about 80 tests, and collecting them takes about 40 seconds. Running them all takes an additional 20.</p>