-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: pytestomatio plugin usage with xdist, add tests, sync tests
- Loading branch information
Showing
11 changed files
with
94 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import pytest | ||
|
||
@pytest.mark.testomatio("@Tfaf4da53") | ||
@pytest.mark.smoke | ||
def test_sync_stop_when_xdist_in_use(pytester): | ||
pytester.makepyfile(""" | ||
def test_example(): | ||
assert True | ||
""") | ||
|
||
# Ensure that your plugin code raises UsageError for this scenario instead of a generic Exception. | ||
# Something like: | ||
# if option == 'sync' and parallel_set: | ||
# raise UsageError("The 'sync' mode does not support parallel execution! In order to synchronise test run command sync as '--testomatio sync -n 0'") | ||
|
||
result = pytester.runpytest_inprocess('-p', 'xdist', '--testomatio', 'sync', '-vv') | ||
|
||
# Match the entire error line as it appears in stderr | ||
result.stderr.fnmatch_lines([ | ||
"ERROR: The 'sync' mode does not support parallel execution! In order to synchronise test run command sync as '--testomatio sync -n 0'" | ||
]) | ||
|
||
# Now that it's a usage error, pytest should produce a summary line that we can assert on | ||
assert result.ret != 0 | ||
|
||
@pytest.mark.smoke | ||
def test_sync_works_with_xdist_set_to_0(pytester): | ||
pytester.makepyfile(""" | ||
def test_example(): | ||
assert True | ||
""") | ||
|
||
result = pytester.runpytest_inprocess('-p', 'xdist', '--testomatio', 'sync', '-n', '0', '-vv') | ||
|
||
# Assert that the special exit message is printed to stderr | ||
result.stdout.fnmatch_lines([ | ||
"*Sync completed without test execution*" | ||
]) | ||
|
||
# Assert that no tests were run | ||
result.stdout.fnmatch_lines([ | ||
"*no tests ran in *" | ||
]) | ||
|
||
# Optional: Verify the process exited successfully (0 means no error) | ||
assert result.ret == 2 |