summaryrefslogtreecommitdiff
path: root/tests/deprecation/tests.py
diff options
context:
space:
mode:
authorAdam Johnson <me@adamj.eu>2025-09-12 09:35:01 +0100
committerGitHub <noreply@github.com>2025-09-12 10:35:01 +0200
commit7b26b64a63b5fc15134426a6ee0534dca2a1a855 (patch)
treed9b4adfe485e3de352269e1fc7dd13d25875054d /tests/deprecation/tests.py
parent41bc48ac1ed1d515977ebe965993b1ef83eafd02 (diff)
Refs #35667 -- Cached Django file prefixes for warnings.
Diffstat (limited to 'tests/deprecation/tests.py')
-rw-r--r--tests/deprecation/tests.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/deprecation/tests.py b/tests/deprecation/tests.py
index 66f6a4d922..3d384b38b7 100644
--- a/tests/deprecation/tests.py
+++ b/tests/deprecation/tests.py
@@ -1,7 +1,32 @@
+import os
import warnings
+import django
from django.test import SimpleTestCase
-from django.utils.deprecation import RemovedAfterNextVersionWarning, RenameMethodsBase
+from django.utils.deprecation import (
+ RemovedAfterNextVersionWarning,
+ RenameMethodsBase,
+ django_file_prefixes,
+)
+
+
+class DjangoFilePrefixesTests(SimpleTestCase):
+ def setUp(self):
+ django_file_prefixes.cache_clear()
+
+ def test_no_file(self):
+ orig_file = django.__file__
+ try:
+ del django.__file__
+ self.assertEqual(django_file_prefixes(), ())
+ finally:
+ django.__file__ = orig_file
+
+ def test_with_file(self):
+ prefixes = django_file_prefixes()
+ self.assertIsInstance(prefixes, tuple)
+ self.assertEqual(len(prefixes), 1)
+ self.assertTrue(prefixes[0].endswith(f"{os.path.sep}django"))
class RenameManagerMethods(RenameMethodsBase):