-
Notifications
You must be signed in to change notification settings - Fork 11
/
conftest.py
50 lines (34 loc) · 1.15 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
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
import os
import pytest
import django
from configurations import importer
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tests.settings')
os.environ.setdefault('DJANGO_CONFIGURATION', 'StandaloneTest')
def pytest_configure():
importer.install()
# Setup command is only available in Django 1.7+ but is required
# to properly initialise the Django app config.
if django.VERSION[1] >= 7:
django.setup()
@pytest.fixture
def webtest_csrf_checks():
return True
@pytest.fixture(scope='function')
def webtest(request, webtest_csrf_checks, transactional_db):
"""
Provide the "app" object from WebTest as a fixture
Taken and adapted from https://gist.github.com/magopian/6673250
"""
from django_webtest import DjangoTestApp, WebTestMixin
# Patch settings on startup
wtm = WebTestMixin()
wtm.csrf_checks = webtest_csrf_checks
wtm._patch_settings()
# Unpatch settings on teardown
request.addfinalizer(wtm._unpatch_settings)
return DjangoTestApp()
@pytest.fixture
def splinter_webdriver():
return 'firefox'