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

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

Issue 2014063002: Run format-webkit on webkitpy code (without string conversion). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 def _raise_exception(self): 42 def _raise_exception(self):
43 raise self.exception 43 raise self.exception
44 44
45 def test_exception(self): 45 def test_exception(self):
46 transaction = NetworkTransaction() 46 transaction = NetworkTransaction()
47 did_process_exception = False 47 did_process_exception = False
48 did_throw_exception = True 48 did_throw_exception = True
49 try: 49 try:
50 transaction.run(lambda: self._raise_exception()) 50 transaction.run(lambda: self._raise_exception())
51 did_throw_exception = False 51 did_throw_exception = False
52 except Exception, e: 52 except Exception as e:
53 did_process_exception = True 53 did_process_exception = True
54 self.assertEqual(e, self.exception) 54 self.assertEqual(e, self.exception)
55 self.assertTrue(did_throw_exception) 55 self.assertTrue(did_throw_exception)
56 self.assertTrue(did_process_exception) 56 self.assertTrue(did_process_exception)
57 57
58 def _raise_500_error(self): 58 def _raise_500_error(self):
59 self._run_count += 1 59 self._run_count += 1
60 if self._run_count < 3: 60 if self._run_count < 3:
61 raise HTTPError("http://example.com/", 500, "internal server error", None, None) 61 raise HTTPError("http://example.com/", 500, "internal server error", None, None)
62 return 42 62 return 42
(...skipping 16 matching lines...) Expand all
79 self.assertIsNone(transaction.run(lambda: self._raise_404_error())) 79 self.assertIsNone(transaction.run(lambda: self._raise_404_error()))
80 80
81 def test_timeout(self): 81 def test_timeout(self):
82 self._run_count = 0 82 self._run_count = 0
83 transaction = NetworkTransaction(initial_backoff_seconds=60 * 60, timeou t_seconds=60) 83 transaction = NetworkTransaction(initial_backoff_seconds=60 * 60, timeou t_seconds=60)
84 did_process_exception = False 84 did_process_exception = False
85 did_throw_exception = True 85 did_throw_exception = True
86 try: 86 try:
87 transaction.run(lambda: self._raise_500_error()) 87 transaction.run(lambda: self._raise_500_error())
88 did_throw_exception = False 88 did_throw_exception = False
89 except NetworkTimeout, e: 89 except NetworkTimeout as e:
90 did_process_exception = True 90 did_process_exception = True
91 self.assertTrue(did_throw_exception) 91 self.assertTrue(did_throw_exception)
92 self.assertTrue(did_process_exception) 92 self.assertTrue(did_process_exception)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698