Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop checking STATICFILES_DIRS with Django 4 or better #1455

Merged
merged 1 commit into from
Mar 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions tests/panels/test_staticfiles.py
Original file line number Diff line number Diff line change
@@ -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
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