forked from blksail-edu/python-refresher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_hello.py
29 lines (22 loc) · 854 Bytes
/
test_hello.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
import unittest
import hello
import math
class TestHello(unittest.TestCase):
def test_hello(self):
self.assertEqual(hello.hello(), "Hello, world!")
def test_sin(self):
self.assertEqual(hello.sin(0), 0)
self.assertNotEqual(hello.sin(0), 1)
self.assertAlmostEqual(hello.sin(1), 0.8414, 3)
self.assertAlmostEqual(hello.sin(1 + 2 * math.pi), 0.8414709848078965)
def test_cos(self):
self.assertEqual(hello.cos(0), 1)
self.assertEqual(hello.cos(1), 0.5403023058681398)
def test_tan(self):
self.assertEqual(hello.tan(0), 0)
self.assertEqual(hello.tan(1), 1.5574077246549023)
def test_cot(self):
self.assertEqual(hello.cot(0), float("inf"))
self.assertEqual(hello.cot(1), 0.6420926159343306)
if __name__ == "__main__":
unittest.main()