commit 6b7eecab5de70b454fa836515183432e1a97359c Author: Tim Burke Date: Fri Oct 16 14:48:40 2020 -0700 Get unit tests passing on py39 They finally got rid of Thread.isAlive, having added Thread.is_alive as an alias back in 2.6. array.tostring is also gone; use array.tofile instead, but only on py3. Change-Id: I0b7e426c60118a5df879a8908729d7feb12dfc1b diff --git a/swift/common/ring/ring.py b/swift/common/ring/ring.py index ce31fc4..43eac5d 100644 --- a/swift/common/ring/ring.py +++ b/swift/common/ring/ring.py @@ -28,6 +28,7 @@ from tempfile import NamedTemporaryFile import sys import zlib +import six from six.moves import range from swift.common.exceptions import RingLoadError @@ -221,7 +222,12 @@ class RingData(object): file_obj.write(struct.pack('!I', json_len)) file_obj.write(json_text) for part2dev_id in ring['replica2part2dev_id']: - file_obj.write(part2dev_id.tostring()) + if six.PY2: + # Can't just use tofile() because a GzipFile apparently + # doesn't count as an 'open file' + file_obj.write(part2dev_id.tostring()) + else: + part2dev_id.tofile(file_obj) def save(self, filename, mtime=1300507380.0): """ diff --git a/test/unit/common/test_manager.py b/test/unit/common/test_manager.py index 5e6296f..b19bfcc 100644 --- a/test/unit/common/test_manager.py +++ b/test/unit/common/test_manager.py @@ -1305,7 +1305,7 @@ class TestServer(unittest.TestCase): return self def __exit__(self, *args): - if self.isAlive(): + if self.is_alive(): self.join() def close_stdout(self): @@ -1359,7 +1359,7 @@ class TestServer(unittest.TestCase): status = server.wait() self.assertEqual(status, 0) # wait should return before process exits - self.assertTrue(proc.isAlive()) + self.assertTrue(proc.is_alive()) self.assertFalse(proc.finished) self.assertTrue(proc.finished) # make sure it did finish # test output kwarg prints subprocess output @@ -1385,7 +1385,7 @@ class TestServer(unittest.TestCase): status = server.wait() self.assertEqual(status, 0) for proc in procs: - self.assertTrue(proc.isAlive()) + self.assertTrue(proc.is_alive()) for proc in procs: proc.join() finally: