-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_fctBase.py
62 lines (42 loc) · 2.22 KB
/
test_fctBase.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
import projet
import unittest
import unittest.mock
class test_absol(unittest.TestCase):
def test1(self):
self.assertEqual(projet.absol((-1, 1)), (1, 1))
def test2(self):
self.assertEqual(projet.absol((-1, -1)), (1, 1))
def test3(self):
self.assertEqual(projet.absol((2, 1)), (2, 1))
class test_droite(unittest.TestCase):
def test1(self):
self.assertEqual(projet.droite((0, 0), (0, 1)), (1, 0, 0))
def test2(self):
self.assertEqual(projet.droite((0, 0), (1, 0)), (0, 1, 0))
def test3(self):
self.assertEqual(projet.droite((0, 0), (1, 1)), (-1, 1, 0))
def test4(self):
self.assertEqual(projet.droite((1, 2), (2, 3)), (-1, 1, -1))
class test_intInput(unittest.TestCase):
@unittest.mock.patch('builtins.input', lambda x: '10')
def test1(self):
self.assertEqual(projet.intInput("test"), 10)
@unittest.mock.patch('builtins.input', lambda x: '-1')
def test2(self):
self.assertEqual(projet.intInput(), -1)
@unittest.mock.patch('builtins.input', unittest.mock.MagicMock(side_effect=['+', '5']))
def test3(self):
self.assertEqual(projet.intInput(), 5)
class test_choixPos(unittest.TestCase):
@unittest.mock.patch('projet.equipe', nbEquipe=1)
@unittest.mock.patch('builtins.input', unittest.mock.MagicMock(side_effect=['-1', '1', 'ab', '+', '1', '2', '1', '0', '1', '2',
'1', '7', '1', '12', '1', '-1', '1', '8', '2', '0', '2', '3', '2', '4', '11', '0', '11', '8']))
def test1(self, equipe):
self.assertEqual(projet.choixPos(equipe.nbEquipe), [
(1, 2), (1, 0), (1, 7), (2, 0), (2, 3), (2, 4)])
@unittest.mock.patch('projet.equipe', nbEquipe=2)
@unittest.mock.patch('builtins.input', unittest.mock.MagicMock(side_effect=['-1', '1', '1', '2', '1', '0', '2', '4', '11',
'0', '11', '8', '11', '7', '10', '0', '10', '6', '10', '5', '20', '3', '10', '7']))
def test2(self, equipe):
self.assertEqual(projet.choixPos(equipe.nbEquipe), [
(11, 0), (11, 7), (10, 0), (10, 6), (10, 5), (10, 7)])