From a7af1e2756e99c51d4a43fe85f664be1a30795fe Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Thu, 16 Jan 2025 11:25:46 +0100 Subject: [PATCH] Refs #35090 -- Fixed urlpatterns.tests.SimplifiedURLTests when run in reverse. Regression in 9cb1ffa67bb0d13f86c2d4627428fcaa4513136d. --- tests/urlpatterns/tests.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/urlpatterns/tests.py b/tests/urlpatterns/tests.py index 5f1a45ba1f..8636ef15f9 100644 --- a/tests/urlpatterns/tests.py +++ b/tests/urlpatterns/tests.py @@ -13,7 +13,7 @@ from django.urls import ( resolve, reverse, ) -from django.urls.converters import IntConverter +from django.urls.converters import REGISTERED_CONVERTERS, IntConverter from django.views import View from .converters import Base64Converter, DynamicConverter @@ -209,8 +209,12 @@ class SimplifiedURLTests(SimpleTestCase): def test_warning_override_converter(self): msg = "Converter 'base64' is already registered." - with self.assertRaisesMessage(ValueError, msg): - register_converter(Base64Converter, "base64") + try: + with self.assertRaisesMessage(ValueError, msg): + register_converter(Base64Converter, "base64") + register_converter(Base64Converter, "base64") + finally: + REGISTERED_CONVERTERS.pop("base64", None) def test_invalid_view(self): msg = "view must be a callable or a list/tuple in the case of include()."