Skip to content

Commit

Permalink
Don't spam test output with deprecation warnings
Browse files Browse the repository at this point in the history
This additionally tests some of those deprecation warnings, and enables
deprecation warnings universally during tests
  • Loading branch information
djmitche committed Sep 26, 2013
1 parent dbc6934 commit f24552b
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 25 deletions.
12 changes: 12 additions & 0 deletions master/buildbot/steps/source/__init__.py
Expand Up @@ -13,9 +13,21 @@
#
# Copyright Buildbot Team Members

from twisted.python.deprecate import deprecatedModuleAttribute
from twisted.python.versions import Version
from buildbot.steps.source.base import Source
from buildbot.steps.source.oldsource import CVS, \
SVN, Git, Darcs, Repo, Bzr, Mercurial, P4, Monotone, BK

warningString = "The slave-side %s step is deprecated and will be removed in a future version. Please switch to the corresponding master-side step."

oldClasses = [ "CVS", "SVN", "Git", "Darcs", "Repo", "Bzr", "Mercurial", "P4",
"Monotone", "BK" ]

for oldClass in oldClasses:
deprecatedModuleAttribute(Version("Buildbot", 0, 8, 9),
warningString %(oldClass),
"buildbot.steps.source", oldClass)

_hush_pyflakes = [ Source, CVS, SVN, \
Git, Darcs, Repo, Bzr, Mercurial, P4, Monotone, BK ]
21 changes: 0 additions & 21 deletions master/buildbot/steps/source/oldsource.py
Expand Up @@ -18,32 +18,11 @@
from email.Utils import formatdate
from twisted.python import log
from twisted.internet import defer
from twisted.python.deprecate import deprecatedModuleAttribute
from twisted.python.versions import Version
from zope.interface import implements
from buildbot.process.buildstep import RemoteCommand
from buildbot.interfaces import BuildSlaveTooOldError, IRenderable
from buildbot.steps.source.base import Source

warningString = "The slave-side %s step is deprecated and will be removed in a future version. Please switch to the corresponding master-side step."


attributes = {
"Git": "Git",
"Mercurial": "Mercurial",
"CVS": "CVS",
"Subversion": "SVN",
"Darcs": "Darcs",
"Repo": "Repo",
"Bzr": "Bzr",
"Perforce": "P4",
"Monotone": "Monotone"}

for attr in attributes:
deprecatedModuleAttribute(Version("Buildbot", 0, 8, 9),
warningString %(attr),
"buildbot.steps.source", attributes[attr])

class _ComputeRepositoryURL(object):
implements(IRenderable)

Expand Down
4 changes: 4 additions & 0 deletions master/buildbot/test/__init__.py
Expand Up @@ -17,6 +17,10 @@
from buildbot import monkeypatches
monkeypatches.patch_all(for_tests=True)

# enable deprecation warnings
import warnings
warnings.filterwarnings('always', category=DeprecationWarning)

# import mock so we bail out early if it's not installed
try:
import mock
Expand Down
5 changes: 3 additions & 2 deletions master/buildbot/test/integration/test_configs.py
Expand Up @@ -65,7 +65,7 @@ def test_0_7_6_config(self):
cvsroot = ":pserver:anonymous@cvs.sourceforge.net:/cvsroot/buildbot"
cvsmodule = "buildbot"
from buildbot.process import factory
from buildbot.steps.source import CVS
from buildbot.steps.source.cvs import CVS
from buildbot.steps.shell import Compile
from buildbot.steps.python_twisted import Trial
f1 = factory.BuildFactory()
Expand Down Expand Up @@ -102,7 +102,8 @@ def test_0_7_6_config(self):
cvsroot = ":pserver:anonymous@cvs.sourceforge.net:/cvsroot/buildbot"
cvsmodule = "buildbot"
from buildbot.process import factory
from buildbot.steps.source import CVS
# old source is deprecated, so we use the new source
from buildbot.steps.source.cvs import CVS
from buildbot.steps.shell import Compile
from buildbot.steps.python_twisted import Trial
f1 = factory.BuildFactory()
Expand Down
19 changes: 18 additions & 1 deletion master/buildbot/test/regressions/test_oldpaths.py
Expand Up @@ -13,9 +13,16 @@
#
# Copyright Buildbot Team Members


from twisted.trial import unittest

def deprecatedImport(fn):
def wrapper(self):
fn(self)
warnings = self.flushWarnings()
self.assertEqual(len(warnings), 1)
self.assertEqual(warnings[0]['category'], DeprecationWarning)
return wrapper

class OldImportPaths(unittest.TestCase):
"""
Test that old, deprecated import paths still work.
Expand Down Expand Up @@ -149,42 +156,52 @@ def test_steps_source_Source(self):
from buildbot.steps.source import Source
assert Source

@deprecatedImport
def test_steps_source_CVS(self):
from buildbot.steps.source import CVS
assert CVS

@deprecatedImport
def test_steps_source_SVN(self):
from buildbot.steps.source import SVN
assert SVN

@deprecatedImport
def test_steps_source_Git(self):
from buildbot.steps.source import Git
assert Git

@deprecatedImport
def test_steps_source_Darcs(self):
from buildbot.steps.source import Darcs
assert Darcs

@deprecatedImport
def test_steps_source_Repo(self):
from buildbot.steps.source import Repo
assert Repo

@deprecatedImport
def test_steps_source_Bzr(self):
from buildbot.steps.source import Bzr
assert Bzr

@deprecatedImport
def test_steps_source_Mercurial(self):
from buildbot.steps.source import Mercurial
assert Mercurial

@deprecatedImport
def test_steps_source_P4(self):
from buildbot.steps.source import P4
assert P4

@deprecatedImport
def test_steps_source_Monotone(self):
from buildbot.steps.source import Monotone
assert Monotone

@deprecatedImport
def test_steps_source_BK(self):
from buildbot.steps.source import BK
assert BK
Expand Down
3 changes: 3 additions & 0 deletions master/buildbot/test/unit/test_process_factory.py
Expand Up @@ -74,6 +74,9 @@ def test_addStep_notAStep(self):
def test_addStep_ArgumentsInTheWrongPlace(self):
factory = BuildFactory()
self.assertRaises(TypeError, factory.addStep, BuildStep(), name="name")
# this also raises a deprecation error, which we don't care about (see
# test_s)
self.flushWarnings()

def test_addSteps(self):
factory = BuildFactory()
Expand Down
Expand Up @@ -13,9 +13,13 @@
#
# Copyright Buildbot Team Members

import warnings
from twisted.trial import unittest

from buildbot.steps.source import Repo
with warnings.catch_warnings():
# ignore deprecation warnings
warnings.simplefilter('ignore')
from buildbot.steps.source import Repo

class RepoURL(unittest.TestCase):

Expand Down

0 comments on commit f24552b

Please sign in to comment.