Skip to content

Commit cd3c774

Browse files
Fix misnamed class attribute
1 parent b368ff9 commit cd3c774

File tree

7 files changed

+51
-3
lines changed

7 files changed

+51
-3
lines changed

requirements/dev.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ babel==2.14.0
1212
# via
1313
# -r docs.txt
1414
# sphinx
15+
beautifulsoup4==4.12.3
16+
# via -r tests.txt
1517
blinker==1.8.1
1618
# via
1719
# -r tests.txt
@@ -170,6 +172,10 @@ snowballstemmer==2.2.0
170172
# via
171173
# -r docs.txt
172174
# sphinx
175+
soupsieve==2.5
176+
# via
177+
# -r tests.txt
178+
# beautifulsoup4
173179
sphinx==7.1.2
174180
# via
175181
# -r docs.txt
@@ -216,10 +222,16 @@ tomli==2.0.1
216222
# tox
217223
tox==4.15.0
218224
# via -r dev.in
225+
types-beautifulsoup4==4.12.0.20240511
226+
# via -r typing.txt
219227
types-docutils==0.21.0.20240423
220228
# via
221229
# -r typing.txt
222230
# types-pygments
231+
types-html5lib==1.1.11.20240228
232+
# via
233+
# -r typing.txt
234+
# types-beautifulsoup4
223235
types-pygments==2.18.0.20240506
224236
# via -r typing.txt
225237
types-setuptools==69.5.0.20240423

requirements/tests.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pytest
22
flask-sqlalchemy
33
pygments
4+
beautifulsoup4

requirements/tests.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#
55
# pip-compile tests.in
66
#
7+
beautifulsoup4==4.12.3
8+
# via -r tests.in
79
blinker==1.8.1
810
# via flask
911
click==8.1.7
@@ -36,6 +38,8 @@ pygments==2.18.0
3638
# via -r tests.in
3739
pytest==8.2.1
3840
# via -r tests.in
41+
soupsieve==2.5
42+
# via beautifulsoup4
3943
sqlalchemy==2.0.29
4044
# via flask-sqlalchemy
4145
tomli==2.0.1

requirements/typing.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ pyright
33
pytest
44
types-pygments
55
flask-sqlalchemy
6+
types-beautifulsoup4

requirements/typing.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ tomli==2.0.1
4848
# via
4949
# mypy
5050
# pytest
51+
types-beautifulsoup4==4.12.0.20240511
52+
# via -r typing.in
5153
types-docutils==0.21.0.20240423
5254
# via types-pygments
55+
types-html5lib==1.1.11.20240228
56+
# via types-beautifulsoup4
5357
types-pygments==2.18.0.20240506
5458
# via -r typing.in
5559
types-setuptools==69.5.0.20240423

src/flask_debugtoolbar/panels/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DebugPanel:
1818
has_content = False
1919

2020
# If the client is able to activate/de-activate the panel
21-
user_enable = False
21+
user_activate = False
2222

2323
# We'll maintain a local context instance so we can expose our template
2424
# context variables to panels which need them:
@@ -62,8 +62,9 @@ def render(self, template_name: str, context: dict[str, t.Any]) -> str:
6262
template = self.jinja_env.get_template(template_name)
6363
return template.render(**context)
6464

65-
def dom_id(self) -> str:
66-
return f"flDebug{self.name.replace(' ', '')}Panel"
65+
@classmethod
66+
def dom_id(cls) -> str:
67+
return f"flDebug{cls.name.replace(' ', '')}Panel"
6768

6869
def nav_title(self) -> str:
6970
"""Title showing in toolbar"""

tests/test_toolbar.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from __future__ import annotations
22

3+
from bs4 import BeautifulSoup
34
from flask import Flask
45
from flask.testing import FlaskClient
6+
from werkzeug.utils import import_string
57

68

79
def load_app(name: str) -> FlaskClient:
@@ -15,3 +17,26 @@ def test_basic_app() -> None:
1517
index = app.get("/")
1618
assert index.status_code == 200
1719
assert b'<div id="flDebug"' in index.data
20+
21+
22+
def test_debug_switch_included_for_user_activated_panels() -> None:
23+
checked_panels = set()
24+
25+
app = load_app("basic_app")
26+
index = app.get("/")
27+
28+
soup = BeautifulSoup(index.text, "html.parser")
29+
30+
for panel in app.application.config["DEBUG_TB_PANELS"]:
31+
panel_cls = import_string(panel)
32+
panel_id = panel_cls.dom_id()
33+
panel_element = soup.select_one(f"#{panel_id}")
34+
35+
assert panel_element
36+
assert (
37+
bool(panel_element.select_one(".flDebugSwitch")) is panel_cls.user_activate
38+
), f"Panel {panel_id} is incorrectly showing (or not showing) a debug switch"
39+
40+
checked_panels.add(panel_id)
41+
42+
assert len(checked_panels) == len(app.application.config["DEBUG_TB_PANELS"])

0 commit comments

Comments
 (0)