Skip to content

Commit

Permalink
Use twisted.python.deprecate.deprecatedModuleAttribute to deprecate S…
Browse files Browse the repository at this point in the history
…etProperty.
  • Loading branch information
tomprince committed Jun 6, 2013
1 parent eb8526c commit 5fd5273
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
16 changes: 8 additions & 8 deletions master/buildbot/steps/shell.py
Expand Up @@ -18,6 +18,8 @@
import inspect
from twisted.python import log, failure
from twisted.spread import pb
from twisted.python.deprecate import deprecatedModuleAttribute
from twisted.python.versions import Version
from buildbot.process import buildstep
from buildbot.status.results import SUCCESS, WARNINGS, FAILURE
from buildbot.status.logfile import STDOUT, STDERR
Expand Down Expand Up @@ -364,14 +366,12 @@ def getText(self, cmd, results):
# let ShellCommand describe
return ShellCommand.getText(self, cmd, results)

class SetProperty(SetPropertyFromCommand):
"alias for SetPropertyFromCommand"
def __init__(self, *args, **kwargs):
log.msg("WARNING: the name 'SetProperty' has been renamed to SetPropertyFromCommand; use " +
"buildbot.steps.slave.SetPropertyFromCommand instead " +
"(note that this may require you to change your import " +
"statement)")
SetPropertyFromCommand.__init__(self, *args, **kwargs)

SetProperty = SetPropertyFromCommand
deprecatedModuleAttribute(Version("Buildbot", 0, 8, 8),
"It has been renamed to SetPropertyFromCommand",
"buildbot.steps.shell", "SetProperty")


class Configure(ShellCommand):

Expand Down
19 changes: 19 additions & 0 deletions master/buildbot/test/unit/test_steps_shell.py
Expand Up @@ -480,6 +480,25 @@ def extract_fn(rc, stdout, stderr):
self.assertEqual(len(self.flushLoggedErrors(RuntimeError)), 1))
return d

class SetPropertyDeprecation(unittest.TestCase):
"""
Tests for L{shell.SetProperty}
"""

def test_deprecated(self):
"""
Accessing L{shell.SetProperty} reports a deprecation error.
"""
shell.SetProperty
warnings = self.flushWarnings([self.test_deprecated])
self.assertEqual(len(warnings), 1)
self.assertIdentical(warnings[0]['category'], DeprecationWarning)
self.assertEqual(warnings[0]['message'],
"buildbot.steps.shell.SetProperty was deprecated in Buildbot 0.8.8: "
"It has been renamed to SetPropertyFromCommand"
)


class Configure(unittest.TestCase):

def test_class_attrs(self):
Expand Down

0 comments on commit 5fd5273

Please sign in to comment.