diff options
| author | Tom Christie | 2015-02-05 00:58:09 +0000 |
|---|---|---|
| committer | Tom Christie | 2015-02-05 00:58:09 +0000 |
| commit | e1c45133126e0c47b8470b4cf7a43c6a7f4fca43 (patch) | |
| tree | bbf4850dfb19781f137a9029b5cada3057501fe9 /tests/utils.py | |
| parent | 83673e8f74abc6dfd77e9b87eca6da9ec319da2b (diff) | |
| download | django-rest-framework-e1c45133126e0c47b8470b4cf7a43c6a7f4fca43.tar.bz2 | |
Fix NamespaceVersioning with hyperlinked serializer fields
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 |
