Skip to content

Commit

Permalink
Stop checking STATICFILES_DIRS with Django 4 or better (#1455)
Browse files Browse the repository at this point in the history
Django 4.0 added its own check for this (staticfiles.W004). 

Also, removed a duplicated unit test for this problem.
  • Loading branch information
matthiask committed Mar 6, 2021
1 parent 3dc5437 commit 06bf4ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
24 changes: 3 additions & 21 deletions tests/panels/test_staticfiles.py
@@ -1,13 +1,11 @@
import os
import unittest

import django
from django.conf import settings
from django.contrib.staticfiles import finders
from django.core.checks import Warning
from django.test import SimpleTestCase
from django.test.utils import override_settings

from debug_toolbar.panels.staticfiles import StaticFilesPanel

from ..base import BaseTestCase

PATH_DOES_NOT_EXIST = os.path.join(settings.BASE_DIR, "tests", "invalid_static")
Expand Down Expand Up @@ -54,6 +52,7 @@ def test_insert_content(self):
)
self.assertValidHTML(content)

@unittest.skipIf(django.VERSION >= (4,), "Django>=4 handles missing dirs itself.")
@override_settings(
STATICFILES_DIRS=[PATH_DOES_NOT_EXIST] + settings.STATICFILES_DIRS,
STATIC_ROOT=PATH_DOES_NOT_EXIST,
Expand Down Expand Up @@ -81,20 +80,3 @@ def test_finder_directory_does_not_exist(self):
self.assertEqual(
self.panel.get_staticfiles_dirs(), finders.FileSystemFinder().locations
)


@override_settings(DEBUG=True)
class StaticFilesPanelChecksTestCase(SimpleTestCase):
@override_settings(STATICFILES_DIRS=[PATH_DOES_NOT_EXIST])
def test_run_checks(self):
messages = StaticFilesPanel.run_checks()
self.assertEqual(
messages,
[
Warning(
"debug_toolbar requires the STATICFILES_DIRS directories to exist.",
hint="Running manage.py collectstatic may help uncover the issue.",
id="debug_toolbar.staticfiles.W001",
)
],
)
3 changes: 3 additions & 0 deletions tests/test_checks.py
@@ -1,5 +1,7 @@
import os
import unittest

import django
from django.conf import settings
from django.core.checks import Warning, run_checks
from django.test import SimpleTestCase, override_settings
Expand Down Expand Up @@ -89,6 +91,7 @@ def test_check_middleware_classes_error(self):
messages,
)

@unittest.skipIf(django.VERSION >= (4,), "Django>=4 handles missing dirs itself.")
@override_settings(
STATICFILES_DIRS=[PATH_DOES_NOT_EXIST],
)
Expand Down

0 comments on commit 06bf4ba

Please sign in to comment.