Skip to content

Commit 1e36c05

Browse files
committed
Stop checking STATICFILES_DIRS with Django 4 or better
Django 4.0 added its own check for this (staticfiles.W004).
1 parent 3dc5437 commit 1e36c05

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

tests/panels/test_staticfiles.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import os
2+
import unittest
23

4+
import django
35
from django.conf import settings
46
from django.contrib.staticfiles import finders
5-
from django.core.checks import Warning
6-
from django.test import SimpleTestCase
77
from django.test.utils import override_settings
88

9-
from debug_toolbar.panels.staticfiles import StaticFilesPanel
10-
119
from ..base import BaseTestCase
1210

1311
PATH_DOES_NOT_EXIST = os.path.join(settings.BASE_DIR, "tests", "invalid_static")
@@ -54,6 +52,7 @@ def test_insert_content(self):
5452
)
5553
self.assertValidHTML(content)
5654

55+
@unittest.skipIf(django.VERSION >= (4,), "Django>=4 handles missing dirs itself.")
5756
@override_settings(
5857
STATICFILES_DIRS=[PATH_DOES_NOT_EXIST] + settings.STATICFILES_DIRS,
5958
STATIC_ROOT=PATH_DOES_NOT_EXIST,
@@ -81,20 +80,3 @@ def test_finder_directory_does_not_exist(self):
8180
self.assertEqual(
8281
self.panel.get_staticfiles_dirs(), finders.FileSystemFinder().locations
8382
)
84-
85-
86-
@override_settings(DEBUG=True)
87-
class StaticFilesPanelChecksTestCase(SimpleTestCase):
88-
@override_settings(STATICFILES_DIRS=[PATH_DOES_NOT_EXIST])
89-
def test_run_checks(self):
90-
messages = StaticFilesPanel.run_checks()
91-
self.assertEqual(
92-
messages,
93-
[
94-
Warning(
95-
"debug_toolbar requires the STATICFILES_DIRS directories to exist.",
96-
hint="Running manage.py collectstatic may help uncover the issue.",
97-
id="debug_toolbar.staticfiles.W001",
98-
)
99-
],
100-
)

tests/test_checks.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import os
2+
import unittest
23

4+
import django
35
from django.conf import settings
46
from django.core.checks import Warning, run_checks
57
from django.test import SimpleTestCase, override_settings
@@ -89,6 +91,7 @@ def test_check_middleware_classes_error(self):
8991
messages,
9092
)
9193

94+
@unittest.skipIf(django.VERSION >= (4,), "Django>=4 handles missing dirs itself.")
9295
@override_settings(
9396
STATICFILES_DIRS=[PATH_DOES_NOT_EXIST],
9497
)

0 commit comments

Comments
 (0)