本文整理匯總了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()