Skip to content

Commit 5ba248b

Browse files
committed
Clear the url cache
1 parent 5f33d32 commit 5ba248b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pytest_django/plugin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def _django_set_urlconf(request):
314314
if marker:
315315
skip_if_no_django()
316316
import django.conf
317-
from django.core.urlresolvers import clear_url_caches
317+
from django.core.urlresolvers import clear_url_caches, set_urlconf
318318

319319
validate_urls(marker)
320320
original_urlconf = django.conf.settings.ROOT_URLCONF
@@ -323,6 +323,10 @@ def _django_set_urlconf(request):
323323

324324
def restore():
325325
django.conf.settings.ROOT_URLCONF = original_urlconf
326+
# Copy the pattern from
327+
# https://github.com/django/django/blob/master/django/test/signals.py#L152
328+
clear_url_caches()
329+
set_urlconf(None)
326330

327331
request.addfinalizer(restore)
328332

0 commit comments

Comments
 (0)