本文整理汇总了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
示例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')
示例3: tearDown
# 需要导入模块: from unittest.mock import patch [as 别名]
# 或者: from unittest.mock.patch import stopall [as 别名]
def tearDown(self):
patch.stopall()
示例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]
示例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()
示例6: tearDown
# 需要导入模块: from unittest.mock import patch [as 别名]
# 或者: from unittest.mock.patch import stopall [as 别名]
def tearDown(self):
patch.stopall()
self.temp_file.close()
示例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()
示例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()
示例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()