1"""
2Py.test configuration file
3
4Maik says: There's some magic in here that I don't fully understand. Normally, one would
5use pytest-django to run the tests, which takes care of all the Django-related testcase
6set up and tear down. But that doesn't work because the current tests attempt to access the
7database not just in tests, but in their set up methods, which trips up the
8"can't access database without mark.django_db" no matter if tests are marked as being
9allowed to access the database or not.
10
11So instead, we run the tests without pytest-django and make it work ourselves.
12"""
13import os
14
15
16os.environ['DJANGO_SETTINGS_MODULE'] = 'treebeard.tests.settings'
17
18import django
19from django.test.utils import setup_test_environment, teardown_test_environment
20from django.db import connection
21
22
23def pytest_report_header(config):
24    return 'Django: ' + django.get_version()
25
26
27def pytest_configure(config):
28    django.setup()
29    setup_test_environment()
30    connection.creation.create_test_db(verbosity=2, autoclobber=True)
31
32
33def pytest_unconfigure(config):
34    teardown_test_environment()
35