forked from xando/progpac.py3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
83 lines (46 loc) · 1.25 KB
/
tests.py
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
72
73
74
75
76
77
78
79
80
81
82
from game import World, Player
class TestWorldEmpty(World):
start = (1, 1)
map = [['o', 'o', 'o'],
['o', 'o', 'o'],
['o', 'o', 'o']]
def test_move_valid_1():
player = Player(TestWorldEmpty)
player.up()
assert player.position == (1, 0)
player = Player(TestWorldEmpty)
player.right()
assert player.position == (2, 1)
player = Player(TestWorldEmpty)
player.down()
assert player.position == (1, 2)
player = Player(TestWorldEmpty)
player.left()
assert player.position == (0, 1)
def test_move_valid_2():
player = Player(TestWorldEmpty)
player.up()
player.right()
assert player.position == (2, 0)
def test_move_valid_3():
player = Player(TestWorldEmpty)
player.up()
player.up()
player.up()
assert player.position == (1, 0)
player = Player(TestWorldEmpty)
player.left()
player.left()
player.left()
assert player.position == (0, 1)
class TestWorld(World):
start = (0, 0)
map = [['o', 'x'],
['o', 'x']]
def test_move_obstacle():
player = Player(TestWorld)
player.down()
assert player.position == (0, 1)
player = Player(TestWorld)
player.right()
assert player.position == (0, 0)