Skip to content

Commit e692a93

Browse files
Fix misnamed class attribute
1 parent b368ff9 commit e692a93

File tree

7 files changed

+56
-3
lines changed

7 files changed

+56
-3
lines changed

requirements/dev.txt

Lines changed: 14 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
@@ -101,6 +103,8 @@ jinja2==3.1.4
101103
# -r typing.txt
102104
# flask
103105
# sphinx
106+
lxml==5.2.2
107+
# via -r tests.txt
104108
markupsafe==2.1.5
105109
# via
106110
# -r docs.txt
@@ -170,6 +174,10 @@ snowballstemmer==2.2.0
170174
# via
171175
# -r docs.txt
172176
# sphinx
177+
soupsieve==2.5
178+
# via
179+
# -r tests.txt
180+
# beautifulsoup4
173181
sphinx==7.1.2
174182
# via
175183
# -r docs.txt
@@ -216,10 +224,16 @@ tomli==2.0.1
216224
# tox
217225
tox==4.15.0
218226
# via -r dev.in
227+
types-beautifulsoup4==4.12.0.20240511
228+
# via -r typing.txt
219229
types-docutils==0.21.0.20240423
220230
# via
221231
# -r typing.txt
222232
# types-pygments
233+
types-html5lib==1.1.11.20240228
234+
# via
235+
# -r typing.txt
236+
# types-beautifulsoup4
223237
types-pygments==2.18.0.20240506
224238
# via -r typing.txt
225239
types-setuptools==69.5.0.20240423

requirements/tests.in

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

requirements/tests.txt

Lines changed: 6 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
@@ -24,6 +26,8 @@ itsdangerous==2.2.0
2426
# via flask
2527
jinja2==3.1.4
2628
# via flask
29+
lxml==5.2.2
30+
# via -r tests.in
2731
markupsafe==2.1.5
2832
# via
2933
# jinja2
@@ -36,6 +40,8 @@ pygments==2.18.0
3640
# via -r tests.in
3741
pytest==8.2.1
3842
# via -r tests.in
43+
soupsieve==2.5
44+
# via beautifulsoup4
3945
sqlalchemy==2.0.29
4046
# via flask-sqlalchemy
4147
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)