diff options
| author | José Padilla | 2015-02-04 23:34:20 -0400 |
|---|---|---|
| committer | José Padilla | 2015-02-04 23:34:20 -0400 |
| commit | 720d154c832794e42e23c3ba2fe7b835d4baf386 (patch) | |
| tree | 565ba041aa657c76b33aed5f829c8164e8922da9 /tests/utils.py | |
| parent | 48fa77c09e2198c7877a724a46230caedcc7b529 (diff) | |
| parent | f98f842827c6e79bbaa196482e3c3c549e8999c8 (diff) | |
| download | django-rest-framework-720d154c832794e42e23c3ba2fe7b835d4baf386.tar.bz2 | |
Merge remote-tracking branch 'upstream/version-3.1' into version-3.1
Diffstat (limited to 'tests/utils.py')
| -rw-r--r-- | tests/utils.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/utils.py b/tests/utils.py index 5b2d7586..b9034996 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -2,6 +2,30 @@ from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import NoReverseMatch +class UsingURLPatterns(object): + """ + Isolates URL patterns used during testing on the test class itself. + For example: + + class MyTestCase(UsingURLPatterns, TestCase): + urlpatterns = [ + ... + ] + + def test_something(self): + ... + """ + urls = __name__ + + def setUp(self): + global urlpatterns + urlpatterns = self.urlpatterns + + def tearDown(self): + global urlpatterns + urlpatterns = [] + + class MockObject(object): def __init__(self, **kwargs): self._kwargs = kwargs |
