Skip to content

Commit 5cdfad1

Browse files
committed
Add test for print functionality.
Load a lotv replay and print all the events to ensure they print. The output from the prints have been redirected to a stream using StringIO and then checked for the last few events to occur.
1 parent fdb913f commit 5cdfad1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test_replays/test_all.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
import unittest2 as unittest
1212
else:
1313
import unittest
14+
# StringIO was changed in python 3
15+
try:
16+
from io import StringIO
17+
except ImportError:
18+
from StringIO import StringIO
1419

1520
import sc2reader
1621
from sc2reader.exceptions import CorruptTrackerFileError
@@ -582,6 +587,15 @@ def test_65895(self):
582587
factory = sc2reader.factories.SC2Factory()
583588
replay = factory.load_replay(replayfilename)
584589

590+
def test_event_print(self):
591+
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__
598+
585599

586600
class TestGameEngine(unittest.TestCase):
587601
class TestEvent(object):

0 commit comments

Comments
 (0)