I'm looking to do some tests and I'm not really familiar with the URLResolver
quite yet but I'd like to solve this issue quickly.
In a TestCase
, I'd like to add a URL to the resolver so that I can then use Client.get('/url/')
and keep it separate from urls.py
.
Since Django 1.8 using of django.test.TestCase.urls
is deprecated. You can use django.test.utils.override_settings
instead:
from django.test import TestCase from django.test.utils import override_settings urlpatterns = [ # custom urlconf ] @override_settings(ROOT_URLCONF=__name__) class MyTestCase(TestCase): pass
override_settings
can be applied either to a whole class or to a particular method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With