33# Run tests with "py.test" in the project root dir
44import os , sys
55import pytest
6+ import datetime
67
78sys .path .insert (0 , os .path .normpath (os .path .join (os .path .dirname (os .path .abspath (__file__ )),"../" )))
89
@@ -21,8 +22,7 @@ def test_empty():
2122
2223def test_standard_1v1 ():
2324 replay = Replay ("test_replays/build17811/1.SC2Replay" )
24-
25- # assert replay.date == "20 Feb 2011 22:44:48"
25+
2626 assert replay .length == (32 , 47 )
2727 assert replay .map == "Lost Temple"
2828 assert replay .build == 17811
@@ -152,3 +152,19 @@ def test_kr_realm_and_tampered_messages():
152152
153153def test_encrypted ():
154154 replay = Replay ("test_replays/build17811/4.SC2Replay" )
155+
156+ def test_datetimes ():
157+ # Ignore seconds in comparisons, because they are off by one what is reported by Windows.
158+ # This might be a little nuance worth investigating at some point.
159+
160+ # Played at 20 Feb 2011 22:44:48 UTC+2
161+ replay = Replay ("test_replays/build17811/1.SC2Replay" )
162+ assert replay .utc_date == datetime .datetime (2011 , 2 , 20 , 20 , 44 , 47 )
163+
164+ # Played at 21 Feb 2011 00:42:13 UTC+2
165+ replay = Replay ("test_replays/build17811/2.SC2Replay" )
166+ assert replay .utc_date == datetime .datetime (2011 , 2 , 20 , 22 , 42 , 12 )
167+
168+ # Played at 25 Feb 2011 16:36:28 UTC+2
169+ replay = Replay ("test_replays/build17811/3.SC2Replay" )
170+ assert replay .utc_date == datetime .datetime (2011 , 2 , 25 , 14 , 36 , 26 )
0 commit comments