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 1717 br ,
1818 input ,
1919 a ,
20- DangerousRawHtml ,
2120)
2221
2322
@@ -249,21 +248,3 @@ def test_boolean_tag_attributes_false():
249248 Attributes with value `False` are skipped
250249 """
251250 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):
7676 assert "**HINT:** if you're using Flask" in str (exception_info .value )
7777
7878
79- if __name__ == '__main__' :
79+ # Ignore coverage since this won't be used when running tests automatically
80+ if __name__ == '__main__' : # pragma: no cover
8081 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