Skip to content

Commit

Permalink
Fix test_warning_captured_deprecated_in_pytest_6
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nicoddemus committed Dec 12, 2020
1 parent 3fb369c commit b3a1bf3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions testing/acceptance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,19 +772,23 @@ def test_warning_captured_deprecated_in_pytest_6(self, testdir):

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"])
Expand Down

0 comments on commit b3a1bf3

Please sign in to comment.