Skip to content

Instantly share code, notes, and snippets.

@pknowledge
Created October 22, 2018 16:02
Show Gist options
  • Save pknowledge/1eed13b4f0da8e30a432b4fadf874bfb to your computer and use it in GitHub Desktop.
Save pknowledge/1eed13b4f0da8e30a432b4fadf874bfb to your computer and use it in GitHub Desktop.
Python Unit Testing With Pytest - Parameterizing tests
def add(x, y):
return x + y
import math_func
import pytest
@pytest.mark.parametrize('num1, num2, result',
[
(7, 3, 10),
('Hello', ' World', 'Hello World'),
(10.5, 25.5, 36)
]
)
def test_add(num1, num2, result):
assert math_func.add(num1, num2) == result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment