Created
December 31, 2023 09:25
-
-
Save danjac/72e00f39d53702de9c20553a941a8343 to your computer and use it in GitHub Desktop.
Using pytest.param with parametrize
This file contains hidden or 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
class TestMarkdown: | |
@pytest.mark.parametrize( | |
("value", "expected"), | |
[ | |
pytest.param(None, "", id="none"), | |
pytest.param("", "", id="empty"), | |
pytest.param("test", "<p>test</p>\n", id="text"), | |
pytest.param(" ", "", id="space"), | |
pytest.param("<p>test</p>", "<p>test</p>", id="html"), | |
pytest.param("<p>test</p> ", "<p>test</p>", id="html and spaces"), | |
pytest.param("<script>test</script>", "", id="unsafe html"), | |
], | |
) | |
def test_markdown(self, value, expected): | |
assert markdown(value) == {"content": expected} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment