pytest
pytest copied to clipboard
Parametrized params listed in reverse order in failed tests output
- [X] a detailed description of the bug or suggestion
- [ ] output of
pip listfrom the virtual environment you are using - [X] pytest and operating system versions
- [X] minimal example if possible
Consider following test:
def my_func(use_x, use_y, use_z):
return 1
class Tests:
@pytest.mark.parametrize("use_x", [0, 1, 2])
@pytest.mark.parametrize("use_y", [0, 1, 2])
@pytest.mark.parametrize("use_z", [0, 1, 2])
def test_test_f(self, use_x, use_y, use_z):
print("use_x =", use_x, "use_y =", use_y, "use_z =", use_z)
assert my_func(use_x, use_y, use_z) != 1
Output of one of the failed tests (for others situation is similar):
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― Tests.test_test_f[2-1-0] ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
../../Coding/Python/TEST/tests.py:51: in test_test_f
assert my_func(use_x, use_y, use_z) != 1
E assert 1 != 1
E + where 1 = my_func(0, 1, 2)
------------------------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------------------------
use_x = 0 use_y = 1 use_z = 2
Problem (or rather inconvenience) is that in the head of the output params are listed in reverse order. Compare:
――― Tests.test_test_f[2-1-0] ―――
use_x = 0 use_y = 1 use_z = 2
Without using print and with more parametrized params it begins really uncomfortable to debug fails.
pytest 4.6.4 OS Ubuntu 19.04