Skip to content

Instantly share code, notes, and snippets.

@danjac
Created December 31, 2023 09:25
Show Gist options
  • Save danjac/72e00f39d53702de9c20553a941a8343 to your computer and use it in GitHub Desktop.
Save danjac/72e00f39d53702de9c20553a941a8343 to your computer and use it in GitHub Desktop.
Using pytest.param with parametrize
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