當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。