Skip to content

Instantly share code, notes, and snippets.

@DanSmaR
Forked from pknowledge/math_func.py
Created February 25, 2023 14:06
Show Gist options
  • Select an option

  • Save DanSmaR/d396a244a8e073c569875a565a042e61 to your computer and use it in GitHub Desktop.

Select an option

Save DanSmaR/d396a244a8e073c569875a565a042e61 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