Skip to content

Commit

Permalink
Replace new.module with types.ModuleType
Browse files Browse the repository at this point in the history
"import new" is gone in Python 3
  • Loading branch information
rodrigc committed Jan 17, 2017
1 parent 1f5865a commit 7d8d5d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions master/buildbot/test/unit/test_worker_transition.py
Expand Up @@ -16,9 +16,9 @@
from __future__ import absolute_import
from __future__ import print_function

import new
import re
import sys
import types

import mock

Expand Down Expand Up @@ -64,7 +64,7 @@ class Test_deprecatedWorkerModuleAttribute(unittest.TestCase):

def test_produces_warning(self):
Worker = type("Worker", (object,), {})
buildbot_module = new.module('buildbot_module')
buildbot_module = types.ModuleType('buildbot_module')
buildbot_module.Worker = Worker
with mock.patch.dict(sys.modules,
{'buildbot_module': buildbot_module}):
Expand All @@ -86,7 +86,7 @@ def test_produces_warning(self):
self.assertIdentical(S, Worker)

def test_not_catched_warning(self):
buildbot_module = new.module('buildbot_module')
buildbot_module = types.ModuleType('buildbot_module')
buildbot_module.deprecated_attr = 1
with mock.patch.dict(sys.modules,
{'buildbot_module': buildbot_module}):
Expand All @@ -111,7 +111,7 @@ def test_not_catched_warning(self):

def test_explicit_compat_name(self):
Worker = type("Worker", (object,), {})
buildbot_module = new.module('buildbot_module')
buildbot_module = types.ModuleType('buildbot_module')
buildbot_module.Worker = Worker
with mock.patch.dict(sys.modules,
{'buildbot_module': buildbot_module}):
Expand All @@ -135,7 +135,7 @@ def test_explicit_compat_name(self):

def test_explicit_new_name(self):
BuildSlave = type("BuildSlave", (object,), {})
buildbot_module = new.module('buildbot_module')
buildbot_module = types.ModuleType('buildbot_module')
buildbot_module.BuildSlave = BuildSlave
with mock.patch.dict(sys.modules,
{'buildbot_module': buildbot_module}):
Expand All @@ -157,7 +157,7 @@ def test_explicit_new_name(self):

def test_explicit_new_name_empty(self):
BuildSlave = type("BuildSlave", (object,), {})
buildbot_module = new.module('buildbot_module')
buildbot_module = types.ModuleType('buildbot_module')
buildbot_module.BuildSlave = BuildSlave
with mock.patch.dict(sys.modules,
{'buildbot_module': buildbot_module}):
Expand All @@ -180,7 +180,7 @@ def test_explicit_new_name_empty(self):

def test_module_reload(self):
Worker = type("Worker", (object,), {})
buildbot_module = new.module('buildbot_module')
buildbot_module = types.ModuleType('buildbot_module')
buildbot_module.Worker = Worker
with mock.patch.dict(sys.modules,
{'buildbot_module': buildbot_module}):
Expand Down
4 changes: 2 additions & 2 deletions master/buildbot/test/unit/test_www_ldapuserinfo.py
Expand Up @@ -18,15 +18,15 @@
from __future__ import print_function
from future.builtins import range

import new
import sys
import types

import mock

from twisted.internet import defer
from twisted.trial import unittest

fake_ldap = new.module('ldap3')
fake_ldap = types.ModuleType('ldap3')
fake_ldap.SEARCH_SCOPE_WHOLE_SUBTREE = 2
with mock.patch.dict(sys.modules, {'ldap3': fake_ldap}):
from buildbot.www import ldapuserinfo
Expand Down

0 comments on commit 7d8d5d0

Please sign in to comment.