-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_test.py
More file actions
46 lines (37 loc) · 1.68 KB
/
utils_test.py
File metadata and controls
46 lines (37 loc) · 1.68 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
from utils import Move
from utils import check_for_stuff
from hero import Hero
import unittest
class Test(unittest.TestCase):
def setUp(self):
self.m = []
with open('test_map.txt', 'r') as f:
for i in f.readlines():
i = i.rstrip()
self.m.append(list(i))
self.hero = Hero(name='ivan', title='Dragon Slayer', health=100,
mana=100, mana_regeneration_rate=2, spell=None, weapon=None)
self.mover = Move(self.hero)
def test_check_for_sttuff(self):
self.assertRaises(AssertionError, check_for_stuff, '1', 1, 1, 'H', 1)
self.assertRaises(AssertionError, check_for_stuff,
self.m, '1', 1, 'H', 1)
self.assertRaises(AssertionError, check_for_stuff,
self.m, 1, '1', 'H', 1)
self.assertRaises(AssertionError, check_for_stuff, self.m, 1, 1, 1, 1)
self.assertRaises(AssertionError, check_for_stuff,
self.m, 1, 1, 'B', 1)
self.assertRaises(AssertionError, check_for_stuff,
self.m, 1, 1, 'H', '1')
def test_move(self):
self.assertRaises(AssertionError, self.mover.move,
self.m, 3, 1, 'wrong')
self.assertRaises(AssertionError, self.mover.move,
self.m, 3, '1', 'up')
self.assertRaises(AssertionError, self.mover.move,
self.m, '3', 1, 'wrong')
self.assertRaises(AssertionError, self.mover.move,
'self.m', 3, 1, 'wrong')
self.assertFalse(self.mover.move(self.m,3,1,'down'))
if __name__ == '__main__':
unittest.main()