From a894300c5085be925f5021bae2058492625a786b Mon Sep 17 00:00:00 2001 From: Le Philousophe Date: Sun, 12 Jan 2025 18:00:33 +0100 Subject: [PATCH] Partially revert "monkeypatches: Remove unused for_tests argument" Since commit d6b698ee4e7fb423e4181b7664b69ebb4d7fa5ca, the monkey patches were applied on every installs. This implies that set_is_in_unit_tests(True) was called even when not it in unit tests. Because it believes being in tests, db.logs._async_iter_on_pool is importing NonThreadPool from a submodule in the test module. This runs the test __init__ code which sets up warnings as error by default. As a consequence, any Deprecation warning will trigger an exception instead of just being shown in logs. This is causing troubles in current v4.2.0 with out of tree modules (which use deprecated code, granted). This partially reverts commit d6b698ee4e7fb423e4181b7664b69ebb4d7fa5ca. In addition, some patches are always run and some only during tests. Modified-by: Povilas Kanapickas --- master/buildbot/monkeypatches/__init__.py | 7 ++++--- master/buildbot/test/__init__.py | 2 +- newsfragments/fix-deprecation-warnings.bugfix | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 newsfragments/fix-deprecation-warnings.bugfix diff --git a/master/buildbot/monkeypatches/__init__.py b/master/buildbot/monkeypatches/__init__.py index 4e00386548db..548df5ade73d 100644 --- a/master/buildbot/monkeypatches/__init__.py +++ b/master/buildbot/monkeypatches/__init__.py @@ -72,8 +72,9 @@ def patch_config_for_unit_tests(): set_is_in_unit_tests(True) -def patch_all(): +def patch_all(for_tests=False): + if for_tests: + patch_testcase_timeout() + patch_config_for_unit_tests() patch_servicechecks() - patch_testcase_timeout() patch_decorators() - patch_config_for_unit_tests() diff --git a/master/buildbot/test/__init__.py b/master/buildbot/test/__init__.py index 5fa1696b5b15..c9dfe4f975c6 100644 --- a/master/buildbot/test/__init__.py +++ b/master/buildbot/test/__init__.py @@ -26,7 +26,7 @@ _ = mock # apply the same patches the buildmaster does when it starts -monkeypatches.patch_all() +monkeypatches.patch_all(for_tests=True) # enable deprecation warnings warnings.filterwarnings('always', category=DeprecationWarning) diff --git a/newsfragments/fix-deprecation-warnings.bugfix b/newsfragments/fix-deprecation-warnings.bugfix new file mode 100644 index 000000000000..b90ad75c39e8 --- /dev/null +++ b/newsfragments/fix-deprecation-warnings.bugfix @@ -0,0 +1 @@ +Fixed deprecation warnings being raised as errors