Ticket #32665: 32665-tests.diff

File 32665-tests.diff, 1.6 KB (added by Mariusz Felisiak, 3 years ago)

Regression tests.

  • tests/check_framework/test_caches.py

    diff --git a/tests/check_framework/test_caches.py b/tests/check_framework/test_caches.py
    index a3ddfd64e7..3b6b41d442 100644
    a b class CheckCacheLocationTest(SimpleTestCase):  
    9191            with self.subTest(setting=setting), self.settings(**settings):
    9292                self.assertEqual(check_cache_location_not_exposed(None), [])
    9393
     94    def test_staticfiles_dirs_prefix(self):
     95        root = pathlib.Path.cwd()
     96        tests = [
     97            (root, root, 'matches'),
     98            (root / 'cache', root, 'is inside'),
     99            (root, root / 'other', 'contains'),
     100        ]
     101        for cache_path, setting_path, msg in tests:
     102            settings = self.get_settings(
     103                'STATICFILES_DIRS',
     104                cache_path,
     105                ('prefix', setting_path),
     106            )
     107            with self.subTest(path=setting_path), self.settings(**settings):
     108                msg = self.warning_message % (msg, 'STATICFILES_DIRS')
     109                self.assertEqual(check_cache_location_not_exposed(None), [
     110                    Warning(msg, id='caches.W002'),
     111                ])
     112
     113    def test_staticfiles_dirs_prefix_not_conflict(self):
     114        root = pathlib.Path.cwd()
     115        settings = self.get_settings(
     116            'STATICFILES_DIRS',
     117            root / 'cache',
     118            ('prefix', root / 'other'),
     119        )
     120        with self.settings(**settings):
     121            self.assertEqual(check_cache_location_not_exposed(None), [])
     122
    94123
    95124class CheckCacheAbsolutePath(SimpleTestCase):
    96125    def test_absolute_path(self):
Back to Top