|
1 | 1 | import os
|
| 2 | +import unittest |
2 | 3 |
|
| 4 | +import django |
3 | 5 | from django.conf import settings
|
4 | 6 | from django.contrib.staticfiles import finders
|
5 |
| -from django.core.checks import Warning |
6 |
| -from django.test import SimpleTestCase |
7 | 7 | from django.test.utils import override_settings
|
8 | 8 |
|
9 |
| -from debug_toolbar.panels.staticfiles import StaticFilesPanel |
10 |
| - |
11 | 9 | from ..base import BaseTestCase
|
12 | 10 |
|
13 | 11 | PATH_DOES_NOT_EXIST = os.path.join(settings.BASE_DIR, "tests", "invalid_static")
|
@@ -54,6 +52,7 @@ def test_insert_content(self):
|
54 | 52 | )
|
55 | 53 | self.assertValidHTML(content)
|
56 | 54 |
|
| 55 | + @unittest.skipIf(django.VERSION >= (4,), "Django>=4 handles missing dirs itself.") |
57 | 56 | @override_settings(
|
58 | 57 | STATICFILES_DIRS=[PATH_DOES_NOT_EXIST] + settings.STATICFILES_DIRS,
|
59 | 58 | STATIC_ROOT=PATH_DOES_NOT_EXIST,
|
@@ -81,20 +80,3 @@ def test_finder_directory_does_not_exist(self):
|
81 | 80 | self.assertEqual(
|
82 | 81 | self.panel.get_staticfiles_dirs(), finders.FileSystemFinder().locations
|
83 | 82 | )
|
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 |
| - ) |
0 commit comments