I have two markers setup in my pytest.ini file which looks like
[pytest]
markers =
fast: mark test as fast test
slow: mark test as slow test
And I have a test class which uses parameters like
@pytest.mark.usefixtures('page')
class TestClassFoo:
@pytest.fixture(scope='class', autouse=True)
def setup_teardown(self, page):
name = f'Name: {self.__class__.__name__} {datetime.now()}'
desc = f'Desc: {self.__class__.__name__} {datetime.now()}'
yield
param_names = 'search_criteria_1, search_criteria_2, expected'
param_values = [
('criteria_a', 'criteria_b', 'expected_1'),
('criteria_c', '', 'expected_2'),
]
@pytest.mark.parametrize(param_names, param_values)
def test_foo(self, page, search_criteria_1, search_criteria_2, expected):
select(search_criteria_1)
select(search_criteria_2)
count = get_count()
assert count >= expected_results[expected]
I have tried to add test markers to the individual param_values like
param_values = [
('criteria_a', 'criteria_b', 'expected_1', 'marks=pytest.mark.slow'),
('criteria_c', '', 'expected_2', 'marks=pytest.mark.fast'),
]
@pytest.mark.parametrize(param_names, param_values)
which has not worked, along with other similar attempts. Additionally, it is not exactly what I want.
I am wondering either
- Can I do something like this, but RANDOMLY assign the 'fast' marker to one parameter, and assigning 'slow' to the other parameter values
- If the above is not possible, what do I need to do to 'hard code' the markers into the parameter values as I have been attempting
Thank you for any help!