當前位置: 首頁>>代碼示例>>Python>>正文


Python networktransaction.NetworkTransaction類代碼示例

本文整理匯總了Python中webkitpy.common.net.networktransaction.NetworkTransaction的典型用法代碼示例。如果您正苦於以下問題:Python NetworkTransaction類的具體用法?Python NetworkTransaction怎麽用?Python NetworkTransaction使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了NetworkTransaction類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_retry

 def test_retry(self):
     transaction = NetworkTransaction(initial_backoff_seconds=0)
     self.assertEqual(transaction.run(self._raise_500_error), 42)
     self.assertEqual(self._run_count, 3)
     self.assertLog(['WARNING: Received HTTP status 500 loading "http://example.com/".  '
                     'Retrying in 0 seconds...\n',
                     'WARNING: Received HTTP status 500 loading "http://example.com/".  '
                     'Retrying in 0.0 seconds...\n'])
開發者ID:mirror,項目名稱:chromium,代碼行數:8,代碼來源:networktransaction_unittest.py

示例2: test_retry

 def test_retry(self):
     self._run_count = 0
     transaction = NetworkTransaction(initial_backoff_seconds=0)
     self.assertEqual(transaction.run(lambda: self._raise_500_error()), 42)
     self.assertEqual(self._run_count, 3)
     self.assertLog(['WARNING: Received HTTP status 500 from server.  '
                     'Retrying in 0 seconds...\n',
                     'WARNING: Received HTTP status 500 from server.  '
                     'Retrying in 0.0 seconds...\n'])
開發者ID:achellies,項目名稱:WinCEWebKit,代碼行數:9,代碼來源:networktransaction_unittest.py

示例3: test_timeout

 def test_timeout(self):
     self._run_count = 0
     transaction = NetworkTransaction(initial_backoff_seconds=60*60, timeout_seconds=60)
     did_process_exception = False
     did_throw_exception = True
     try:
         transaction.run(lambda: self._raise_500_error())
         did_throw_exception = False
     except NetworkTimeout, e:
         did_process_exception = True
開發者ID:achellies,項目名稱:WinCEWebKit,代碼行數:10,代碼來源:networktransaction_unittest.py

示例4: test_exception

 def test_exception(self):
     transaction = NetworkTransaction()
     did_process_exception = False
     did_throw_exception = True
     try:
         transaction.run(lambda: self._raise_exception())
         did_throw_exception = False
     except Exception, e:
         did_process_exception = True
         self.assertEqual(e, self.exception)
開發者ID:achellies,項目名稱:WinCEWebKit,代碼行數:10,代碼來源:networktransaction_unittest.py

示例5: test_timeout

 def test_timeout(self):
     transaction = NetworkTransaction(initial_backoff_seconds=60 * 60, timeout_seconds=60)
     did_process_exception = False
     did_throw_exception = True
     try:
         transaction.run(self._raise_500_error)
         did_throw_exception = False
     except NetworkTimeout:
         did_process_exception = True
     self.assertTrue(did_throw_exception)
     self.assertTrue(did_process_exception)
開發者ID:mirror,項目名稱:chromium,代碼行數:11,代碼來源:networktransaction_unittest.py

示例6: test_convert_404_to_None

 def test_convert_404_to_None(self):
     transaction = NetworkTransaction(convert_404_to_None=True)
     self.assertEqual(transaction.run(lambda: self._raise_404_error()), None)
開發者ID:achellies,項目名稱:WinCEWebKit,代碼行數:3,代碼來源:networktransaction_unittest.py

示例7: test_success

 def test_success(self):
     transaction = NetworkTransaction()
     self.assertEqual(transaction.run(lambda: 42), 42)
開發者ID:achellies,項目名稱:WinCEWebKit,代碼行數:3,代碼來源:networktransaction_unittest.py

示例8: test_convert_404_to_None

 def test_convert_404_to_None(self):
     transaction = NetworkTransaction(convert_404_to_None=True)
     self.assertIsNone(transaction.run(self._raise_404_error))
開發者ID:mirror,項目名稱:chromium,代碼行數:3,代碼來源:networktransaction_unittest.py


注:本文中的webkitpy.common.net.networktransaction.NetworkTransaction類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。