diff options
| author | Tom Christie | 2015-02-05 00:58:16 +0000 |
|---|---|---|
| committer | Tom Christie | 2015-02-05 00:58:16 +0000 |
| commit | 65bbc4a1598350f3dd7847d3f2f5d98c5d258b92 (patch) | |
| tree | bbf4850dfb19781f137a9029b5cada3057501fe9 /tests/utils.py | |
| parent | 41b213414df57d7e39f1bbf3aaa35a1b033e89a3 (diff) | |
| parent | e1c45133126e0c47b8470b4cf7a43c6a7f4fca43 (diff) | |
| download | django-rest-framework-65bbc4a1598350f3dd7847d3f2f5d98c5d258b92.tar.bz2 | |
Merge branch 'brandoncazander-version-3.1-2489' 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 |
