Skip to content

Commit 86287f0

Browse files
committed
Tests should demonstrate both plugin methods.
1 parent 85b4507 commit 86287f0

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

test_replays/test_all.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,10 @@ def test_map_info(self):
284284
controllers = [(p.pid, p.control) for p in replay.map.map_info.players]
285285
self.assertEquals(controllers, [(0, 3), (1, 1), (2, 1), (15, 4)])
286286

287-
def test_plugins(self):
287+
def test_engine_plugins(self):
288288
from sc2reader.engine.plugins import ContextLoader, APMTracker, SelectionTracker
289-
from sc2reader.factories.plugins.replay import toJSON
290289

291-
from sc2reader.factories import SC2Factory
292-
factory = SC2Factory()
293-
factory.register_plugin('Replay', toJSON())
294-
replay = factory.load_replay(
290+
replay = sc2reader.load_replay(
295291
"test_replays/2.0.5.25092/cn1.SC2Replay",
296292
engine=sc2reader.engine.GameEngine(plugins=[
297293
ContextLoader(),
@@ -300,6 +296,15 @@ def test_plugins(self):
300296
])
301297
)
302298

299+
def test_factory_plugins(self):
300+
from sc2reader.factories.plugins.replay import APMTracker, SelectionTracker, toJSON
301+
302+
factory = sc2reader.factories.SC2Factory()
303+
factory.register_plugin("Replay", APMTracker())
304+
factory.register_plugin("Replay", SelectionTracker())
305+
factory.register_plugin("Replay", toJSON())
306+
replay = factory.load_replay("test_replays/2.0.5.25092/cn1.SC2Replay")
307+
303308
# Load and quickly check the JSON output consistency
304309
result = json.loads(replay)
305310
self.assertEquals(result["map_name"], u"生化实验区")

0 commit comments

Comments
 (0)