Skip to content

Commit b3a1bf3

Browse files
committed
Fix test_warning_captured_deprecated_in_pytest_6
The test was failing because *other* warnings were being triggered on the master node. This makes the test more reliable by checking only that the warning from the worker node is not emitted. Fix #601
1 parent 3fb369c commit b3a1bf3

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

testing/acceptance_test.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -772,19 +772,23 @@ def test_warning_captured_deprecated_in_pytest_6(self, testdir):
772772

773773
testdir.makeconftest(
774774
"""
775-
def pytest_warning_captured():
776-
assert False, "this hook should not be called in this version"
775+
def pytest_warning_captured(warning_message):
776+
if warning_message == "my custom worker warning":
777+
assert False, (
778+
"this hook should not be called from workers "
779+
"in this version: {}"
780+
).format(warning_message)
777781
"""
778782
)
779783
testdir.makepyfile(
780784
"""
781785
import warnings
782786
def test():
783-
warnings.warn("custom warning")
787+
warnings.warn("my custom worker warning")
784788
"""
785789
)
786790
result = testdir.runpytest("-n1")
787-
result.stdout.fnmatch_lines(["* 1 passed in *"])
791+
result.stdout.fnmatch_lines(["*1 passed*"])
788792
result.stdout.no_fnmatch_line("*this hook should not be called in this version")
789793

790794
@pytest.mark.parametrize("n", ["-n0", "-n1"])

0 commit comments

Comments
 (0)