Skip to content
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
2 changes: 1 addition & 1 deletion debug_toolbar/panels/staticfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from debug_toolbar import panels


@dataclass(eq=True, frozen=True)
@dataclass(eq=True, frozen=True, order=True)
class StaticFile:
"""
Representing the different properties of a static file.
Expand Down
14 changes: 10 additions & 4 deletions tests/panels/test_staticfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,25 @@ def test_insert_content(self):

def test_path(self):
def get_response(request):
# template contains one static file
return render(
request,
"staticfiles/path.html",
{"path": Path("additional_static/base.css")},
{
"paths": [
Path("additional_static/base.css"),
Path("additional_static/base.css"),
Path("additional_static/base2.css"),
]
},
)

self._get_response = get_response
request = RequestFactory().get("/")
response = self.panel.process_request(request)
self.panel.generate_stats(self.request, response)
self.assertEqual(self.panel.get_stats()["num_used"], 1)
self.assertIn('"/static/additional_static/base.css"', self.panel.content)
self.assertEqual(self.panel.get_stats()["num_used"], 2)
self.assertIn('"/static/additional_static/base.css"', self.panel.content, 1)
self.assertIn('"/static/additional_static/base2.css"', self.panel.content, 1)

def test_storage_state_preservation(self):
"""Ensure the URLMixin doesn't affect storage state"""
Expand Down
4 changes: 1 addition & 3 deletions tests/templates/staticfiles/path.html
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{% load static %}
{# A single file used twice #}
{% static path %}{% static path %}
{% load static %}{% for path in paths %}{% static path %}{% endfor %}