Browse Source

Add WebTest global fixture for tests

From https://gist.github.com/magopian/6673250
producao
Marcio Mazza 10 years ago
parent
commit
5a7e5061cf
  1. 20
      conftest.py

20
conftest.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
import pytest
from django_webtest import DjangoTestApp, WebTestMixin
@pytest.fixture(scope='function')
def app(request):
"""WebTest's TestApp.
Patch and unpatch settings before and after each test.
WebTestMixin, when used in a unittest.TestCase, automatically calls
_patch_settings() and _unpatchsettings.
source: https://gist.github.com/magopian/6673250
"""
wtm = WebTestMixin()
wtm._patch_settings()
request.addfinalizer(wtm._unpatch_settings)
return DjangoTestApp()
Loading…
Cancel
Save