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
This commit is contained in:
Tim Burke 2020-10-16 14:48:40 -07:00
parent 127bf9707c
commit 6b7eecab5d
2 changed files with 10 additions and 4 deletions

View File

@ -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):
"""

View File

@ -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: