Fix more tempfile already open problems in Windows tests

This commit is contained in:
Micah Lee 2020-08-21 18:33:45 -04:00
parent 176368a22b
commit c6f1eb4766
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73

View File

@ -83,13 +83,13 @@ class TestShare(GuiBaseTest):
),
)
tmp_file = tempfile.NamedTemporaryFile()
with open(tmp_file.name, "wb") as f:
f.write(r.content)
tmp_file = tempfile.NamedTemporaryFile("wb", delete=False)
tmp_file.write(r.content)
tmp_file.close()
zip = zipfile.ZipFile(tmp_file.name)
z = zipfile.ZipFile(tmp_file.name)
QtTest.QTest.qWait(50)
self.assertEqual("onionshare", zip.read("test.txt").decode("utf-8"))
self.assertEqual("onionshare", z.read("test.txt").decode("utf-8"))
QtTest.QTest.qWait(500)
@ -135,9 +135,8 @@ class TestShare(GuiBaseTest):
),
)
tmp_file = tempfile.NamedTemporaryFile()
with open(tmp_file.name, "wb") as f:
f.write(r.content)
tmp_file = tempfile.NamedTemporaryFile("wb")
tmp_file.write(r.content)
with open(tmp_file.name, "r") as f:
self.assertEqual("onionshare", f.read())
@ -207,7 +206,10 @@ class TestShare(GuiBaseTest):
QtTest.QTest.mouseRelease(
tab.get_mode().server_status.server_button, QtCore.Qt.LeftButton
)
self.assertEqual(tab.get_mode().server_status.status, 0)
self.assertEqual(
tab.get_mode().server_status.status,
tab.get_mode().server_status.STATUS_STOPPED,
)
self.server_is_stopped(tab)
self.web_server_is_stopped(tab)