upload_symbols: get tests passing under Python 3
There's one encoding fix to get pass the hard failure, then a bunch
of explicit socket/file closing to avoid resource leakage warnings.
BUG=chromium:997354
TEST=`./run_tests` passes
Change-Id: Icde02806e524a2bee835dd31126e1e1d2915683c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1919673
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/upload_symbols_unittest.py b/scripts/upload_symbols_unittest.py
index b526668..96a9127 100644
--- a/scripts/upload_symbols_unittest.py
+++ b/scripts/upload_symbols_unittest.py
@@ -101,7 +101,7 @@
with open(fullname, 'w+b') as f:
f.truncate(size)
f.seek(0)
- f.write(content)
+ f.write(content.encode('utf-8'))
result = upload_symbols.SymbolFile(display_path=filename,
file_name=fullname)
@@ -164,6 +164,8 @@
if self.httpd_pid == 0:
self.httpd.serve_forever(poll_interval=0.1)
sys.exit(0)
+ # The child runs the server, so close the socket in the parent.
+ self.httpd.server_close()
def setUp(self):
self.httpd_pid = None