Skip to content

Commit

Permalink
Stop checking STATICFILES_DIRS with Django 4 or better
Browse files Browse the repository at this point in the history
Django 4.0 added its own check for this (staticfiles.W004).
  • Loading branch information
matthiask committed Mar 2, 2021
1 parent 3dc5437 commit d5801b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
20 changes: 3 additions & 17 deletions tests/panels/test_staticfiles.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
import unittest

import django
from django.conf import settings
from django.contrib.staticfiles import finders
from django.core.checks import Warning
Expand Down Expand Up @@ -54,6 +56,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 +84,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
Original file line number Diff line number Diff line change
@@ -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 d5801b8

Please sign in to comment.