Skip to content

fix: Resolve test collisions when capsys used - #6013

Open
davem-bis wants to merge 3 commits into
SQLMesh:mainfrom
davem-bis:feature/DRM/resolve-test-collisions-in-parallel-run
Open

fix: Resolve test collisions when capsys used#6013
davem-bis wants to merge 3 commits into
SQLMesh:mainfrom
davem-bis:feature/DRM/resolve-test-collisions-in-parallel-run

Conversation

@davem-bis

@davem-bis davem-bis commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Description

Tests that use capsys can collide with each other as capsys is not threadsafe.

I have modified conftest.py to apply the isolated pytest marker (so they tests run sequentially) if capsys is passed to the test.

Test Plan

  • make fast-test passes.

  • PyTest correctly flags tests that use capsys as marked with isolated:

    image

    Note that test_python_model_empty_df_raises does not have the isolated marker applied to it directly, it is dynamically added by the changes to conftest.

    image

Checklist

  • I have run make style and fixed any issues
  • I have added tests for my changes (if applicable) (N/A)
  • All existing tests pass (make fast-test)
  • My commits are signed off (git commit -s) per the DCO

Signed-off-by: davem-bis <68955845+davem-bis@users.noreply.github.com>
@davem-bis
davem-bis force-pushed the feature/DRM/resolve-test-collisions-in-parallel-run branch from 267388d to 85c40c3 Compare September 2, 2026 12:56
@davem-bis
davem-bis marked this pull request as ready for review September 2, 2026 13:56
@cmgoffena13

Copy link
Copy Markdown
Collaborator

Appreciate you wanting to help stabilize the CI!

Something I noticed is we have capsys stuff in the slow tests as well. So to make sure we properly tag stuff you'd want to reorder the labeling in conftest.py like this:

for item in items:
    if "capsys" in item.fixturenames:
        item.add_marker("isolated")
    for marker in item.iter_markers():
        if marker.name in test_type_markers:
            break
    else:
        item.add_marker("fast")

And then we can modify the make commands to exclude isolated and just run them after:

fast-test:
	pytest -n auto -m "fast and not cicdonly and not isolated" --junitxml=test-results/junit-fast-test.xml && pytest -m "isolated and not slow" && pytest -m "registry_isolation" && pytest -m "dialect_isolated"

slow-test:
	pytest -n auto -m "(fast or slow) and not cicdonly and not isolated" && pytest -m "isolated" && pytest -m "registry_isolation" && pytest -m "dialect_isolated"

cicd-test:
	pytest -n auto -m "(fast or slow) and not pyspark and not isolated" --junitxml=test-results/junit-cicd.xml && pytest -m "pyspark" && pytest -m "isolated" && pytest -m "registry_isolation" && pytest -m "dialect_isolated"

That should address this issue regardless of fast, slow, or cicdonly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants