当前位置: 首页>>代码示例>>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;未经允许,请勿转载。