File tree Expand file tree Collapse file tree 3 files changed +35
-20
lines changed Expand file tree Collapse file tree 3 files changed +35
-20
lines changed Original file line number Diff line number Diff line change 17
17
br ,
18
18
input ,
19
19
a ,
20
- DangerousRawHtml ,
21
20
)
22
21
23
22
@@ -249,21 +248,3 @@ def test_boolean_tag_attributes_false():
249
248
Attributes with value `False` are skipped
250
249
"""
251
250
assert str (input (readonly = False )) == "<input/>"
252
-
253
-
254
- def test_dangerous_raw_html ():
255
- """
256
- Is raw HTML rendered correctly?
257
- """
258
- assert str (DangerousRawHtml ("<script>alert(1)</script>" )) \
259
- == "<script>alert(1)</script>"
260
-
261
- assert str (
262
- html (
263
- DangerousRawHtml ("<script>alert(1)</script>" )
264
- )
265
- ) == "\n " .join ([
266
- "<html>" ,
267
- " <script>alert(1)</script>" ,
268
- "</html>" ,
269
- ])
Original file line number Diff line number Diff line change @@ -76,5 +76,6 @@ def test_failed_to_stringify(client: FlaskClient):
76
76
assert "**HINT:** if you're using Flask" in str (exception_info .value )
77
77
78
78
79
- if __name__ == '__main__' :
79
+ # Ignore coverage since this won't be used when running tests automatically
80
+ if __name__ == '__main__' : # pragma: no cover
80
81
app .run (debug = True )
Original file line number Diff line number Diff line change
1
+ """
2
+ # Tests / Raw HTML Test
3
+
4
+ Test cases for `DangerousRawHtml` tag
5
+ """
6
+ import pytest
7
+ from pyhtml import DangerousRawHtml , html
8
+
9
+
10
+ def test_dangerous_raw_html ():
11
+ """
12
+ Is raw HTML rendered correctly?
13
+ """
14
+ assert str (DangerousRawHtml ("<script>alert(1)</script>" )) \
15
+ == "<script>alert(1)</script>"
16
+
17
+ assert str (
18
+ html (
19
+ DangerousRawHtml ("<script>alert(1)</script>" )
20
+ )
21
+ ) == "\n " .join ([
22
+ "<html>" ,
23
+ " <script>alert(1)</script>" ,
24
+ "</html>" ,
25
+ ])
26
+
27
+
28
+ def test_raw_html_not_callable ():
29
+ """
30
+ `DangerousRawHtml` elements should not be callable.
31
+ """
32
+ with pytest .raises (TypeError ):
33
+ DangerousRawHtml ("" )()
You can’t perform that action at this time.
0 commit comments