-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
76c30c1
commit 79e65cd
Showing
3 changed files
with
35 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
# Tests / Raw HTML Test | ||
Test cases for `DangerousRawHtml` tag | ||
""" | ||
import pytest | ||
from pyhtml import DangerousRawHtml, html | ||
|
||
|
||
def test_dangerous_raw_html(): | ||
""" | ||
Is raw HTML rendered correctly? | ||
""" | ||
assert str(DangerousRawHtml("<script>alert(1)</script>")) \ | ||
== "<script>alert(1)</script>" | ||
|
||
assert str( | ||
html( | ||
DangerousRawHtml("<script>alert(1)</script>") | ||
) | ||
) == "\n".join([ | ||
"<html>", | ||
" <script>alert(1)</script>", | ||
"</html>", | ||
]) | ||
|
||
|
||
def test_raw_html_not_callable(): | ||
""" | ||
`DangerousRawHtml` elements should not be callable. | ||
""" | ||
with pytest.raises(TypeError): | ||
DangerousRawHtml("")() |