diff options
| author | Tom Christie | 2015-02-13 13:38:44 +0000 |
|---|---|---|
| committer | Tom Christie | 2015-02-13 13:38:44 +0000 |
| commit | 4248a8d3fc725d9ae3fe7aaaad7ee12479ab07ab (patch) | |
| tree | c38485aec717a35de8691c3d55bd50ba3e4aae6d /tests/utils.py | |
| parent | 84260b5dd66cc31858898ff11d5300a73083cca1 (diff) | |
| parent | ad32e14360a23ee3e93ff54ca206c64009d184c9 (diff) | |
| download | django-rest-framework-4248a8d3fc725d9ae3fe7aaaad7ee12479ab07ab.tar.bz2 | |
Merge pull request #2198 from tomchristie/version-3.1
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 |
