本文整理匯總了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'])
示例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'])
示例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
示例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)
示例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)
示例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)
示例7: test_success
def test_success(self):
transaction = NetworkTransaction()
self.assertEqual(transaction.run(lambda: 42), 42)
示例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))