Refs #29983 -- Added tests for FileBasedCache pathlib support.
diff --git a/tests/cache/tests.py b/tests/cache/tests.py
index 2e17127ce9369..1b2a9490f6de3 100644
--- a/tests/cache/tests.py
+++ b/tests/cache/tests.py
@@ -10,6 +10,7 @@
 import threading
 import time
 import unittest
+from pathlib import Path
 from unittest import mock
 
 from django.conf import settings
@@ -1422,12 +1423,12 @@ class FileBasedCacheTests(BaseCacheTests, TestCase):
 
     def setUp(self):
         super().setUp()
-        self.dirname = tempfile.mkdtemp()
+        self.dirname = self.mkdtemp()
         # Caches location cannot be modified through override_settings / modify_settings,
         # hence settings are manipulated directly here and the setting_changed signal
         # is triggered manually.
         for cache_params in settings.CACHES.values():
-            cache_params.update({'LOCATION': self.dirname})
+            cache_params['LOCATION'] = self.dirname
         setting_changed.send(self.__class__, setting='CACHES', enter=False)
 
     def tearDown(self):
@@ -1435,6 +1436,9 @@ def tearDown(self):
         # Call parent first, as cache.clear() may recreate cache base directory
         shutil.rmtree(self.dirname)
 
+    def mkdtemp(self):
+        return tempfile.mkdtemp()
+
     def test_ignores_non_cache_files(self):
         fname = os.path.join(self.dirname, 'not-a-cache-file')
         with open(fname, 'w'):
@@ -1473,6 +1477,12 @@ def test_empty_cache_file_considered_expired(self):
             self.assertIs(cache._is_expired(fh), True)
 
 
+class FileBasedCachePathLibTests(FileBasedCacheTests):
+    def mkdtemp(self):
+        tmp_dir = super().mkdtemp()
+        return Path(tmp_dir)
+
+
 @override_settings(CACHES={
     'default': {
         'BACKEND': 'cache.liberal_backend.CacheClass',
