Currently I have this implementation where I am running a parameterized pytest in this way:
@pytest.mark.parametrize('int_val', [1, 0])
def test_int_val(self, int_val: int):
# performs all the steps
and running the same test with boolean values this way:
@pytest.mark.parametrize('bool_val', [True, False])
def test_bool_val(self, bool_val: int):
# performs all the steps
Is there a way to combine both the tests in 1 test?
CodePudding user response:
Doing the below:
@pytest.mark.parametrize('bool_val', [True, False, 1, 0])
def test_bool(bool_val):
print(f"VAL: {bool_val}")
# your code
prints this:
tests/tests_temp.py::test_bool[True] VAL: True
PASSED
tests/tests_temp.py::test_bool[False] VAL: False
PASSED
tests/tests_temp.py::test_bool[1] VAL: 1
PASSED
tests/tests_temp.py::test_bool[0] VAL: 0
PASSED
Edit: as per OP's comment