Skip to content

Commit aaf0912

Browse files
committed
adjust tests
1 parent 1047038 commit aaf0912

12 files changed

+97
-115
lines changed

tests/integration/test_pytest_extension.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_example(snapshot):
4646
assert result.ret == 0
4747

4848

49-
def test_does_not_print_empty_snapshot_report(testdir, plugin_args_fails_xdist):
49+
def test_does_not_print_empty_snapshot_report(testdir, plugin_args):
5050
testdir.makeconftest("")
5151
testcase_no_snapshots = """
5252
def test_example(snapshot):
@@ -61,15 +61,15 @@ def test_example(snapshot):
6161
)
6262

6363
result = testdir.runpytest(
64-
"-v", "test_file_no.py", "--snapshot-update", *plugin_args_fails_xdist
64+
"-v", "test_file_no.py", "--snapshot-update", *plugin_args
6565
)
6666
result.stdout.re_match_lines((r".*test_file_no.py.*"))
6767
assert "snapshot report" not in result.stdout.str()
6868
assert "test_file_yes" not in result.stdout.str()
6969
assert result.ret == 0
7070

7171
result = testdir.runpytest(
72-
"-v", "test_file_yes.py", "--snapshot-update", *plugin_args_fails_xdist
72+
"-v", "test_file_yes.py", "--snapshot-update", *plugin_args
7373
)
7474
result.stdout.re_match_lines((r".*test_file_yes.py.*", r".*snapshot report.*"))
7575
assert result.ret == 0

tests/integration/test_single_file_multiple_extensions.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from pathlib import Path
22

33

4-
def test_multiple_file_extensions(testdir, plugin_args_fails_xdist):
4+
def test_multiple_file_extensions(testdir, plugin_args):
55
file_extension = "ext2.ext1"
66

77
testcase = f"""
@@ -21,7 +21,7 @@ def test_dot_in_filename(snapshot):
2121

2222
test_file: Path = testdir.makepyfile(test_file=testcase)
2323

24-
result = testdir.runpytest("-v", "--snapshot-update", *plugin_args_fails_xdist)
24+
result = testdir.runpytest("-v", "--snapshot-update", *plugin_args)
2525
result.stdout.re_match_lines((r"1 snapshot generated\."))
2626
assert "snapshots unused" not in result.stdout.str()
2727
assert result.ret == 0
@@ -34,13 +34,13 @@ def test_dot_in_filename(snapshot):
3434
)
3535
assert snapshot_file.exists()
3636

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

4242

43-
def test_class_style(testdir, plugin_args_fails_xdist):
43+
def test_class_style(testdir, plugin_args):
4444
"""
4545
Regression test for https://github.com/syrupy-project/syrupy/issues/717
4646
"""
@@ -60,7 +60,7 @@ def test_foo(self, snapshot):
6060

6161
test_file: Path = testdir.makepyfile(test_file=testcase)
6262

63-
result = testdir.runpytest("-v", "--snapshot-update", *plugin_args_fails_xdist)
63+
result = testdir.runpytest("-v", "--snapshot-update", *plugin_args)
6464
result.stdout.re_match_lines((r"1 snapshot generated\."))
6565
assert "deleted" not in result.stdout.str()
6666
assert result.ret == 0
@@ -70,7 +70,7 @@ def test_foo(self, snapshot):
7070
)
7171
assert snapshot_file.exists()
7272

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

tests/integration/test_snapshot_option_include_details.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ def test_unused_snapshots_details(
6868
expected_status_code,
6969
run_testfiles_with_update,
7070
testcases,
71-
plugin_args_fails_xdist,
71+
plugin_args,
7272
):
7373
testdir = run_testfiles_with_update(test_file=testcases)
7474
testdir.makepyfile(test_file=testcases["used"])
7575

76-
result = testdir.runpytest(*options, *plugin_args_fails_xdist)
76+
result = testdir.runpytest(*options, *plugin_args)
7777
result.stdout.re_match_lines(
7878
(
7979
r"1 snapshot passed\. 1 snapshot unused\.",
@@ -85,7 +85,7 @@ def test_unused_snapshots_details(
8585

8686

8787
def test_unused_snapshots_details_multiple_tests(
88-
run_testfiles_with_update, testcases, extra_testcases, plugin_args_fails_xdist
88+
run_testfiles_with_update, testcases, extra_testcases, plugin_args
8989
):
9090
testdir = run_testfiles_with_update(
9191
test_file=testcases, test_second_file=extra_testcases
@@ -95,7 +95,7 @@ def test_unused_snapshots_details_multiple_tests(
9595
test_second_file="",
9696
)
9797

98-
result = testdir.runpytest("-v", "--snapshot-details", *plugin_args_fails_xdist)
98+
result = testdir.runpytest("-v", "--snapshot-details", *plugin_args)
9999
result.stdout.re_match_lines(
100100
(
101101
r"2 snapshots passed\. 2 snapshots unused\.",
@@ -108,7 +108,7 @@ def test_unused_snapshots_details_multiple_tests(
108108

109109

110110
def test_unused_snapshots_details_multiple_locations(
111-
run_testfiles_with_update, testcases, extra_testcases, plugin_args_fails_xdist
111+
run_testfiles_with_update, testcases, extra_testcases, plugin_args
112112
):
113113
testdir = run_testfiles_with_update(
114114
test_file=testcases, test_second_file=extra_testcases
@@ -118,7 +118,7 @@ def test_unused_snapshots_details_multiple_locations(
118118
test_second_file=extra_testcases["extra_a"],
119119
)
120120

121-
result = testdir.runpytest("-v", "--snapshot-details", *plugin_args_fails_xdist)
121+
result = testdir.runpytest("-v", "--snapshot-details", *plugin_args)
122122
result.stdout.re_match_lines_random(
123123
(
124124
r"2 snapshots passed\. 2 snapshots unused\.",
@@ -131,13 +131,13 @@ def test_unused_snapshots_details_multiple_locations(
131131

132132

133133
def test_unused_snapshots_details_no_details_on_deletion(
134-
run_testfiles_with_update, testcases, plugin_args_fails_xdist
134+
run_testfiles_with_update, testcases, plugin_args
135135
):
136136
testdir = run_testfiles_with_update(test_file=testcases)
137137
testdir.makepyfile(test_file=testcases["used"])
138138

139139
result = testdir.runpytest(
140-
"-v", "--snapshot-details", "--snapshot-update", *plugin_args_fails_xdist
140+
"-v", "--snapshot-details", "--snapshot-update", *plugin_args
141141
)
142142
result.stdout.re_match_lines(
143143
(

tests/integration/test_snapshot_option_name.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,25 @@ def run_testcases(testdir, testcases):
3232
return testdir, testcases
3333

3434

35-
def test_run_all(run_testcases, plugin_args_fails_xdist):
35+
def test_run_all(run_testcases, plugin_args):
3636
testdir, testcases = run_testcases
37-
result = testdir.runpytest("-v", *plugin_args_fails_xdist)
37+
result = testdir.runpytest("-v", *plugin_args)
3838
result.stdout.re_match_lines("2 snapshots passed")
3939
assert result.ret == 0
4040

4141

42-
def test_failure(run_testcases, plugin_args_fails_xdist):
42+
def test_failure(run_testcases, plugin_args):
4343
testdir, testcases = run_testcases
4444
testdir.makepyfile(test_1=testcases["modified"])
45-
result = testdir.runpytest("-vv", *plugin_args_fails_xdist)
45+
result = testdir.runpytest("-vv", *plugin_args)
4646
result.stdout.re_match_lines("1 snapshot failed. 1 snapshot passed.")
4747
assert result.ret == 1
4848

4949

50-
def test_update(run_testcases, plugin_args_fails_xdist):
50+
def test_update(run_testcases, plugin_args):
5151
testdir, testcases = run_testcases
5252
testdir.makepyfile(test_1=testcases["modified"])
53-
result = testdir.runpytest("-v", "--snapshot-update", *plugin_args_fails_xdist)
53+
result = testdir.runpytest("-v", "--snapshot-update", *plugin_args)
5454
assert "Can not relate snapshot name" not in str(result.stdout)
5555
result.stdout.re_match_lines("1 snapshot passed. 1 snapshot updated.")
5656
assert result.ret == 0

tests/integration/test_snapshot_option_update.py

+22-36
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,17 @@ def test_update_failure_shows_snapshot_diff(
184184

185185

186186
def test_update_success_shows_snapshot_report(
187-
run_testcases, testcases_updated, plugin_args_fails_xdist
187+
run_testcases, testcases_updated, plugin_args
188188
):
189189
testdir = run_testcases[1]
190190
testdir.makepyfile(**testcases_updated)
191-
result = testdir.runpytest("-v", "--snapshot-update", *plugin_args_fails_xdist)
191+
result = testdir.runpytest("-v", "--snapshot-update", *plugin_args)
192192
result.stdout.re_match_lines((r"5 snapshots passed\. 5 snapshots updated\."))
193193
assert result.ret == 0
194194

195195

196196
def test_update_targets_only_selected_parametrized_tests_for_update_dash_m(
197-
run_testcases, plugin_args_fails_xdist
197+
run_testcases, plugin_args
198198
):
199199
updated_tests = {
200200
"test_used": (
@@ -210,7 +210,7 @@ def test_used(snapshot, actual):
210210
testdir = run_testcases[1]
211211
testdir.makepyfile(**updated_tests)
212212
result = testdir.runpytest(
213-
"-v", "--snapshot-update", *plugin_args_fails_xdist, "-m", "parametrize"
213+
"-v", "--snapshot-update", *plugin_args, "-m", "parametrize"
214214
)
215215
result.stdout.re_match_lines(
216216
(
@@ -224,7 +224,7 @@ def test_used(snapshot, actual):
224224

225225

226226
def test_update_targets_only_selected_parametrized_tests_for_update_dash_k(
227-
run_testcases, plugin_args_fails_xdist
227+
run_testcases, plugin_args
228228
):
229229
updated_tests = {
230230
"test_used": (
@@ -240,7 +240,7 @@ def test_used(snapshot, actual):
240240
testdir = run_testcases[1]
241241
testdir.makepyfile(**updated_tests)
242242
result = testdir.runpytest(
243-
"-v", "--snapshot-update", *plugin_args_fails_xdist, "-k", "test_used[2]"
243+
"-v", "--snapshot-update", *plugin_args, "-k", "test_used[2]"
244244
)
245245
result.stdout.re_match_lines((r"1 snapshot updated\."))
246246
assert "Deleted" not in result.stdout.str()
@@ -250,7 +250,7 @@ def test_used(snapshot, actual):
250250

251251

252252
def test_update_targets_only_selected_parametrized_tests_for_removal_dash_k(
253-
run_testcases, plugin_args_fails_xdist
253+
run_testcases, plugin_args
254254
):
255255
updated_tests = {
256256
"test_used": (
@@ -266,7 +266,7 @@ def test_used(snapshot, actual):
266266
testdir = run_testcases[1]
267267
testdir.makepyfile(**updated_tests)
268268
result = testdir.runpytest(
269-
"-v", "--snapshot-update", *plugin_args_fails_xdist, "-k", "test_used["
269+
"-v", "--snapshot-update", *plugin_args, "-k", "test_used["
270270
)
271271
result.stdout.re_match_lines(
272272
(
@@ -279,9 +279,7 @@ def test_used(snapshot, actual):
279279
assert Path(*snapshot_path, "test_updated_1.ambr").exists()
280280

281281

282-
def test_update_targets_only_selected_class_tests_dash_k(
283-
testdir, plugin_args_fails_xdist
284-
):
282+
def test_update_targets_only_selected_class_tests_dash_k(testdir, plugin_args):
285283
test_content = """
286284
import pytest
287285
@@ -298,15 +296,13 @@ def test_case_2(self, snapshot):
298296
assert Path(testdir.tmpdir, "__snapshots__", "test_content.ambr").exists()
299297

300298
result = testdir.runpytest(
301-
"test_content.py", "-v", *plugin_args_fails_xdist, "-k", "test_case_2"
299+
"test_content.py", "-v", *plugin_args, "-k", "test_case_2"
302300
)
303301
result.stdout.re_match_lines((r"1 snapshot passed\."))
304302
assert "snaphot unused" not in result.stdout.str()
305303

306304

307-
def test_update_targets_only_selected_module_tests_dash_k(
308-
testdir, plugin_args_fails_xdist
309-
):
305+
def test_update_targets_only_selected_module_tests_dash_k(testdir, plugin_args):
310306
test_content = """
311307
import pytest
312308
@@ -322,21 +318,19 @@ def test_case_2(snapshot):
322318
assert Path(testdir.tmpdir, "__snapshots__", "test_content.ambr").exists()
323319

324320
result = testdir.runpytest(
325-
"test_content.py", "-v", *plugin_args_fails_xdist, "-k", "test_case_2"
321+
"test_content.py", "-v", *plugin_args, "-k", "test_case_2"
326322
)
327323
result.stdout.re_match_lines((r"1 snapshot passed\."))
328324
assert "snaphot unused" not in result.stdout.str()
329325

330326

331-
def test_update_targets_only_selected_module_tests_nodes(
332-
run_testcases, plugin_args_fails_xdist
333-
):
327+
def test_update_targets_only_selected_module_tests_nodes(run_testcases, plugin_args):
334328
testdir = run_testcases[1]
335329
snapfile_empty = Path("__snapshots__", "empty_snapfile.ambr")
336330
testdir.makefile(".ambr", **{str(snapfile_empty): ""})
337331
testfile = Path(testdir.tmpdir, "test_used.py")
338332
result = testdir.runpytest(
339-
"-v", f"{testfile}::test_used", "--snapshot-update", *plugin_args_fails_xdist
333+
"-v", f"{testfile}::test_used", "--snapshot-update", *plugin_args
340334
)
341335
result.stdout.re_match_lines((r"3 snapshots passed\."))
342336
assert "unused" not in result.stdout.str()
@@ -368,7 +362,7 @@ def test_update_targets_only_selected_module_tests_nodes_pyargs(
368362

369363

370364
def test_update_targets_only_selected_module_tests_file_for_update(
371-
run_testcases, plugin_args_fails_xdist
365+
run_testcases, plugin_args
372366
):
373367
testdir = run_testcases[1]
374368
snapfile_empty = Path("__snapshots__", "empty_snapfile.ambr")
@@ -384,9 +378,7 @@ def test_used(snapshot, actual):
384378
"""
385379
)
386380
)
387-
result = testdir.runpytest(
388-
"-v", "test_used.py", "--snapshot-update", *plugin_args_fails_xdist
389-
)
381+
result = testdir.runpytest("-v", "test_used.py", "--snapshot-update", *plugin_args)
390382
result.stdout.re_match_lines(
391383
(
392384
r"3 snapshots passed\. 2 unused snapshots deleted\.",
@@ -399,7 +391,7 @@ def test_used(snapshot, actual):
399391

400392

401393
def test_update_targets_only_selected_module_tests_file_for_removal(
402-
run_testcases, plugin_args_fails_xdist
394+
run_testcases, plugin_args
403395
):
404396
testdir = run_testcases[1]
405397
testdir.makepyfile(
@@ -412,9 +404,7 @@ def test_used(snapshot):
412404
)
413405
snapfile_empty = Path("__snapshots__", "empty_snapfile.ambr")
414406
testdir.makefile(".ambr", **{str(snapfile_empty): ""})
415-
result = testdir.runpytest(
416-
"-v", "test_used.py", "--snapshot-update", *plugin_args_fails_xdist
417-
)
407+
result = testdir.runpytest("-v", "test_used.py", "--snapshot-update", *plugin_args)
418408
result.stdout.re_match_lines(
419409
(
420410
r"5 unused snapshots deleted\.",
@@ -427,14 +417,12 @@ def test_used(snapshot):
427417
assert not Path("__snapshots__", "test_used.ambr").exists()
428418

429419

430-
def test_update_removes_empty_snapshot_collection_only(
431-
run_testcases, plugin_args_fails_xdist
432-
):
420+
def test_update_removes_empty_snapshot_collection_only(run_testcases, plugin_args):
433421
testdir = run_testcases[1]
434422
snapfile_empty = Path("__snapshots__", "empty_snapfile.ambr")
435423
testdir.makefile(".ambr", **{str(snapfile_empty): ""})
436424
assert snapfile_empty.exists()
437-
result = testdir.runpytest("-v", "--snapshot-update", *plugin_args_fails_xdist)
425+
result = testdir.runpytest("-v", "--snapshot-update", *plugin_args)
438426
result.stdout.re_match_lines(
439427
(
440428
r"10 snapshots passed\. 1 unused snapshot deleted\.",
@@ -447,15 +435,13 @@ def test_update_removes_empty_snapshot_collection_only(
447435
assert Path("__snapshots__", "test_used.ambr").exists()
448436

449437

450-
def test_update_removes_hanging_snapshot_collection_file(
451-
run_testcases, plugin_args_fails_xdist
452-
):
438+
def test_update_removes_hanging_snapshot_collection_file(run_testcases, plugin_args):
453439
testdir = run_testcases[1]
454440
snapfile_used = Path("__snapshots__", "test_used.ambr")
455441
snapfile_hanging = Path("__snapshots__", "hanging_snapfile.abc")
456442
testdir.makefile(".abc", **{str(snapfile_hanging): ""})
457443
assert snapfile_hanging.exists()
458-
result = testdir.runpytest("-v", "--snapshot-update", *plugin_args_fails_xdist)
444+
result = testdir.runpytest("-v", "--snapshot-update", *plugin_args)
459445
result.stdout.re_match_lines(
460446
(
461447
r"10 snapshots passed\. 1 unused snapshot deleted\.",

0 commit comments

Comments
 (0)