From d9b4e1eb250eb9a070e9fd295d20cbb84a66ec0c Mon Sep 17 00:00:00 2001 From: Monika Kairaityte <monika@kibit.lt> Date: Tue, 14 May 2024 12:23:36 +0300 Subject: [PATCH] process: Switch deprecation warning to error in BuildStepWrapperMixin --- master/buildbot/process/buildstep.py | 6 ++--- .../test/unit/process/test_buildstep.py | 25 +++++++++++-------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/master/buildbot/process/buildstep.py b/master/buildbot/process/buildstep.py index b5cf0305f76..1b6b40cc708 100644 --- a/master/buildbot/process/buildstep.py +++ b/master/buildbot/process/buildstep.py @@ -65,7 +65,6 @@ from buildbot.util import deferwaiter from buildbot.util import flatten from buildbot.util.test_result_submitter import TestResultSubmitter -from buildbot.warnings import warn_deprecated if TYPE_CHECKING: from buildbot.process.build import Build @@ -192,10 +191,9 @@ def __init__(self, *args, **kwargs): def __setattr__(self, name, value): if self.__init_completed: - warn_deprecated( - "3.10.0", + config.error( "Changes to attributes of a BuildStep instance are ignored, this is a bug. " - "Use set_step_arg(name, value) for that.", + "Use set_step_arg(name, value) for that." ) super().__setattr__(name, value) diff --git a/master/buildbot/test/unit/process/test_buildstep.py b/master/buildbot/test/unit/process/test_buildstep.py index 0331ec11caa..68f57a01b34 100644 --- a/master/buildbot/test/unit/process/test_buildstep.py +++ b/master/buildbot/test/unit/process/test_buildstep.py @@ -24,6 +24,7 @@ from twisted.trial import unittest from buildbot import locks +from buildbot.config import ConfigErrors from buildbot.interfaces import WorkerSetupError from buildbot.plugins import util from buildbot.process import buildstep @@ -52,9 +53,7 @@ from buildbot.test.steps import TestBuildStepMixin from buildbot.test.util import config from buildbot.test.util import interfaces -from buildbot.test.util.warnings import assertProducesWarning from buildbot.util.eventual import eventually -from buildbot.warnings import DeprecatedApiWarning class NewStyleStep(buildstep.BuildStep): @@ -200,18 +199,22 @@ def run(self): @defer.inlineCallbacks def test_arg_changes(self): - recorded_arg = [] - - step = self.RecordingBuildStep(record_target=recorded_arg, arg="orig") - self.setup_step(step) + try: + recorded_arg = [] - with assertProducesWarning(DeprecatedApiWarning): - step.arg = "changed" + step = self.RecordingBuildStep(record_target=recorded_arg, arg="orig") + self.setup_step(step) - self.expect_outcome(result=SUCCESS) - yield self.run_step() + self.expect_outcome(result=SUCCESS) + yield self.run_step() - self.assertEqual(recorded_arg, ["orig"]) + self.assertEqual(recorded_arg, ["orig"]) + except ConfigErrors as e: + self.assertEqual( + "Changes to attributes of a BuildStep instance are ignored, this is a bug. " + "Use set_step_arg(name, value) for that.", + e.errors[0], + ) @defer.inlineCallbacks def test_arg_changes_set_step_arg(self):