From 5abf40a8f00b77497912413992db9c4a3c9c1bbf Mon Sep 17 00:00:00 2001 From: Daniel Harding Date: Mon, 11 Mar 2024 15:53:14 +0300 Subject: [PATCH] Remove obsolete tests There were two tests that were skipped on Django 4.0 and later. However, since the toolbar's minimum supported Django version is now 4.2, these tests will always be skipped and thus can be removed. --- tests/panels/test_staticfiles.py | 33 -------------------------------- tests/test_checks.py | 19 ------------------ 2 files changed, 52 deletions(-) diff --git a/tests/panels/test_staticfiles.py b/tests/panels/test_staticfiles.py index 32ed7ea61..5c0ec74b0 100644 --- a/tests/panels/test_staticfiles.py +++ b/tests/panels/test_staticfiles.py @@ -1,10 +1,7 @@ import os -import unittest -import django from django.conf import settings from django.contrib.staticfiles import finders -from django.test.utils import override_settings from ..base import BaseTestCase @@ -52,33 +49,3 @@ def test_insert_content(self): "django.contrib.staticfiles.finders.AppDirectoriesFinder", content ) 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, - ) - def test_finder_directory_does_not_exist(self): - """Misconfigure the static files settings and verify the toolbar runs. - - The test case is that the STATIC_ROOT is in STATICFILES_DIRS and that - the directory of STATIC_ROOT does not exist. - """ - response = self.panel.process_request(self.request) - self.panel.generate_stats(self.request, response) - content = self.panel.content - self.assertIn( - "django.contrib.staticfiles.finders.AppDirectoriesFinder", content - ) - self.assertNotIn( - "django.contrib.staticfiles.finders.FileSystemFinder (2 files)", content - ) - self.assertEqual(self.panel.num_used, 0) - self.assertNotEqual(self.panel.num_found, 0) - expected_apps = ["django.contrib.admin", "debug_toolbar"] - if settings.USE_GIS: - expected_apps = ["django.contrib.gis"] + expected_apps - self.assertEqual(self.panel.get_staticfiles_apps(), expected_apps) - self.assertEqual( - self.panel.get_staticfiles_dirs(), finders.FileSystemFinder().locations - ) diff --git a/tests/test_checks.py b/tests/test_checks.py index 8e4f8e62f..50e83aa70 100644 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -1,8 +1,6 @@ import os -import unittest from unittest.mock import patch -import django from django.conf import settings from django.core.checks import Warning, run_checks from django.test import SimpleTestCase, override_settings @@ -92,23 +90,6 @@ 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], - ) - def test_panel_check_errors(self): - messages = 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", - ) - ], - ) - @override_settings(DEBUG_TOOLBAR_PANELS=[]) def test_panels_is_empty(self): errors = run_checks()