From d2d23cb9e484c7005f1aa226c6213d5cfa60d43e Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 12 Nov 2024 08:03:45 +0100 Subject: [PATCH] chore: fix UP034 extraneous-parentheses in tests --- tests/integration/test_custom_comparator.py | 8 ++++---- tests/integration/test_pytest_extension.py | 4 ++-- .../test_single_file_multiple_extensions.py | 8 ++++---- .../integration/test_snapshot_option_extension.py | 2 +- .../test_snapshot_option_extension_pythonpath.py | 2 +- .../test_snapshot_option_include_details.py | 2 +- tests/integration/test_snapshot_option_name.py | 2 +- tests/integration/test_snapshot_option_update.py | 14 +++++++------- .../test_snapshot_option_warn_unused.py | 2 +- .../integration/test_snapshot_outside_directory.py | 4 ++-- .../test_snapshot_similar_names_default.py | 2 +- .../test_snapshot_similar_names_file_extension.py | 2 +- tests/integration/test_snapshot_use_extension.py | 10 ++++++---- tests/integration/test_xfail.py | 10 +++++----- 14 files changed, 37 insertions(+), 35 deletions(-) diff --git a/tests/integration/test_custom_comparator.py b/tests/integration/test_custom_comparator.py index d88ebf9e..d4c2ff20 100644 --- a/tests/integration/test_custom_comparator.py +++ b/tests/integration/test_custom_comparator.py @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/tests/integration/test_pytest_extension.py b/tests/integration/test_pytest_extension.py index d8186fa7..febb03fe 100644 --- a/tests/integration/test_pytest_extension.py +++ b/tests/integration/test_pytest_extension.py @@ -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 @@ -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 diff --git a/tests/integration/test_single_file_multiple_extensions.py b/tests/integration/test_single_file_multiple_extensions.py index 8c4fb0dc..0bf9c87e 100644 --- a/tests/integration/test_single_file_multiple_extensions.py +++ b/tests/integration/test_single_file_multiple_extensions.py @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/tests/integration/test_snapshot_option_extension.py b/tests/integration/test_snapshot_option_extension.py index 884f92a6..d93eca79 100644 --- a/tests/integration/test_snapshot_option_extension.py +++ b/tests/integration/test_snapshot_option_extension.py @@ -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() diff --git a/tests/integration/test_snapshot_option_extension_pythonpath.py b/tests/integration/test_snapshot_option_extension_pythonpath.py index 35701540..739dcf61 100644 --- a/tests/integration/test_snapshot_option_extension_pythonpath.py +++ b/tests/integration/test_snapshot_option_extension_pythonpath.py @@ -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() diff --git a/tests/integration/test_snapshot_option_include_details.py b/tests/integration/test_snapshot_option_include_details.py index e2224c64..a3647d2f 100644 --- a/tests/integration/test_snapshot_option_include_details.py +++ b/tests/integration/test_snapshot_option_include_details.py @@ -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 diff --git a/tests/integration/test_snapshot_option_name.py b/tests/integration/test_snapshot_option_name.py index fd58df57..05c55c83 100644 --- a/tests/integration/test_snapshot_option_name.py +++ b/tests/integration/test_snapshot_option_name.py @@ -28,7 +28,7 @@ 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 diff --git a/tests/integration/test_snapshot_option_update.py b/tests/integration/test_snapshot_option_update.py index c4991f93..f2a23f3f 100644 --- a/tests/integration/test_snapshot_option_update.py +++ b/tests/integration/test_snapshot_option_update.py @@ -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 @@ -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 @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() diff --git a/tests/integration/test_snapshot_option_warn_unused.py b/tests/integration/test_snapshot_option_warn_unused.py index 99442583..056c2a91 100644 --- a/tests/integration/test_snapshot_option_warn_unused.py +++ b/tests/integration/test_snapshot_option_warn_unused.py @@ -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 diff --git a/tests/integration/test_snapshot_outside_directory.py b/tests/integration/test_snapshot_outside_directory.py index 87defe71..a8b8175c 100644 --- a/tests/integration/test_snapshot_outside_directory.py +++ b/tests/integration/test_snapshot_outside_directory.py @@ -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 @@ -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 diff --git a/tests/integration/test_snapshot_similar_names_default.py b/tests/integration/test_snapshot_similar_names_default.py index ea832a74..ab5cea3e 100644 --- a/tests/integration/test_snapshot_similar_names_default.py +++ b/tests/integration/test_snapshot_similar_names_default.py @@ -32,7 +32,7 @@ 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 diff --git a/tests/integration/test_snapshot_similar_names_file_extension.py b/tests/integration/test_snapshot_similar_names_file_extension.py index 520baad7..26cea969 100644 --- a/tests/integration/test_snapshot_similar_names_file_extension.py +++ b/tests/integration/test_snapshot_similar_names_file_extension.py @@ -37,7 +37,7 @@ def run_testcases(testdir, testcases): "--snapshot-default-extension", "syrupy.extensions.single_file.SingleFileSnapshotExtension", ) - result.stdout.re_match_lines((r"9 snapshots generated\.")) + result.stdout.re_match_lines((r"9 snapshots generated\.",)) return testdir, testcases diff --git a/tests/integration/test_snapshot_use_extension.py b/tests/integration/test_snapshot_use_extension.py index cfe0df26..5d456145 100644 --- a/tests/integration/test_snapshot_use_extension.py +++ b/tests/integration/test_snapshot_use_extension.py @@ -107,13 +107,13 @@ def test_unsaved_snapshots(testdir, testcases_initial): def test_failed_snapshots(testdir, testcases_initial, plugin_args_fails_xdist): testdir.makepyfile(test_file=testcases_initial["failed"]) result = testdir.runpytest("-v", "--snapshot-update", *plugin_args_fails_xdist) - result.stdout.re_match_lines((r"2 snapshots failed\.")) + result.stdout.re_match_lines((r"2 snapshots failed\.",)) assert result.ret == 1 def test_generated_snapshots(generate_snapshots): result = generate_snapshots[0] - result.stdout.re_match_lines((r"4 snapshots generated\.")) + result.stdout.re_match_lines((r"4 snapshots generated\.",)) assert "snapshots unused" not in result.stdout.str() assert result.ret == 0 @@ -124,7 +124,7 @@ def test_unmatched_snapshots( testdir = generate_snapshots[1] testdir.makepyfile(test_file=testcases_updated["passed"]) result = testdir.runpytest("-v", *plugin_args_fails_xdist) - result.stdout.re_match_lines((r"1 snapshot failed\. 2 snapshots unused\.")) + result.stdout.re_match_lines((r"1 snapshot failed\. 2 snapshots unused\.",)) assert result.ret == 1 @@ -134,7 +134,9 @@ def test_updated_snapshots( testdir = generate_snapshots[1] testdir.makepyfile(test_file=testcases_updated["passed"]) result = testdir.runpytest("-v", "--snapshot-update", *plugin_args_fails_xdist) - result.stdout.re_match_lines((r"1 snapshot updated\. 2 unused snapshots deleted\.")) + result.stdout.re_match_lines( + (r"1 snapshot updated\. 2 unused snapshots deleted\.",) + ) assert result.ret == 0 diff --git a/tests/integration/test_xfail.py b/tests/integration/test_xfail.py index 4dee1ea1..68299dcb 100644 --- a/tests/integration/test_xfail.py +++ b/tests/integration/test_xfail.py @@ -11,7 +11,7 @@ def test_a(snapshot): ) ) result = testdir.runpytest("-v", *plugin_args) - result.stdout.no_re_match_line((r".*snapshot failed*")) + result.stdout.no_re_match_line((r".*snapshot failed*",)) assert result.ret == 0 @@ -33,8 +33,8 @@ def test_b(snapshot): ) ) result = testdir.runpytest("-v", *plugin_args_fails_xdist) - result.stdout.re_match_lines((r".*1 snapshot failed*")) - result.stdout.re_match_lines((r".*1 snapshot xfailed*")) + result.stdout.re_match_lines((r".*1 snapshot failed*",)) + result.stdout.re_match_lines((r".*1 snapshot xfailed*",)) assert result.ret == 1 @@ -51,6 +51,6 @@ def test_a(snapshot): ) ) result = testdir.runpytest("-v", *plugin_args_fails_xdist) - result.stdout.re_match_lines((r".*1 snapshot failed*")) - result.stdout.no_re_match_line((r".*1 snapshot xfailed*")) + result.stdout.re_match_lines((r".*1 snapshot failed*",)) + result.stdout.no_re_match_line((r".*1 snapshot xfailed*",)) assert result.ret == 1