From 5a7e5061cf99d11dce1fb0a56f450acaa856d8de Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Mon, 6 Oct 2014 13:37:35 -0300 Subject: [PATCH] Add WebTest global fixture for tests From https://gist.github.com/magopian/6673250 --- conftest.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 conftest.py diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000..a3bd77c --- /dev/null +++ b/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()