Skip to content

Commit 306923f

Browse files
committed
Added a few tests
1 parent c5d8d7e commit 306923f

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

profile.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,19 @@
88

99
cProfile.run("Replay('test_replays/build17811/1.sc2replay')","replay_profile")
1010
stats = Stats("replay_profile")
11-
stats.strip_dirs().sort_stats("time").print_stats(15)
11+
stats.strip_dirs().sort_stats("time").print_stats(15)
12+
13+
# file_list = []
14+
# rootdir = "test_replays/"
15+
# for root, sub_folders, files in os.walk(rootdir):
16+
# for file in files:
17+
# if (os.path.splitext(file)[1].lower() == ".sc2replay"):
18+
# file_list.append(os.path.join(root,file))
19+
#
20+
# for file in file_list:
21+
# try:
22+
# replay = Replay(file)
23+
# except ValueError as e:
24+
# print e
25+
# except ParseError as e:
26+
# print e

test_replays/test_all.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# Run tests with "py.test" in the project root dir
2-
3-
# TODO:
4-
# - Performance tests to measure the effect of optimizations
52
import os, sys
6-
from timeit import Timer
73
import pytest
84

9-
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)),"../"))
5+
#sys.path.append(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),"../")))
6+
sys.path.insert(0, os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),"../")))
7+
108
from sc2reader import Replay
119
from sc2reader.exceptions import ParseError
1210

@@ -42,6 +40,7 @@ def test_1():
4240
assert replay.release_string == "1.2.2.17811"
4341
assert replay.speed == "Faster"
4442
assert replay.type == "1v1"
43+
# TODO: library should probably provide helper functions and/or constants to check this
4544
assert replay.category == "Ladder"
4645

4746
assert len(replay.players) == 2
@@ -96,4 +95,18 @@ def test_1():
9695
assert replay.messages[11].player.name == "Boom"
9796

9897
for msg in replay.messages:
99-
assert sent_to_all(msg) == True
98+
assert sent_to_all(msg) == True
99+
100+
def test_2():
101+
replay = Replay("test_replays/build17811/2.sc2replay")
102+
103+
# TODO: library should probably provide helper functions and/or constants to check this
104+
assert replay.category == "Private"
105+
106+
def test_3():
107+
replay = Replay("test_replays/build17811/3.sc2replay")
108+
109+
assert replay.type == "3v3"
110+
assert len(replay.messages) == 25
111+
112+
# TODO: Test 2v2, 4v4 and FFA

0 commit comments

Comments
 (0)