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
This commit is contained in:
@@ -772,19 +772,23 @@ class TestWarnings:
|
||||
|
||||
testdir.makeconftest(
|
||||
"""
|
||||
def pytest_warning_captured():
|
||||
assert False, "this hook should not be called in this version"
|
||||
def pytest_warning_captured(warning_message):
|
||||
if warning_message == "my custom worker warning":
|
||||
assert False, (
|
||||
"this hook should not be called from workers "
|
||||
"in this version: {}"
|
||||
).format(warning_message)
|
||||
"""
|
||||
)
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
import warnings
|
||||
def test():
|
||||
warnings.warn("custom warning")
|
||||
warnings.warn("my custom worker warning")
|
||||
"""
|
||||
)
|
||||
result = testdir.runpytest("-n1")
|
||||
result.stdout.fnmatch_lines(["* 1 passed in *"])
|
||||
result.stdout.fnmatch_lines(["*1 passed*"])
|
||||
result.stdout.no_fnmatch_line("*this hook should not be called in this version")
|
||||
|
||||
@pytest.mark.parametrize("n", ["-n0", "-n1"])
|
||||
|
||||
Reference in New Issue
Block a user