本文整理汇总了Python中mock.patch.stopall方法的典型用法代码示例。如果您正苦于以下问题:Python patch.stopall方法的具体用法?Python patch.stopall怎么用?Python patch.stopall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.patch
的用法示例。
在下文中一共展示了patch.stopall方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from mock import patch [as 别名]
# 或者: from mock.patch import stopall [as 别名]
def setUp(self):
info_cinfo = patch('lib.client.node.Node._info_cinfo')
getfqdn = patch('lib.client.node.getfqdn')
getaddrinfo = patch('socket.getaddrinfo')
self.addCleanup(patch.stopall)
lib.client.node.Node._info_cinfo = info_cinfo.start()
lib.client.node.getfqdn = getfqdn.start()
socket.getaddrinfo = getaddrinfo.start()
Node._info_cinfo.return_value = ""
lib.client.node.getfqdn.return_value = "host.domain.local"
socket.getaddrinfo.return_value = [(2, 1, 6, '', ('192.1.1.1', 3000))]
#@unittest.skip("Known Failure")
示例2: setUp
# 需要导入模块: from mock import patch [as 别名]
# 或者: from mock.patch import stopall [as 别名]
def setUp(self):
info_cinfo = patch('lib.client.node.Node._info_cinfo')
getfqdn = patch('lib.client.node.getfqdn')
getaddrinfo = patch('socket.getaddrinfo')
self.addCleanup(patch.stopall)
lib.client.node.Node._info_cinfo = info_cinfo.start()
lib.client.node.getfqdn = getfqdn.start()
socket.getaddrinfo = getaddrinfo.start()
Node._info_cinfo.return_value = ""
lib.client.node.getfqdn.return_value = "host.domain.local"
def getaddressinfo_side_effect(*args):
return [(2, 1, 6, '', (args[0], 3000))]
socket.getaddrinfo = Mock(side_effect=getaddressinfo_side_effect)
# socket.getaddrinfo.return_value = [(2, 1, 6, '', ("192.1.1.1", 3000))]
示例3: storage
# 需要导入模块: from mock import patch [as 别名]
# 或者: from mock.patch import stopall [as 别名]
def storage(request):
import_module = patch.object(module, 'import_module').start()
storage = import_module.return_value.Storage.return_value
request.addfinalizer(patch.stopall)
return storage
示例4: setUp
# 需要导入模块: from mock import patch [as 别名]
# 或者: from mock.patch import stopall [as 别名]
def setUp(self):
self.cluster_patch = patch('lib.client.cluster.Cluster')
#self.view_patch = patch('lib.view.CliView')
real_stdoup = sys.stdout
sys.stdout = StringIO()
self.addCleanup(patch.stopall)
self.addCleanup(reset_stdout)
self.MockCluster = self.cluster_patch.start()
#self.MockView = self.view_patch.start()
Cluster._crawl = classmethod(lambda self: None)
Cluster.call_node_method = classmethod(
lambda self, nodes, method_name, *args, **kwargs:
{"test":IOError("test error")})
n = Node("172.99.99.99")
Cluster.get_node = classmethod(
lambda self, key: [n])
pd = LookupDict()
pd['test'] = 'test'
Cluster.get_node_displaynames = classmethod(lambda self: pd)
self.rc = BasicRootController()
示例5: tearDown
# 需要导入模块: from mock import patch [as 别名]
# 或者: from mock.patch import stopall [as 别名]
def tearDown(self):
patch.stopall()
示例6: setUp
# 需要导入模块: from mock import patch [as 别名]
# 或者: from mock.patch import stopall [as 别名]
def setUp(self):
fill_db()
request = request_factory.post('')
request.session = SessionStore()
set_up_session(request.session)
cart = Cart(request)
mock_update = Mock(wraps=cart.update)
patch.object(cart, 'update', mock_update).start()
self.addCleanup(patch.stopall)
self.mock_update = mock_update
self.request = request
self.cart = cart
self.cart_session = request.session[SESSION_KEY]
示例7: tearDown
# 需要导入模块: from mock import patch [as 别名]
# 或者: from mock.patch import stopall [as 别名]
def tearDown(self):
self.testbed.deactivate()
patch.stopall()
示例8: setUp
# 需要导入模块: from mock import patch [as 别名]
# 或者: from mock.patch import stopall [as 别名]
def setUp(self):
# Paths generated by git_path are always the given argument
_git_path_mock = patch('diff_cover.violationsreporters.violations_reporter.GitPathTool').start()
_git_path_mock.relative_path = lambda path: path
_git_path_mock.absolute_path = lambda path: path
self.addCleanup(patch.stopall)
示例9: tearDown
# 需要导入模块: from mock import patch [as 别名]
# 或者: from mock.patch import stopall [as 别名]
def tearDown(self):
"""
Undo all patches and reset the cwd
"""
patch.stopall()
os.chdir(self._old_cwd)
示例10: tearDown
# 需要导入模块: from mock import patch [as 别名]
# 或者: from mock.patch import stopall [as 别名]
def tearDown(self):
"""
Undo all patches.
"""
patch.stopall()