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

Side by Side Diff: client/tests/on_error_test.py

Issue 2857443002: Finally fix on_error_test hang. (Closed)
Patch Set: Add default None value for getattr() Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The LUCI Authors. All rights reserved. 2 # Copyright 2014 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 import BaseHTTPServer 6 import BaseHTTPServer
7 import atexit 7 import atexit
8 import cgi 8 import cgi
9 import getpass 9 import getpass
10 import json 10 import json
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 self.end_headers() 124 self.end_headers()
125 data = { 125 data = {
126 'id': '1234', 126 'id': '1234',
127 'url': 'https://localhost/error/1234', 127 'url': 'https://localhost/error/1234',
128 } 128 }
129 self.wfile.write(json.dumps(data)) 129 self.wfile.write(json.dumps(data))
130 130
131 131
132 def start_server(): 132 def start_server():
133 """Starts an HTTPS web server and returns the port bound.""" 133 """Starts an HTTPS web server and returns the port bound."""
134 # A premade passwordless self-signed certificate. It works because urllib 134 # A premade passwordless self-signed certificate. It works because older
135 # doesn't verify the certificate validity. 135 # urllib doesn't verify the certificate validity. Disable SSL certificate
136 # verification for more recent version.
137 create_unverified_https_context = getattr(
138 ssl, '_create_unverified_context', None)
139 if create_unverified_https_context:
140 ssl._create_default_https_context = create_unverified_https_context
136 httpd = HttpsServer(('127.0.0.1', 0), Handler, 'localhost', pem=PEM) 141 httpd = HttpsServer(('127.0.0.1', 0), Handler, 'localhost', pem=PEM)
137 httpd.start() 142 httpd.start()
138 return httpd 143 return httpd
139 144
140 145
141 class OnErrorBase(auto_stub.TestCase): 146 class OnErrorBase(auto_stub.TestCase):
142 HOSTNAME = socket.getfqdn() 147 HOSTNAME = socket.getfqdn()
143 148
144 def setUp(self): 149 def setUp(self):
145 super(OnErrorBase, self).setUp() 150 super(OnErrorBase, self).setUp()
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 os.environ.pop(on_error._DISABLE_ENVVAR, None) 421 os.environ.pop(on_error._DISABLE_ENVVAR, None)
417 422
418 if len(sys.argv) == 4 and sys.argv[1] == 'run_shell_out': 423 if len(sys.argv) == 4 and sys.argv[1] == 'run_shell_out':
419 sys.exit(run_shell_out(sys.argv[2], sys.argv[3])) 424 sys.exit(run_shell_out(sys.argv[2], sys.argv[3]))
420 425
421 if '-v' in sys.argv: 426 if '-v' in sys.argv:
422 unittest.TestCase.maxDiff = None 427 unittest.TestCase.maxDiff = None
423 logging.basicConfig( 428 logging.basicConfig(
424 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR) 429 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR)
425 unittest.main() 430 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698