-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathles_45_runner.py
42 lines (31 loc) · 922 Bytes
/
les_45_runner.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
import unittest
class Runner:
def __init__(self, name):
self.name = name
self.distance = 0
def run(self):
self.distance += 10
def walk(self):
self.distance += 5
def __str__(self):
return self.name
class RunnerTest(unittest.TestCase):
def test_walk(self):
_walk = Runner("Test runner")
for i in range(10):
_walk.walk()
self.assertEqual(_walk.distance, 50)
def test_run(self):
_run = Runner("Test runner")
for i in range(10):
_run.run()
self.assertEqual(_run.distance, 100)
def test_challenge(self):
runner1 = Runner("Test runner")
runner2 = Runner("Test runner2")
for i in range(10):
runner1.run()
runner2.walk()
self.assertNotEqual(runner1.distance, runner2.distance)
if __name__ == "__main__":
unittest.main()