1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #23895 -- Prevented pickling of ResolverMatch.

Pickling a ResolverMatch did not work correctly in many cases,
especially with CBVs and URLResolvers in the list of tried URL paths.
This commit is contained in:
Jonathan Davis
2021-07-29 06:04:56 +01:00
committed by GitHub
parent 85d47a58bf
commit 4c6a6d5ac7
3 changed files with 12 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
"""
Unit tests for reverse URL lookups.
"""
import pickle
import sys
import threading
@@ -1167,6 +1168,12 @@ class ResolverMatchTests(SimpleTestCase):
f"route='{name}/')",
)
@override_settings(ROOT_URLCONF='urlpatterns.path_urls')
def test_pickling(self):
msg = 'Cannot pickle ResolverMatch.'
with self.assertRaisesMessage(pickle.PicklingError, msg):
pickle.dumps(resolve('/users/'))
@override_settings(ROOT_URLCONF='urlpatterns_reverse.erroneous_urls')
class ErroneousViewTests(SimpleTestCase):