Skip to content

repeat tests change to happen after -k #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 31 additions & 17 deletions pytest_repeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,35 @@ def __pytest_repeat_step_number(request):

@pytest.hookimpl(trylast=True)
def pytest_generate_tests(metafunc):
# Retrieve the configured count for repetitions
count = metafunc.config.option.count
m = metafunc.definition.get_closest_marker('repeat')
if m is not None:
count = int(m.args[0])
if count > 1:
metafunc.fixturenames.append("__pytest_repeat_step_number")

def make_progress_id(i, n=count):
return '{0}-{1}'.format(i + 1, n)

scope = metafunc.config.option.repeat_scope
metafunc.parametrize(
'__pytest_repeat_step_number',
range(count),
indirect=True,
ids=make_progress_id,
scope=scope
)

k_option = metafunc.config.option.keyword

repeat_marker = metafunc.definition.get_closest_marker('repeat')

if repeat_marker is not None:
count = int(repeat_marker.args[0])

# function to add parameterization for test repetition
def apply_repetition():
if count > 1:
metafunc.fixturenames.append("__pytest_repeat_step_number")

def make_progress_id(i, n=count):
return '{0}-{1}'.format(i + 1, n)

scope = metafunc.config.option.repeat_scope
metafunc.parametrize(
'__pytest_repeat_step_number',
range(count),
indirect=True,
ids=make_progress_id,
scope=scope
)

if k_option:
if k_option in metafunc.definition.nodeid:
apply_repetition()
else:
apply_repetition()
Loading