generated from tophat/new-project-kit
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve reporting around xfailed snapshots, close #736
- Loading branch information
Noah Negin-Ulster
committed
Jul 11, 2023
1 parent
6a93c87
commit 5196d89
Showing
5 changed files
with
109 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
def test_no_failure_printed_if_all_failures_xfailed(testdir): | ||
testdir.makepyfile( | ||
test_file=( | ||
""" | ||
import pytest | ||
@pytest.mark.xfail(reason="Failure expected.") | ||
def test_a(snapshot): | ||
assert snapshot == 'does-not-exist' | ||
""" | ||
) | ||
) | ||
result = testdir.runpytest("-v") | ||
result.stdout.no_re_match_line((r".*snapshot failed*")) | ||
assert result.ret == 0 | ||
|
||
|
||
def test_failures_printed_if_only_some_failures_xfailed(testdir): | ||
testdir.makepyfile( | ||
test_file=( | ||
""" | ||
import pytest | ||
@pytest.mark.xfail(reason="Failure expected.") | ||
def test_a(snapshot): | ||
assert snapshot == 'does-not-exist' | ||
def test_b(snapshot): | ||
assert snapshot == 'other' | ||
""" | ||
) | ||
) | ||
result = testdir.runpytest("-v") | ||
result.stdout.re_match_lines((r".*1 snapshot failed*")) | ||
result.stdout.re_match_lines((r".*1 snapshot xfailed*")) | ||
assert result.ret == 1 | ||
|
||
|
||
def test_failure_printed_if_xfail_does_not_run(testdir): | ||
testdir.makepyfile( | ||
test_file=( | ||
""" | ||
import pytest | ||
@pytest.mark.xfail(False, reason="Failure expected.") | ||
def test_a(snapshot): | ||
assert snapshot == 'does-not-exist' | ||
""" | ||
) | ||
) | ||
result = testdir.runpytest("-v") | ||
result.stdout.re_match_lines((r".*1 snapshot failed*")) | ||
result.stdout.no_re_match_line((r".*1 snapshot xfailed*")) | ||
assert result.ret == 1 |
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