From 5fd5273241de3e1e3a93cfe259d6cc882bf796a4 Mon Sep 17 00:00:00 2001 From: Tom Prince Date: Thu, 6 Jun 2013 10:59:11 -0600 Subject: [PATCH] Use twisted.python.deprecate.deprecatedModuleAttribute to deprecate SetProperty. --- master/buildbot/steps/shell.py | 16 ++++++++-------- master/buildbot/test/unit/test_steps_shell.py | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/master/buildbot/steps/shell.py b/master/buildbot/steps/shell.py index b54c19b624d..b469579511a 100644 --- a/master/buildbot/steps/shell.py +++ b/master/buildbot/steps/shell.py @@ -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 @@ -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): diff --git a/master/buildbot/test/unit/test_steps_shell.py b/master/buildbot/test/unit/test_steps_shell.py index 64c9582be7d..9f914600838 100644 --- a/master/buildbot/test/unit/test_steps_shell.py +++ b/master/buildbot/test/unit/test_steps_shell.py @@ -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):