From b3a1bf3c2e8c46c7f07d3be34f66f704397c2076 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 12 Dec 2020 11:58:41 -0300 Subject: [PATCH] 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 --- testing/acceptance_test.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 48ed35f9..b71d1d94 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -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"])