Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebTestMixin is extracted. WebTest and TransactionWebTest are provided. #10

Merged
merged 4 commits into from Jun 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.txt
Expand Up @@ -16,3 +16,4 @@ Authors
* Bruno Renié
* Gautier Hayoun
* Carl Meyer
* Iurii Kriachko
14 changes: 11 additions & 3 deletions django_webtest/__init__.py
Expand Up @@ -2,7 +2,7 @@
from django.conf import settings
from django.test.signals import template_rendered
from django.core.handlers.wsgi import WSGIHandler
from django.test import TestCase
from django.test import TestCase, TransactionTestCase
from django.test.client import store_rendered_templates
from django.utils.functional import curry
from django.utils.importlib import import_module
Expand Down Expand Up @@ -144,7 +144,7 @@ def session(self):
return {}


class WebTest(TestCase):
class WebTestMixin(object):

extra_environ = {}
csrf_checks = True
Expand Down Expand Up @@ -215,11 +215,19 @@ def renew_app(self):
def __call__(self, result=None):
self._patch_settings()
self.renew_app()
res = super(WebTest, self).__call__(result)
res = super(WebTestMixin, self).__call__(result)
self._unpatch_settings()
return res


class WebTest(WebTestMixin, TestCase):
pass


class TransactionWebTest(WebTestMixin, TestCase):
pass


def _get_username(user):
"""
Return user's username. ``user`` can be standard Django User
Expand Down