Skip to content

Commit

Permalink
Fix Python 2 issues with test_event_print.
Browse files Browse the repository at this point in the history
Logic issue with conditional import.
StringIO.StringIO does not support usage of the with keyword.
  • Loading branch information
Gusgus01 committed Nov 2, 2018
1 parent a66278d commit 8c90728
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test_replays/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import unittest
# StringIO was changed in python 3
try:
from io import StringIO
except ImportError:
from StringIO import StringIO
except ImportError:
from io import StringIO

import sc2reader
from sc2reader.exceptions import CorruptTrackerFileError
Expand Down Expand Up @@ -589,12 +589,12 @@ def test_65895(self):

def test_event_print(self):
replay = sc2reader.load_replay("test_replays/lotv/lotv1.SC2Replay")
with StringIO() as capturedOutput:
sys.stdout = capturedOutput
for event in replay.events:
print(event)
self.assertIn("PlayerLeaveEvent", capturedOutput.getvalue())
sys.stdout = sys.__stdout__
sys.stdout = capturedOutput = StringIO()
for event in replay.events:
print(event)
self.assertIn("PlayerLeaveEvent", capturedOutput.getvalue())
sys.stdout = sys.__stdout__
capturedOutput.close()


class TestGameEngine(unittest.TestCase):
Expand Down

0 comments on commit 8c90728

Please sign in to comment.