Skip to content

Commit 8c90728

Browse files
committed
Fix Python 2 issues with test_event_print.
Logic issue with conditional import. StringIO.StringIO does not support usage of the with keyword.
1 parent a66278d commit 8c90728

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

test_replays/test_all.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
import unittest
1414
# StringIO was changed in python 3
1515
try:
16-
from io import StringIO
17-
except ImportError:
1816
from StringIO import StringIO
17+
except ImportError:
18+
from io import StringIO
1919

2020
import sc2reader
2121
from sc2reader.exceptions import CorruptTrackerFileError
@@ -589,12 +589,12 @@ def test_65895(self):
589589

590590
def test_event_print(self):
591591
replay = sc2reader.load_replay("test_replays/lotv/lotv1.SC2Replay")
592-
with StringIO() as capturedOutput:
593-
sys.stdout = capturedOutput
594-
for event in replay.events:
595-
print(event)
596-
self.assertIn("PlayerLeaveEvent", capturedOutput.getvalue())
597-
sys.stdout = sys.__stdout__
592+
sys.stdout = capturedOutput = StringIO()
593+
for event in replay.events:
594+
print(event)
595+
self.assertIn("PlayerLeaveEvent", capturedOutput.getvalue())
596+
sys.stdout = sys.__stdout__
597+
capturedOutput.close()
598598

599599

600600
class TestGameEngine(unittest.TestCase):

0 commit comments

Comments
 (0)