-
Notifications
You must be signed in to change notification settings - Fork 73
/
conftest.py
64 lines (45 loc) · 1.5 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""Configures pytest and Django environment setup for Djblets.
.. important::
Do not define plugins in this file! Plugins must be in a different
package (such as in tests/). pytest overrides importers for plugins and
all modules descending from that module level, which will cause extension
importers to fail, breaking unit tests.
Version Added:
3.0
"""
from __future__ import unicode_literals
import os
import shutil
import sys
import django
import pytest
sys.path.insert(0, os.path.join(os.path.dirname(__file__)))
@pytest.fixture(autouse=True, scope='session')
def django_setup_static(request):
"""Collect static media at session start.
Args:
request (object):
The pytest request.
"""
from django.conf import settings
from django.core import management
for path in (settings.MEDIA_ROOT, settings.STATIC_ROOT):
shutil.rmtree(path, ignore_errors=True)
if not os.path.exists(path):
os.mkdir(path, 0o755)
management.call_command('collectstatic',
verbosity=request.config.option.verbose,
interactive=False)
def pytest_report_header(config):
"""Return information for the report header.
This will log the version of Django.
Args:
config (object):
The pytest configuration object.
Returns:
list of unicode:
The report header entries to log.
"""
return [
'django version: %s' % django.get_version(),
]