Created
October 22, 2018 16:02
-
-
Save pknowledge/1eed13b4f0da8e30a432b4fadf874bfb to your computer and use it in GitHub Desktop.
Python Unit Testing With Pytest - Parameterizing tests
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
| def add(x, y): | |
| return x + y |
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
| 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