當前位置: 首頁>>代碼示例>>Python>>正文


Python patch.stopall方法代碼示例

本文整理匯總了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") 
開發者ID:aerospike,項目名稱:aerospike-admin,代碼行數:18,代碼來源:test_node.py

示例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))] 
開發者ID:aerospike,項目名稱:aerospike-admin,代碼行數:20,代碼來源:test_cluster.py

示例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 
開發者ID:frictionlessdata,項目名稱:datapackage-py,代碼行數:7,代碼來源:test_pushpull.py

示例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() 
開發者ID:aerospike,項目名稱:aerospike-admin,代碼行數:29,代碼來源:test_controller.py

示例5: tearDown

# 需要導入模塊: from mock import patch [as 別名]
# 或者: from mock.patch import stopall [as 別名]
def tearDown(self):
        patch.stopall() 
開發者ID:nccgroup,項目名稱:ScoutSuite,代碼行數:4,代碼來源:test-main.py

示例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] 
開發者ID:nevimov,項目名稱:django-easycart,代碼行數:15,代碼來源:test_cart.py

示例7: tearDown

# 需要導入模塊: from mock import patch [as 別名]
# 或者: from mock.patch import stopall [as 別名]
def tearDown(self):
        self.testbed.deactivate()
        patch.stopall() 
開發者ID:ocadotechnology,項目名稱:gcp-census,代碼行數:5,代碼來源:model_creator_handler_test.py

示例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) 
開發者ID:Bachmann1234,項目名稱:diff_cover,代碼行數:8,代碼來源:test_violations_reporter.py

示例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) 
開發者ID:Bachmann1234,項目名稱:diff_cover,代碼行數:8,代碼來源:test_integration.py

示例10: tearDown

# 需要導入模塊: from mock import patch [as 別名]
# 或者: from mock.patch import stopall [as 別名]
def tearDown(self):
        """
        Undo all patches.
        """
        patch.stopall() 
開發者ID:Bachmann1234,項目名稱:diff_cover,代碼行數:7,代碼來源:test_java_violations_reporter.py


注:本文中的mock.patch.stopall方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。