-
Couldn't load subscription status.
- Fork 43
test: Add tests highlighting xdist incompatibilities #902
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
Changes from 1 commit
4c6d3e7
5af0e7b
3ad859d
ac509e5
0e727da
a7223f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import pytest | ||
|
|
||
| # Constants for testing with extra plugin arguments | ||
| _NO_ARGS = [] | ||
| _XDIST_ZERO = ["--numprocesses", "0"] | ||
| _XDIST_TWO = ["--numprocesses", "2"] | ||
|
|
||
|
|
||
| @pytest.fixture( | ||
| params=[_NO_ARGS, _XDIST_ZERO, _XDIST_TWO], | ||
| ids=["no_plugin", "xdist_zero", "xdist_two"], | ||
| ) | ||
| def plugin_args(request: pytest.FixtureRequest) -> list[str]: | ||
| """Fixture to test with various plugins""" | ||
| return request.param | ||
|
|
||
|
|
||
| @pytest.fixture( | ||
| params=[ | ||
| _NO_ARGS, | ||
| _XDIST_ZERO, | ||
| pytest.param( | ||
| _XDIST_TWO, | ||
| marks=pytest.mark.xfail(reason="Not currently compatible with xdist"), | ||
| ), | ||
| ], | ||
| ids=["no_plugin", "xdist_zero", "xdist_two"], | ||
| ) | ||
| def plugin_args_fails_xdist(request: pytest.FixtureRequest) -> list[str]: | ||
| """Fixture to test with various plugins, but expected to fail xdist""" | ||
| return request.param | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,41 +48,37 @@ def generate_snapshots(testdir, testcases_initial): | |
| return result, testdir, testcases_initial | ||
|
|
||
|
|
||
| @pytest.mark.xfail(strict=False) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The xfail here is because the test is flakey, haven't figured out why. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've put the flaky markers back in. |
||
| def test_generated_snapshots(generate_snapshots): | ||
| result = generate_snapshots[0] | ||
| result.stdout.re_match_lines((r"1 snapshot generated\.")) | ||
| assert "snapshots unused" not in result.stdout.str() | ||
| assert result.ret == 0 | ||
|
|
||
|
|
||
| @pytest.mark.xfail(strict=False) | ||
| def test_approximate_match(generate_snapshots): | ||
| def test_approximate_match(generate_snapshots, plugin_args_fails_xdist): | ||
| testdir = generate_snapshots[1] | ||
| testdir.makepyfile( | ||
| test_file=""" | ||
| def test_passed_custom(snapshot_custom): | ||
| assert snapshot_custom == 3.2 | ||
| """ | ||
| ) | ||
| result = testdir.runpytest("-v") | ||
| result = testdir.runpytest("-v", *plugin_args_fails_xdist) | ||
| result.stdout.re_match_lines((r"test_file.py::test_passed_custom PASSED")) | ||
| assert result.ret == 0 | ||
|
|
||
|
|
||
| @pytest.mark.xfail(strict=False) | ||
| def test_failed_snapshots(generate_snapshots): | ||
| def test_failed_snapshots(generate_snapshots, plugin_args_fails_xdist): | ||
| testdir = generate_snapshots[1] | ||
| testdir.makepyfile(test_file=generate_snapshots[2]["failed"]) | ||
| result = testdir.runpytest("-v") | ||
| result = testdir.runpytest("-v", *plugin_args_fails_xdist) | ||
| result.stdout.re_match_lines((r"1 snapshot failed\.")) | ||
| assert result.ret == 1 | ||
|
|
||
|
|
||
| @pytest.mark.xfail(strict=False) | ||
| def test_updated_snapshots(generate_snapshots): | ||
| def test_updated_snapshots(generate_snapshots, plugin_args_fails_xdist): | ||
| _, testdir, initial = generate_snapshots | ||
| testdir.makepyfile(test_file=initial["failed"]) | ||
| result = testdir.runpytest("-v", "--snapshot-update") | ||
| result = testdir.runpytest("-v", "--snapshot-update", *plugin_args_fails_xdist) | ||
| result.stdout.re_match_lines((r"1 snapshot updated\.")) | ||
| assert result.ret == 0 | ||
Uh oh!
There was an error while loading. Please reload this page.