forked from altf4/libmelee
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·71 lines (65 loc) · 2.76 KB
/
test.py
File metadata and controls
executable file
·71 lines (65 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/python3
import unittest
import melee
class SLPFile(unittest.TestCase):
"""
Test cases that can be run automatically in the Github cloud environment
In particular, there are no live dolphin tests here.
"""
def test_read_file(self):
"""
Load and parse SLP file
"""
console = melee.Console(is_dolphin=False,
allow_old_version=False,
path="test_artifacts/test_game_1.slp")
self.assertTrue(console.connect())
framecount = 0
while True:
gamestate = console.step()
framecount += 1
if gamestate is None:
self.assertEqual(framecount, 1039)
break
if gamestate.frame == -123:
self.assertEqual(console.slp_version_tuple, (3, 6, 1))
self.assertEqual(gamestate.players[1].character.value, 1)
self.assertEqual(gamestate.players[2].character.value, 1)
if gamestate.frame == 297:
self.assertEqual(gamestate.players[1].action.value, 0)
self.assertEqual(gamestate.players[2].action.value, 27)
self.assertEqual(int(gamestate.players[1].percent), 17)
self.assertEqual(gamestate.players[2].percent, 0)
def test_read_old_file(self):
"""
Load and parse old SLP file
"""
console = melee.Console(is_dolphin=False,
allow_old_version=True,
path="test_artifacts/test_game_2.slp")
self.assertTrue(console.connect())
framecount = 0
while True:
gamestate = console.step()
framecount += 1
if gamestate is None:
self.assertEqual(framecount, 3840)
break
if gamestate.frame == -123:
self.assertEqual(console.slp_version_tuple, (2, 0, 1))
self.assertEqual(gamestate.players[2].character.value, 3)
self.assertEqual(gamestate.players[3].character.value, 18)
if gamestate.frame == 301:
self.assertEqual(gamestate.players[2].action.value, 88)
self.assertEqual(gamestate.players[3].action.value, 56)
self.assertEqual(int(gamestate.players[2].percent), 25)
self.assertEqual(gamestate.players[3].percent, 0)
def test_framedata(self):
"""
Test that frame and stage data retreive correctly
"""
framedata = melee.FrameData()
self.assertTrue(framedata.is_attack(melee.Character.FALCO, melee.Action.DAIR))
self.assertFalse(framedata.is_attack(melee.Character.FALCO, melee.Action.STANDING))
if __name__ == '__main__':
unittest.main()