当前位置: 首页>>代码示例>>Python>>正文


Python patch.stopall方法代码示例

本文整理汇总了Python中unittest.mock.patch.stopall方法的典型用法代码示例。如果您正苦于以下问题:Python patch.stopall方法的具体用法?Python patch.stopall怎么用?Python patch.stopall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest.mock.patch的用法示例。


在下文中一共展示了patch.stopall方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from unittest.mock import patch [as 别名]
# 或者: from unittest.mock.patch import stopall [as 别名]
def setUp(self):
        self.apns_mock_class = patch("sygnal.apnspushkin.APNs").start()
        self.apns_mock = MagicMock()
        self.apns_mock_class.return_value = self.apns_mock

        # pretend our certificate exists
        patch("os.path.exists", lambda x: x == TEST_CERTFILE_PATH).start()
        # Since no certificate exists, don't try to read it.
        patch("sygnal.apnspushkin.ApnsPushkin._report_certificate_expiration").start()
        self.addCleanup(patch.stopall)

        super(HttpTestCase, self).setUp()

        self.apns_pushkin_snotif = MagicMock()
        for key, value in self.sygnal.pushkins.items():
            value._send_notification = self.apns_pushkin_snotif 
开发者ID:matrix-org,项目名称:sygnal,代码行数:18,代码来源:test_http.py

示例2: setUp

# 需要导入模块: from unittest.mock import patch [as 别名]
# 或者: from unittest.mock.patch import stopall [as 别名]
def setUp(self):
        client_patcher = patch('pyredis.pool.ClusterClient', autospeck=True)
        self.client_mock = client_patcher.start()

        self.client_mock_inst = Mock()
        self.client_mock.return_value = self.client_mock_inst

        map_patcher = patch('pyredis.pool.ClusterMap', autospeck=True)
        self.map_mock = map_patcher.start()

        self.map_mock_inst = Mock()
        self.map_mock.return_value = self.map_mock_inst

        self.addCleanup(patch.stopall)

        self.pool = pyredis.pool.ClusterPool(seeds=[('seed1', 12345), ('seed2', 12345), ('seed3', 12345)],
                                             password='blubber') 
开发者ID:schlitzered,项目名称:pyredis,代码行数:19,代码来源:test_pool.py

示例3: tearDown

# 需要导入模块: from unittest.mock import patch [as 别名]
# 或者: from unittest.mock.patch import stopall [as 别名]
def tearDown(self):
        patch.stopall() 
开发者ID:nusnlp,项目名称:crosentgec,代码行数:4,代码来源:test_train.py

示例4: setUp

# 需要导入模块: from unittest.mock import patch [as 别名]
# 或者: from unittest.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

示例5: tearDown

# 需要导入模块: from unittest.mock import patch [as 别名]
# 或者: from unittest.mock.patch import stopall [as 别名]
def tearDown(self):
        self.read_pipe.close()
        self.write_pipe.close()
        patch.stopall() 
开发者ID:b2wdigital,项目名称:aiologger,代码行数:6,代码来源:test_streams.py

示例6: tearDown

# 需要导入模块: from unittest.mock import patch [as 别名]
# 或者: from unittest.mock.patch import stopall [as 别名]
def tearDown(self):
        patch.stopall()
        self.temp_file.close() 
开发者ID:b2wdigital,项目名称:aiologger,代码行数:5,代码来源:test_files.py

示例7: tearDown

# 需要导入模块: from unittest.mock import patch [as 别名]
# 或者: from unittest.mock.patch import stopall [as 别名]
def tearDown(self):
        self.write_pipe.close()
        self.reader_transport.close()
        self.read_pipe.close()
        await self.logger.shutdown()
        patch.stopall() 
开发者ID:b2wdigital,项目名称:aiologger,代码行数:8,代码来源:test_json_logger.py

示例8: tearDown

# 需要导入模块: from unittest.mock import patch [as 别名]
# 或者: from unittest.mock.patch import stopall [as 别名]
def tearDown(self):
        self.read_pipe.close()
        self.write_pipe.close()
        asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())
        patch.stopall() 
开发者ID:b2wdigital,项目名称:aiologger,代码行数:7,代码来源:test_uvloop_integration.py

示例9: tearDown

# 需要导入模块: from unittest.mock import patch [as 别名]
# 或者: from unittest.mock.patch import stopall [as 别名]
def tearDown(self):
        await super(AuthenticationTest, self).tearDown()
        patch.stopall() 
开发者ID:b2wdigital,项目名称:asgard-api,代码行数:5,代码来源:test_apiv2.py


注:本文中的unittest.mock.patch.stopall方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。