def client(request): import django_webtest wtm = django_webtest.WebTestMixin() wtm.csrf_checks = False wtm._patch_settings() request.addfinalizer(wtm._unpatch_settings) app = django_webtest.DjangoTestApp() return app
def app(request): wtm = django_webtest.WebTestMixin() wtm._patch_settings() yield django_webtest.DjangoTestApp() wtm._unpatch_settings()
self.get('/accounts/login/') form = self.wait_for_element(timeout=2, id_='login') form.fill_out_and_submit({ 'username': username, 'password': password, }) self.mustcontain(username) def mustcontain(self, *texts): for text in texts: if text not in self.page_source: print(self.page_source) assert text in self.page_source wtm = django_webtest.WebTestMixin() @pytest.fixture(scope='function') def app(request, db): request.addfinalizer(wtm._unpatch_settings) wtm._patch_settings() wtm.renew_app() return wtm.app @pytest.fixture(scope='function') def browser(request, app): server = aiowsgi.thread.WSGIServer(app.app) server.start() # travis
def app(request, settings): wtm = django_webtest.WebTestMixin() wtm._patch_settings() request.addfinalizer(wtm._unpatch_settings) return django_webtest.DjangoTestApp()
def app(request): wtm = django_webtest.WebTestMixin() wtm._patch_settings() request.addfinalizer(wtm._unpatch_settings) return django_webtest.DjangoTestApp( extra_environ={'HTTP_HOST': 'localhost'})