Skip to content

Commit 58a14b6

Browse files
authored
Merge pull request #4986 from blueyed/fnmatch_lines-list
tests: fnmatch_lines: use list
2 parents b53bf44 + 08f3b02 commit 58a14b6

16 files changed

+58
-56
lines changed

testing/acceptance_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ def test_pytest_plugins_as_module(testdir):
10331033
}
10341034
)
10351035
result = testdir.runpytest()
1036-
result.stdout.fnmatch_lines("* 1 passed in *")
1036+
result.stdout.fnmatch_lines(["* 1 passed in *"])
10371037

10381038

10391039
def test_deferred_hook_checking(testdir):
@@ -1173,7 +1173,7 @@ def test_fixture_mock_integration(testdir):
11731173
"""Test that decorators applied to fixture are left working (#3774)"""
11741174
p = testdir.copy_example("acceptance/fixture_mock_integration.py")
11751175
result = testdir.runpytest(p)
1176-
result.stdout.fnmatch_lines("*1 passed*")
1176+
result.stdout.fnmatch_lines(["*1 passed*"])
11771177

11781178

11791179
def test_usage_error_code(testdir):

testing/deprecated_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def test_pytest_plugins_in_non_top_level_conftest_unsupported_pyargs(
147147
if use_pyargs:
148148
assert msg not in res.stdout.str()
149149
else:
150-
res.stdout.fnmatch_lines("*{msg}*".format(msg=msg))
150+
res.stdout.fnmatch_lines(["*{msg}*".format(msg=msg)])
151151

152152

153153
def test_pytest_plugins_in_non_top_level_conftest_unsupported_no_top_level_conftest(

testing/logging/test_reporting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ def test_log_file():
747747
"""
748748
)
749749
result = testdir.runpytest("-s")
750-
result.stdout.fnmatch_lines("* 1 passed in *")
750+
result.stdout.fnmatch_lines(["* 1 passed in *"])
751751

752752

753753
def test_log_file_ini(testdir):

testing/python/collect.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ def test_skip_if(x):
558558
"""
559559
)
560560
result = testdir.runpytest()
561-
result.stdout.fnmatch_lines("* 2 passed, 1 skipped in *")
561+
result.stdout.fnmatch_lines(["* 2 passed, 1 skipped in *"])
562562

563563
def test_parametrize_skip(self, testdir):
564564
testdir.makepyfile(
@@ -573,7 +573,7 @@ def test_skip(x):
573573
"""
574574
)
575575
result = testdir.runpytest()
576-
result.stdout.fnmatch_lines("* 2 passed, 1 skipped in *")
576+
result.stdout.fnmatch_lines(["* 2 passed, 1 skipped in *"])
577577

578578
def test_parametrize_skipif_no_skip(self, testdir):
579579
testdir.makepyfile(
@@ -588,7 +588,7 @@ def test_skipif_no_skip(x):
588588
"""
589589
)
590590
result = testdir.runpytest()
591-
result.stdout.fnmatch_lines("* 1 failed, 2 passed in *")
591+
result.stdout.fnmatch_lines(["* 1 failed, 2 passed in *"])
592592

593593
def test_parametrize_xfail(self, testdir):
594594
testdir.makepyfile(
@@ -603,7 +603,7 @@ def test_xfail(x):
603603
"""
604604
)
605605
result = testdir.runpytest()
606-
result.stdout.fnmatch_lines("* 2 passed, 1 xfailed in *")
606+
result.stdout.fnmatch_lines(["* 2 passed, 1 xfailed in *"])
607607

608608
def test_parametrize_passed(self, testdir):
609609
testdir.makepyfile(
@@ -618,7 +618,7 @@ def test_xfail(x):
618618
"""
619619
)
620620
result = testdir.runpytest()
621-
result.stdout.fnmatch_lines("* 2 passed, 1 xpassed in *")
621+
result.stdout.fnmatch_lines(["* 2 passed, 1 xpassed in *"])
622622

623623
def test_parametrize_xfail_passed(self, testdir):
624624
testdir.makepyfile(
@@ -633,7 +633,7 @@ def test_passed(x):
633633
"""
634634
)
635635
result = testdir.runpytest()
636-
result.stdout.fnmatch_lines("* 3 passed in *")
636+
result.stdout.fnmatch_lines(["* 3 passed in *"])
637637

638638
def test_function_original_name(self, testdir):
639639
items = testdir.getitems(
@@ -831,7 +831,7 @@ def test_something():
831831
)
832832
# Use runpytest_subprocess, since we're futzing with sys.meta_path.
833833
result = testdir.runpytest_subprocess()
834-
result.stdout.fnmatch_lines("*1 passed*")
834+
result.stdout.fnmatch_lines(["*1 passed*"])
835835

836836

837837
def test_setup_only_available_in_subdir(testdir):
@@ -1296,14 +1296,14 @@ def test_real():
12961296
def test_package_collection_infinite_recursion(testdir):
12971297
testdir.copy_example("collect/package_infinite_recursion")
12981298
result = testdir.runpytest()
1299-
result.stdout.fnmatch_lines("*1 passed*")
1299+
result.stdout.fnmatch_lines(["*1 passed*"])
13001300

13011301

13021302
def test_package_collection_init_given_as_argument(testdir):
13031303
"""Regression test for #3749"""
13041304
p = testdir.copy_example("collect/package_init_given_as_arg")
13051305
result = testdir.runpytest(p / "pkg" / "__init__.py")
1306-
result.stdout.fnmatch_lines("*1 passed*")
1306+
result.stdout.fnmatch_lines(["*1 passed*"])
13071307

13081308

13091309
def test_package_with_modules(testdir):

testing/python/fixtures.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ def test_func():
536536
"""
537537
)
538538
result = testdir.runpytest_subprocess()
539-
result.stdout.fnmatch_lines("* 1 passed in *")
539+
result.stdout.fnmatch_lines(["* 1 passed in *"])
540540

541541
def test_getfixturevalue_recursive(self, testdir):
542542
testdir.makeconftest(
@@ -598,7 +598,7 @@ def test_func(resource):
598598
"""
599599
)
600600
result = testdir.runpytest()
601-
result.stdout.fnmatch_lines("* 2 passed in *")
601+
result.stdout.fnmatch_lines(["* 2 passed in *"])
602602

603603
@pytest.mark.parametrize("getfixmethod", ("getfixturevalue", "getfuncargvalue"))
604604
def test_getfixturevalue(self, testdir, getfixmethod):
@@ -787,7 +787,7 @@ def test_request_fixturenames_dynamic_fixture(self, testdir):
787787
"""Regression test for #3057"""
788788
testdir.copy_example("fixtures/test_getfixturevalue_dynamic.py")
789789
result = testdir.runpytest()
790-
result.stdout.fnmatch_lines("*1 passed*")
790+
result.stdout.fnmatch_lines(["*1 passed*"])
791791

792792
def test_funcargnames_compatattr(self, testdir):
793793
testdir.makepyfile(
@@ -1527,7 +1527,7 @@ def test_package(one):
15271527
def test_collect_custom_items(self, testdir):
15281528
testdir.copy_example("fixtures/custom_item")
15291529
result = testdir.runpytest("foo")
1530-
result.stdout.fnmatch_lines("*passed*")
1530+
result.stdout.fnmatch_lines(["*passed*"])
15311531

15321532

15331533
class TestAutouseDiscovery(object):
@@ -2609,7 +2609,7 @@ def test_browser(browser):
26092609
)
26102610
reprec = testdir.runpytest("-s")
26112611
for test in ["test_browser"]:
2612-
reprec.stdout.fnmatch_lines("*Finalized*")
2612+
reprec.stdout.fnmatch_lines(["*Finalized*"])
26132613

26142614
def test_class_scope_with_normal_tests(self, testdir):
26152615
testpath = testdir.makepyfile(
@@ -3450,7 +3450,7 @@ def test_1(meow):
34503450
"""
34513451
)
34523452
result = testdir.runpytest("-s")
3453-
result.stdout.fnmatch_lines("*mew*")
3453+
result.stdout.fnmatch_lines(["*mew*"])
34543454

34553455

34563456
class TestParameterizedSubRequest(object):

testing/test_assertrewrite.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ def test_rewrite_warning(self, testdir):
796796
)
797797
# needs to be a subprocess because pytester explicitly disables this warning
798798
result = testdir.runpytest_subprocess()
799-
result.stdout.fnmatch_lines("*Module already imported*: _pytest")
799+
result.stdout.fnmatch_lines(["*Module already imported*: _pytest"])
800800

801801
def test_rewrite_module_imported_from_conftest(self, testdir):
802802
testdir.makeconftest(
@@ -1123,7 +1123,7 @@ def test_foo(self):
11231123
)
11241124
path.join("data.txt").write("Hey")
11251125
result = testdir.runpytest()
1126-
result.stdout.fnmatch_lines("*1 passed*")
1126+
result.stdout.fnmatch_lines(["*1 passed*"])
11271127

11281128

11291129
def test_issue731(testdir):
@@ -1154,7 +1154,7 @@ def test_ternary_display():
11541154
"""
11551155
)
11561156
result = testdir.runpytest()
1157-
result.stdout.fnmatch_lines("*E*assert (False == False) == False")
1157+
result.stdout.fnmatch_lines(["*E*assert (False == False) == False"])
11581158

11591159
def test_long_case(self, testdir):
11601160
testdir.makepyfile(
@@ -1164,7 +1164,7 @@ def test_ternary_display():
11641164
"""
11651165
)
11661166
result = testdir.runpytest()
1167-
result.stdout.fnmatch_lines("*E*assert (False == True) == True")
1167+
result.stdout.fnmatch_lines(["*E*assert (False == True) == True"])
11681168

11691169
def test_many_brackets(self, testdir):
11701170
testdir.makepyfile(
@@ -1174,7 +1174,7 @@ def test_ternary_display():
11741174
"""
11751175
)
11761176
result = testdir.runpytest()
1177-
result.stdout.fnmatch_lines("*E*assert True == ((False == True) == True)")
1177+
result.stdout.fnmatch_lines(["*E*assert True == ((False == True) == True)"])
11781178

11791179

11801180
class TestIssue2121:
@@ -1194,7 +1194,7 @@ def test_simple_failure():
11941194
"""
11951195
)
11961196
result = testdir.runpytest()
1197-
result.stdout.fnmatch_lines("*E*assert (1 + 1) == 3")
1197+
result.stdout.fnmatch_lines(["*E*assert (1 + 1) == 3"])
11981198

11991199

12001200
@pytest.mark.parametrize("offset", [-1, +1])
@@ -1356,4 +1356,4 @@ def test():
13561356
}
13571357
)
13581358
result = testdir.runpytest()
1359-
result.stdout.fnmatch_lines("* 1 passed in *")
1359+
result.stdout.fnmatch_lines(["* 1 passed in *"])

testing/test_cacheprovider.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def test_fail(val):
393393
"""
394394
)
395395
result = testdir.runpytest()
396-
result.stdout.fnmatch_lines("*1 failed in*")
396+
result.stdout.fnmatch_lines(["*1 failed in*"])
397397

398398
def test_terminal_report_lastfailed(self, testdir):
399399
test_a = testdir.makepyfile(
@@ -574,7 +574,7 @@ def test():
574574
"""
575575
)
576576
result = testdir.runpytest()
577-
result.stdout.fnmatch_lines("*1 xfailed*")
577+
result.stdout.fnmatch_lines(["*1 xfailed*"])
578578
assert self.get_cached_last_failed(testdir) == []
579579

580580
def test_xfail_strict_considered_failure(self, testdir):
@@ -587,7 +587,7 @@ def test():
587587
"""
588588
)
589589
result = testdir.runpytest()
590-
result.stdout.fnmatch_lines("*1 failed*")
590+
result.stdout.fnmatch_lines(["*1 failed*"])
591591
assert self.get_cached_last_failed(testdir) == [
592592
"test_xfail_strict_considered_failure.py::test"
593593
]
@@ -680,12 +680,12 @@ def test_bar_2():
680680
"""
681681
)
682682
result = testdir.runpytest(test_bar)
683-
result.stdout.fnmatch_lines("*2 passed*")
683+
result.stdout.fnmatch_lines(["*2 passed*"])
684684
# ensure cache does not forget that test_foo_4 failed once before
685685
assert self.get_cached_last_failed(testdir) == ["test_foo.py::test_foo_4"]
686686

687687
result = testdir.runpytest("--last-failed")
688-
result.stdout.fnmatch_lines("*1 failed, 3 deselected*")
688+
result.stdout.fnmatch_lines(["*1 failed, 3 deselected*"])
689689
assert self.get_cached_last_failed(testdir) == ["test_foo.py::test_foo_4"]
690690

691691
# 3. fix test_foo_4, run only test_foo.py
@@ -698,11 +698,11 @@ def test_foo_4():
698698
"""
699699
)
700700
result = testdir.runpytest(test_foo, "--last-failed")
701-
result.stdout.fnmatch_lines("*1 passed, 1 deselected*")
701+
result.stdout.fnmatch_lines(["*1 passed, 1 deselected*"])
702702
assert self.get_cached_last_failed(testdir) == []
703703

704704
result = testdir.runpytest("--last-failed")
705-
result.stdout.fnmatch_lines("*4 passed*")
705+
result.stdout.fnmatch_lines(["*4 passed*"])
706706
assert self.get_cached_last_failed(testdir) == []
707707

708708
def test_lastfailed_no_failures_behavior_all_passed(self, testdir):

testing/test_capture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ def test_captured_print(captured_print):
673673
)
674674
)
675675
result = testdir.runpytest_subprocess()
676-
result.stdout.fnmatch_lines("*1 passed*")
676+
result.stdout.fnmatch_lines(["*1 passed*"])
677677
assert "stdout contents begin" not in result.stdout.str()
678678
assert "stderr contents begin" not in result.stdout.str()
679679

testing/test_collection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,10 @@ def pytest_ignore_collect(path, config):
350350
p = testdir.makepyfile("def test_hello(): pass")
351351
result = testdir.runpytest(p)
352352
assert result.ret == 0
353-
result.stdout.fnmatch_lines("*1 passed*")
353+
result.stdout.fnmatch_lines(["*1 passed*"])
354354
result = testdir.runpytest()
355355
assert result.ret == EXIT_NOTESTSCOLLECTED
356-
result.stdout.fnmatch_lines("*collected 0 items*")
356+
result.stdout.fnmatch_lines(["*collected 0 items*"])
357357

358358
def test_collectignore_exclude_on_option(self, testdir):
359359
testdir.makeconftest(
@@ -390,10 +390,10 @@ def pytest_configure(config):
390390
testdir.makepyfile(test_welt="def test_hallo(): pass")
391391
result = testdir.runpytest()
392392
assert result.ret == EXIT_NOTESTSCOLLECTED
393-
result.stdout.fnmatch_lines("*collected 0 items*")
393+
result.stdout.fnmatch_lines(["*collected 0 items*"])
394394
result = testdir.runpytest("--XX")
395395
assert result.ret == 0
396-
result.stdout.fnmatch_lines("*2 passed*")
396+
result.stdout.fnmatch_lines(["*2 passed*"])
397397

398398
def test_pytest_fs_collect_hooks_are_seen(self, testdir):
399399
testdir.makeconftest(

testing/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ def test_collect_pytest_prefix_bug_integration(testdir):
805805
"""Integration test for issue #3775"""
806806
p = testdir.copy_example("config/collect_pytest_prefix")
807807
result = testdir.runpytest(p)
808-
result.stdout.fnmatch_lines("* 1 passed *")
808+
result.stdout.fnmatch_lines(["* 1 passed *"])
809809

810810

811811
def test_collect_pytest_prefix_bug(pytestconfig):

0 commit comments

Comments
 (0)