Skip to content

Commit

Permalink
add test for explit name in deprecatedWorkerModuleAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
rutsky committed Feb 3, 2016
1 parent b5fbf04 commit 62f0e7f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions master/buildbot/test/unit/test_worker_transition.py
Expand Up @@ -83,6 +83,31 @@ class Worker:
S = buildbot_module.Slave
self.assertIdentical(S, Worker)

def test_explicit_name(self):
Worker = type("Worker")

buildbot_module = new.module('buildbot_module')
buildbot_module.Worker = Worker
with mock.patch.dict(sys.modules,
{'buildbot_module': buildbot_module}):
scope = buildbot_module.__dict__
deprecatedWorkerModuleAttribute(
scope, Worker, compat_name="BuildSlave")

# Overwrite with Twisted's module wrapper.
import buildbot_module

with assertNotProducesWarnings(DeprecatedWorkerAPIWarning):
W = buildbot_module.Worker
self.assertIdentical(W, Worker)

with assertProducesWarning(
DeprecatedWorkerNameWarning,
message_pattern=r"buildbot_module\.BuildSlave was deprecated in "
r"Buildbot 0.9.0: Use Worker instead."):
S = buildbot_module.BuildSlave
self.assertIdentical(S, Worker)

def test_module_reload(self):
class Worker:
pass
Expand Down

0 comments on commit 62f0e7f

Please sign in to comment.