Skip to content
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

chore: use tuple in stdout.re_match_lines #919

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tests/integration/test_custom_comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def generate_snapshots(testdir, testcases_initial):
@pytest.mark.xfail(strict=False)
def test_generated_snapshots(generate_snapshots):
result = generate_snapshots[0]
result.stdout.re_match_lines((r"1 snapshot generated\."))
result.stdout.re_match_lines((r"1 snapshot generated\.",))
assert "snapshots unused" not in result.stdout.str()
assert result.ret == 0

Expand All @@ -66,7 +66,7 @@ def test_passed_custom(snapshot_custom):
"""
)
result = testdir.runpytest("-v", *plugin_args_fails_xdist)
result.stdout.re_match_lines((r"test_file.py::test_passed_custom PASSED"))
result.stdout.re_match_lines((r"test_file.py::test_passed_custom PASSED",))
assert result.ret == 0


Expand All @@ -75,7 +75,7 @@ def test_failed_snapshots(generate_snapshots):
testdir = generate_snapshots[1]
testdir.makepyfile(test_file=generate_snapshots[2]["failed"])
result = testdir.runpytest("-v")
result.stdout.re_match_lines((r"1 snapshot failed\."))
result.stdout.re_match_lines((r"1 snapshot failed\.",))
assert result.ret == 1


Expand All @@ -84,5 +84,5 @@ 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", *plugin_args_fails_xdist)
result.stdout.re_match_lines((r"1 snapshot updated\."))
result.stdout.re_match_lines((r"1 snapshot updated\.",))
assert result.ret == 0
20 changes: 10 additions & 10 deletions tests/integration/test_pycharm_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ def test_case(snapshot):
result.assert_outcomes(failed=1, passed=0, warnings=0)

result.stdout.re_match_lines(
[
(
r"Expected: 'list([\n 1,\n 2,\n])'",
# Actual is the amber-style list representation
r"Actual: 'list([\n 1,\n 2,\n 3,\n])'",
]
)
)


Expand Down Expand Up @@ -120,11 +120,11 @@ def test_case(snapshot):
result.assert_outcomes(failed=1, passed=0, warnings=0)

result.stdout.re_match_lines(
[
(
r"Expected: 'list([\n 1,\n 2,\n])'",
# Actual is the amber-style list representation
r"Actual: 'list([\n 1,\n 2,\n 3,\n])'",
]
)
)


Expand Down Expand Up @@ -163,11 +163,11 @@ def test_case(snapshot):
result.assert_outcomes(failed=1, passed=0, warnings=0)

result.stdout.re_match_lines(
[
(
r"Expected: 'list([\n 1,\n 2,\n])'",
# Actual is the original list's repr. No newlines or amber-style list prefix
r"Actual: '[1, 2, 3]'",
]
)
)


Expand Down Expand Up @@ -197,10 +197,10 @@ def test_case():
result.assert_outcomes(failed=1, passed=0, warnings=0)

result.stdout.re_match_lines(
[
(
r"Expected: '[1, 3]'",
r"Actual: '[1, 2, 3]'",
]
)
)


Expand Down Expand Up @@ -234,8 +234,8 @@ def test_case():
result.assert_outcomes(failed=1, passed=0, warnings=0)

result.stdout.re_match_lines(
[
(
r"Expected: '[1, 3]'",
r"Actual: '[1, 2, 3]'",
]
)
)
4 changes: 2 additions & 2 deletions tests/integration/test_pytest_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_example(snapshot):
testdir.makeconftest(conftest)
testdir.makepyfile(test_file=testcase)
result = testdir.runpytest("test_file.py", "-v", "--snapshot-update", *plugin_args)
result.stdout.re_match_lines((r".*test_file.py::CUSTOM.*"))
result.stdout.re_match_lines((r".*test_file.py::CUSTOM.*",))
assert result.ret == 0


Expand Down Expand Up @@ -63,7 +63,7 @@ def test_example(snapshot):
result = testdir.runpytest(
"-v", "test_file_no.py", "--snapshot-update", *plugin_args_fails_xdist
)
result.stdout.re_match_lines((r".*test_file_no.py.*"))
result.stdout.re_match_lines((r".*test_file_no.py.*",))
assert "snapshot report" not in result.stdout.str()
assert "test_file_yes" not in result.stdout.str()
assert result.ret == 0
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/test_single_file_multiple_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_dot_in_filename(snapshot):
test_file: Path = testdir.makepyfile(test_file=testcase)

result = testdir.runpytest("-v", "--snapshot-update", *plugin_args_fails_xdist)
result.stdout.re_match_lines((r"1 snapshot generated\."))
result.stdout.re_match_lines((r"1 snapshot generated\.",))
assert "snapshots unused" not in result.stdout.str()
assert result.ret == 0

Expand All @@ -35,7 +35,7 @@ def test_dot_in_filename(snapshot):
assert snapshot_file.exists()

result = testdir.runpytest("-v", *plugin_args_fails_xdist)
result.stdout.re_match_lines((r"1 snapshot passed\."))
result.stdout.re_match_lines((r"1 snapshot passed\.",))
assert "snapshots unused" not in result.stdout.str()
assert result.ret == 0

Expand All @@ -61,7 +61,7 @@ def test_foo(self, snapshot):
test_file: Path = testdir.makepyfile(test_file=testcase)

result = testdir.runpytest("-v", "--snapshot-update", *plugin_args_fails_xdist)
result.stdout.re_match_lines((r"1 snapshot generated\."))
result.stdout.re_match_lines((r"1 snapshot generated\.",))
assert "deleted" not in result.stdout.str()
assert result.ret == 0

Expand All @@ -71,6 +71,6 @@ def test_foo(self, snapshot):
assert snapshot_file.exists()

result = testdir.runpytest("-v", *plugin_args_fails_xdist)
result.stdout.re_match_lines((r"1 snapshot passed\."))
result.stdout.re_match_lines((r"1 snapshot passed\.",))
assert "snapshots unused" not in result.stdout.str()
assert result.ret == 0
2 changes: 1 addition & 1 deletion tests/integration/test_snapshot_option_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_snapshot_default_extension_option_success(testfile):
"--snapshot-default-extension",
"syrupy.extensions.single_file.SingleFileSnapshotExtension",
)
result.stdout.re_match_lines((r"1 snapshot generated\."))
result.stdout.re_match_lines((r"1 snapshot generated\.",))
assert Path(
testfile.tmpdir, "__snapshots__", "test_file", "test_default.raw"
).exists()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_snapshot_default_extension_option_success(testfile):
"--snapshot-default-extension",
"extension_file.MySingleFileExtension",
)
result.stdout.re_match_lines((r"1 snapshot generated\."))
result.stdout.re_match_lines((r"1 snapshot generated\.",))
assert Path(
testfile.path, "__snapshots__", "test_file", "test_default.raw"
).exists()
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_snapshot_option_include_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def run_testfiles_with_update_impl(**testfiles):
}
)
result = testdir.runpytest("-v", "--snapshot-update")
result.stdout.re_match_lines((r"[0-9]+ snapshots generated\."))
result.stdout.re_match_lines((r"[0-9]+ snapshots generated\.",))
return testdir

return run_testfiles_with_update_impl
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/test_snapshot_option_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ def run_testcases(testdir, testcases):
"-v",
"--snapshot-update",
)
result.stdout.re_match_lines((r"2 snapshots generated\."))
result.stdout.re_match_lines((r"2 snapshots generated\.",))
return testdir, testcases


def test_run_all(run_testcases, plugin_args_fails_xdist):
testdir, testcases = run_testcases
result = testdir.runpytest("-v", *plugin_args_fails_xdist)
result.stdout.re_match_lines("2 snapshots passed")
result.stdout.re_match_lines(("2 snapshots passed",))
assert result.ret == 0


def test_failure(run_testcases, plugin_args_fails_xdist):
testdir, testcases = run_testcases
testdir.makepyfile(test_1=testcases["modified"])
result = testdir.runpytest("-vv", *plugin_args_fails_xdist)
result.stdout.re_match_lines("1 snapshot failed. 1 snapshot passed.")
result.stdout.re_match_lines(("1 snapshot failed. 1 snapshot passed.",))
assert result.ret == 1


Expand All @@ -52,5 +52,5 @@ def test_update(run_testcases, plugin_args_fails_xdist):
testdir.makepyfile(test_1=testcases["modified"])
result = testdir.runpytest("-v", "--snapshot-update", *plugin_args_fails_xdist)
assert "Can not relate snapshot name" not in str(result.stdout)
result.stdout.re_match_lines("1 snapshot passed. 1 snapshot updated.")
result.stdout.re_match_lines(("1 snapshot passed. 1 snapshot updated.",))
assert result.ret == 0
14 changes: 7 additions & 7 deletions tests/integration/test_snapshot_option_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def run_testcases(testdir, testcases_initial):
sys.path.append(str(testdir.tmpdir))
testdir.makepyfile(**testcases_initial)
result = testdir.runpytest("-v", "--snapshot-update")
result.stdout.re_match_lines((r"10 snapshots generated."))
result.stdout.re_match_lines((r"10 snapshots generated.",))
assert "Can not relate snapshot name" not in result.stdout.str()

return result, testdir, testcases_initial
Expand Down Expand Up @@ -189,7 +189,7 @@ def test_update_success_shows_snapshot_report(
testdir = run_testcases[1]
testdir.makepyfile(**testcases_updated)
result = testdir.runpytest("-v", "--snapshot-update", *plugin_args_fails_xdist)
result.stdout.re_match_lines((r"5 snapshots passed\. 5 snapshots updated\."))
result.stdout.re_match_lines((r"5 snapshots passed\. 5 snapshots updated\.",))
assert result.ret == 0


Expand Down Expand Up @@ -242,7 +242,7 @@ def test_used(snapshot, actual):
result = testdir.runpytest(
"-v", "--snapshot-update", *plugin_args_fails_xdist, "-k", "test_used[2]"
)
result.stdout.re_match_lines((r"1 snapshot updated\."))
result.stdout.re_match_lines((r"1 snapshot updated\.",))
assert "Deleted" not in result.stdout.str()
snapshot_path = [testdir.tmpdir, "__snapshots__"]
assert Path(*snapshot_path, "test_used.ambr").exists()
Expand Down Expand Up @@ -300,7 +300,7 @@ def test_case_2(self, snapshot):
result = testdir.runpytest(
"test_content.py", "-v", *plugin_args_fails_xdist, "-k", "test_case_2"
)
result.stdout.re_match_lines((r"1 snapshot passed\."))
result.stdout.re_match_lines((r"1 snapshot passed\.",))
assert "snaphot unused" not in result.stdout.str()


Expand All @@ -324,7 +324,7 @@ def test_case_2(snapshot):
result = testdir.runpytest(
"test_content.py", "-v", *plugin_args_fails_xdist, "-k", "test_case_2"
)
result.stdout.re_match_lines((r"1 snapshot passed\."))
result.stdout.re_match_lines((r"1 snapshot passed\.",))
assert "snaphot unused" not in result.stdout.str()


Expand All @@ -338,7 +338,7 @@ def test_update_targets_only_selected_module_tests_nodes(
result = testdir.runpytest(
"-v", f"{testfile}::test_used", "--snapshot-update", *plugin_args_fails_xdist
)
result.stdout.re_match_lines((r"3 snapshots passed\."))
result.stdout.re_match_lines((r"3 snapshots passed\.",))
assert "unused" not in result.stdout.str()
assert "updated" not in result.stdout.str()
assert "deleted" not in result.stdout.str()
Expand All @@ -359,7 +359,7 @@ def test_update_targets_only_selected_module_tests_nodes_pyargs(
"--pyargs",
"test_used::test_used",
)
result.stdout.re_match_lines((r"3 snapshots passed\."))
result.stdout.re_match_lines((r"3 snapshots passed\.",))
assert "unused" not in result.stdout.str()
assert "updated" not in result.stdout.str()
assert "deleted" not in result.stdout.str()
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_snapshot_option_warn_unused.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def run_testcases(testdir, testcases):
pyfile_content = "\n\n".join(testcases.values())
testdir.makepyfile(test_file=pyfile_content)
result = testdir.runpytest("-v", "--snapshot-update")
result.stdout.re_match_lines((r"2 snapshots generated\."))
result.stdout.re_match_lines((r"2 snapshots generated\.",))
return testdir, testcases


Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_snapshot_outside_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def generate_snapshots(testdir, testcases):

def test_generated_snapshots(generate_snapshots):
result = generate_snapshots[0]
result.stdout.re_match_lines((r"2 snapshots generated\."))
result.stdout.re_match_lines((r"2 snapshots generated\.",))
assert "snapshots unused" not in result.stdout.str()
assert result.ret == 0

Expand All @@ -61,7 +61,7 @@ def test_unmatched_snapshots(generate_snapshots, plugin_args_fails_xdist):
_, testdir, testcases = generate_snapshots
testdir.makepyfile(test_file=testcases["one"])
result = testdir.runpytest("-v", *plugin_args_fails_xdist)
result.stdout.re_match_lines((r"1 snapshot passed. 1 snapshot unused\."))
result.stdout.re_match_lines((r"1 snapshot passed. 1 snapshot unused\.",))
assert result.ret == 1


Expand Down
14 changes: 7 additions & 7 deletions tests/integration/test_snapshot_similar_names_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ def run_testcases(testdir, testcases):
test_1=pyfile_content, test_2=pyfile_content, test_1_with_suffix=pyfile_content
)
result = testdir.runpytest("-v", "--snapshot-update")
result.stdout.re_match_lines((r"9 snapshots generated\."))
result.stdout.re_match_lines((r"9 snapshots generated\.",))
return testdir, testcases


def test_run_all(run_testcases, plugin_args_fails_xdist):
testdir, testcases = run_testcases
result = testdir.runpytest("-v", *plugin_args_fails_xdist)
result.stdout.re_match_lines("9 snapshots passed")
result.stdout.re_match_lines(("9 snapshots passed",))
assert result.ret == 0


def test_run_single_file(run_testcases, plugin_args_fails_xdist):
testdir, testcases = run_testcases
result = testdir.runpytest("-v", "test_1.py", *plugin_args_fails_xdist)
result.stdout.re_match_lines("3 snapshots passed")
result.stdout.re_match_lines(("3 snapshots passed",))
assert result.ret == 0


def test_run_single_test_case_in_file(run_testcases, plugin_args_fails_xdist):
testdir, testcases = run_testcases
result = testdir.runpytest("-v", "test_2.py::test_a", *plugin_args_fails_xdist)
result.stdout.re_match_lines("1 snapshot passed")
result.stdout.re_match_lines(("1 snapshot passed",))
assert result.ret == 0


Expand All @@ -66,7 +66,7 @@ def test_run_all_but_one(run_testcases, plugin_args_fails_xdist):
"test_2.py::test_a",
*plugin_args_fails_xdist,
)
result.stdout.re_match_lines("4 snapshots passed")
result.stdout.re_match_lines(("4 snapshots passed",))
assert result.ret == 0


Expand All @@ -79,7 +79,7 @@ def test_run_both_files_by_node(run_testcases, plugin_args_fails_xdist):
"test_2.py::test_a",
*plugin_args_fails_xdist,
)
result.stdout.re_match_lines("2 snapshots passed")
result.stdout.re_match_lines(("2 snapshots passed",))
assert result.ret == 0


Expand All @@ -92,5 +92,5 @@ def test_run_both_files_by_node_2(run_testcases, plugin_args_fails_xdist):
"test_2.py::test_a",
*plugin_args_fails_xdist,
)
result.stdout.re_match_lines("2 snapshots passed")
result.stdout.re_match_lines(("2 snapshots passed",))
assert result.ret == 0
Loading
Loading