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: ignore unused snapshots for skipped test (#862)
- Loading branch information
1 parent
2105b52
commit 3f6e301
Showing
4 changed files
with
132 additions
and
11 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,74 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def testcases(): | ||
return { | ||
"used": ( | ||
""" | ||
def test_used(snapshot): | ||
assert snapshot == 'used' | ||
""" | ||
), | ||
"raise-skipped": ( | ||
""" | ||
import pytest | ||
def test_skipped(snapshot): | ||
pytest.skip("Skipping...") | ||
assert snapshot == 'unused' | ||
""" | ||
), | ||
"mark-skipped": ( | ||
""" | ||
import pytest | ||
@pytest.mark.skip | ||
def test_skipped(snapshot): | ||
assert snapshot == 'unused' | ||
""" | ||
), | ||
"not-skipped": ( | ||
""" | ||
def test_skipped(snapshot): | ||
assert snapshot == 'unused' | ||
""" | ||
), | ||
} | ||
|
||
|
||
@pytest.fixture | ||
def run_testcases(testdir, testcases): | ||
pyfile_content = "\n\n".join([testcases["used"], testcases["not-skipped"]]) | ||
testdir.makepyfile(test_file=pyfile_content) | ||
result = testdir.runpytest("-v", "--snapshot-update") | ||
result.stdout.re_match_lines(r"2 snapshots generated\.") | ||
return testdir, testcases | ||
|
||
|
||
def test_mark_skipped_snapshots(run_testcases): | ||
testdir, testcases = run_testcases | ||
pyfile_content = "\n\n".join([testcases["used"], testcases["mark-skipped"]]) | ||
testdir.makepyfile(test_file=pyfile_content) | ||
|
||
result = testdir.runpytest("-v") | ||
result.stdout.re_match_lines(r"1 snapshot passed\.$") | ||
assert result.ret == 0 | ||
|
||
|
||
def test_raise_skipped_snapshots(run_testcases): | ||
testdir, testcases = run_testcases | ||
pyfile_content = "\n\n".join([testcases["used"], testcases["raise-skipped"]]) | ||
testdir.makepyfile(test_file=pyfile_content) | ||
|
||
result = testdir.runpytest("-v") | ||
result.stdout.re_match_lines(r"1 snapshot passed\.$") | ||
assert result.ret == 0 | ||
|
||
|
||
def test_skipped_snapshots_update(run_testcases): | ||
testdir, testcases = run_testcases | ||
pyfile_content = "\n\n".join([testcases["used"], testcases["raise-skipped"]]) | ||
testdir.makepyfile(test_file=pyfile_content) | ||
|
||
result = testdir.runpytest("-v", "--snapshot-update") | ||
result.stdout.re_match_lines(r"1 snapshot passed\.$") | ||
assert result.ret == 0 |