Last active
August 10, 2017 17:23
-
-
Save abehmiel/5b36ae5d250aa3b4ff965a2ab7ca27ef to your computer and use it in GitHub Desktop.
Even better parameterized pytest boilerplate
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
# 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