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