Skip to content

Instantly share code, notes, and snippets.

@abehmiel
Last active August 10, 2017 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abehmiel/5b36ae5d250aa3b4ff965a2ab7ca27ef to your computer and use it in GitHub Desktop.
Save abehmiel/5b36ae5d250aa3b4ff965a2ab7ca27ef to your computer and use it in GitHub Desktop.
Even better parameterized pytest boilerplate
# test_prime.py
# from James Routley's blog: https://jamesroutley.co.uk/tech/2017/08/09/parameterise-python-tests.html
import pytest
from prime import is_prime
@pytest.mark.parametrize("x,output", [
(-1, False),
(0, False),
(1, False),
(2, True),
(3, True),
(10, False),
(53, True),
])
def test_is_prime(x, output):
assert is_prime(x) == output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment