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(
|
testdir.makeconftest(
|
||||||
"""
|
"""
|
||||||
def pytest_warning_captured():
|
def pytest_warning_captured(warning_message):
|
||||||
assert False, "this hook should not be called in this version"
|
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(
|
testdir.makepyfile(
|
||||||
"""
|
"""
|
||||||
import warnings
|
import warnings
|
||||||
def test():
|
def test():
|
||||||
warnings.warn("custom warning")
|
warnings.warn("my custom worker warning")
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
result = testdir.runpytest("-n1")
|
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")
|
result.stdout.no_fnmatch_line("*this hook should not be called in this version")
|
||||||
|
|
||||||
@pytest.mark.parametrize("n", ["-n0", "-n1"])
|
@pytest.mark.parametrize("n", ["-n0", "-n1"])
|
||||||
|
|||||||
Reference in New Issue
Block a user