Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/net/networktransaction_unittest.py

Issue 2248653002: Revert of Fix pylint warnings in webkitpy/common/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Manual Revert (Patch Set 1 causes patch failure in read_checksum_from_png_unittest.py) Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (c) 2010 Google Inc. All rights reserved. 1 # Copyright (c) 2010 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 def _raise_exception(self): 46 def _raise_exception(self):
47 raise self.exception 47 raise self.exception
48 48
49 def test_exception(self): 49 def test_exception(self):
50 transaction = NetworkTransaction() 50 transaction = NetworkTransaction()
51 did_process_exception = False 51 did_process_exception = False
52 did_throw_exception = True 52 did_throw_exception = True
53 try: 53 try:
54 transaction.run(self._raise_exception) 54 transaction.run(self._raise_exception)
55 did_throw_exception = False 55 did_throw_exception = False
56 except Exception as e: # pylint: disable=broad-except 56 except Exception as e:
57 did_process_exception = True 57 did_process_exception = True
58 self.assertEqual(e, self.exception) 58 self.assertEqual(e, self.exception)
59 self.assertTrue(did_throw_exception) 59 self.assertTrue(did_throw_exception)
60 self.assertTrue(did_process_exception) 60 self.assertTrue(did_process_exception)
61 61
62 def _raise_500_error(self): 62 def _raise_500_error(self):
63 self._run_count += 1 63 self._run_count += 1
64 if self._run_count < 3: 64 if self._run_count < 3:
65 raise HTTPError("http://example.com/", 500, "internal server error", None, None) 65 raise HTTPError("http://example.com/", 500, "internal server error", None, None)
66 return 42 66 return 42
67 67
68 def _raise_404_error(self): 68 def _raise_404_error(self):
69 raise HTTPError("http://foo.com/", 404, "not found", None, None) 69 raise HTTPError("http://foo.com/", 404, "not found", None, None)
70 70
71 def test_retry(self): 71 def test_retry(self):
72 transaction = NetworkTransaction(initial_backoff_seconds=0) 72 transaction = NetworkTransaction(initial_backoff_seconds=0)
73 self.assertEqual(transaction.run(self._raise_500_error), 42) 73 self.assertEqual(transaction.run(self._raise_500_error), 42)
74 self.assertEqual(self._run_count, 3) 74 self.assertEqual(self._run_count, 3)
75 self.assertLog(['WARNING: Received HTTP status 500 loading "http://examp le.com/". ' 75 self.assertLog(['WARNING: Received HTTP status 500 loading "http://examp le.com/". '
76 'Retrying in 0 seconds...\n', 76 'Retrying in 0 seconds...\n',
77 'WARNING: Received HTTP status 500 loading "http://examp le.com/". ' 77 'WARNING: Received HTTP status 500 loading "http://examp le.com/". '
78 'Retrying in 0.0 seconds...\n']) 78 'Retrying in 0.0 seconds...\n'])
79 79
80 def test_convert_404_to_none(self): 80 def test_convert_404_to_None(self):
81 transaction = NetworkTransaction(convert_404_to_None=True) 81 transaction = NetworkTransaction(convert_404_to_None=True)
82 self.assertIsNone(transaction.run(self._raise_404_error)) 82 self.assertIsNone(transaction.run(self._raise_404_error))
83 83
84 def test_timeout(self): 84 def test_timeout(self):
85 transaction = NetworkTransaction(initial_backoff_seconds=60 * 60, timeou t_seconds=60) 85 transaction = NetworkTransaction(initial_backoff_seconds=60 * 60, timeou t_seconds=60)
86 did_process_exception = False 86 did_process_exception = False
87 did_throw_exception = True 87 did_throw_exception = True
88 try: 88 try:
89 transaction.run(self._raise_500_error) 89 transaction.run(self._raise_500_error)
90 did_throw_exception = False 90 did_throw_exception = False
91 except NetworkTimeout: 91 except NetworkTimeout:
92 did_process_exception = True 92 did_process_exception = True
93 self.assertTrue(did_throw_exception) 93 self.assertTrue(did_throw_exception)
94 self.assertTrue(did_process_exception) 94 self.assertTrue(did_process_exception)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698