Skip to content

Commit

Permalink
Merge pull request buildbot#7609 from mokibit/convert-BuildStepWrappe…
Browse files Browse the repository at this point in the history
…rMixin-warning-to-error

Switch deprecation warning to error in BuildStepWrapperMixin
  • Loading branch information
p12tic authored May 14, 2024
2 parents 97fb9c3 + d9b4e1e commit 5ff602e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
6 changes: 2 additions & 4 deletions master/buildbot/process/buildstep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
25 changes: 14 additions & 11 deletions master/buildbot/test/unit/process/test_buildstep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 5ff602e

Please sign in to comment.