parametrize and running a single test in pytest

You can specify the tests to run by using the -k flag for filtering tests that match a string expression. When using parametrize, pytest names each test case with the following convention:

test_name[‘-‘ separated test inputs]

for example

test_name[First_test_value-Second_test_value-N_test_value]

Selecting an specific test to run is a matter of putting all the above together for example

pytest -k 'my_test[value_1-value_2]'

or

pytest -k my_test\[value_1-value_2\]

You need to escape the square brackets.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)