Skip to content

Commit

Permalink
Allow running a whole set of parameterized tests from the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
scosman committed Nov 7, 2024
1 parent 66151a8 commit 42fc982
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,28 @@ def pytest_addoption(parser):
)


def is_single_manual_test(config, items) -> bool:
# Check if we're running manually (eg, in vscode)
if not config.getoption("--runsinglewithoutchecks"):
return False

if len(items) == 1:
return True
if len(items) == 0:
return False

# Check if all of the items are the same prefix, expluding a.b.c[param]
# This is still a 'single test' for the purposes of this flag
prefix = items[0].name.split("[")[0] + "["
for item in items:
if not item.name.startswith(prefix):
return False
return True


def pytest_collection_modifyitems(config, items):
# Always run test if it's a single test invoked, and we have "runsinglewithoutchecks" (which is enabled in vscode params)
if len(items) == 1 and config.getoption("--runsinglewithoutchecks"):
# Always run test if it's a single test manually invoked
if is_single_manual_test(config, items):
return

# Mark tests that use paid services as skipped unless --runpaid is passed
Expand Down

0 comments on commit 42fc982

Please sign in to comment.