46 lines
1.0 KiB
Python
46 lines
1.0 KiB
Python
import django
|
|
import django_webtest
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def app(request):
|
|
wtm = django_webtest.WebTestMixin()
|
|
wtm.setup_auth = False
|
|
wtm._patch_settings()
|
|
request.addfinalizer(wtm._unpatch_settings)
|
|
return django_webtest.DjangoTestApp()
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def media_root(settings, tmpdir):
|
|
settings.MEDIA_ROOT = str(tmpdir.mkdir('media_root'))
|
|
|
|
|
|
@pytest.fixture
|
|
def nocache(settings):
|
|
settings.CACHES = {
|
|
'default': {
|
|
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
|
|
}
|
|
}
|
|
|
|
|
|
@pytest.fixture
|
|
def get_proper_html_str():
|
|
"""
|
|
There are some subtle differences in the HTML generated by django 2 and 3
|
|
making it harder to write tests compatible with both versions.
|
|
|
|
XXX: remove when django 2 compat isn't necessary.
|
|
"""
|
|
|
|
def inner(s):
|
|
if django.VERSION[0] == 2:
|
|
return s.replace(''', ''')
|
|
if django.VERSION[0] == 3:
|
|
return s.replace(''', ''')
|
|
return s
|
|
|
|
return inner
|