forked from hombit/scientific_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
27 lines (22 loc) · 665 Bytes
/
tests.py
File metadata and controls
27 lines (22 loc) · 665 Bytes
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
import unittest
import numpy as np
def is_even(n):
if int(n) != n:
raise ValueError('Argument should be integer')
return n % 2 == 0
class MyTest(unittest.TestCase):
def test_true(self):
self.assertTrue(True)
class IsEvenTest(unittest.TestCase):
def test_even(self):
self.assertTrue(is_even(10))
def test_odd(self):
self.assertFalse(is_even(7))
def test_float(self):
with self.assertRaises(ValueError):
is_even(3.14)
class FactorialTest(unittest.TestCase):
def test_dactorial(self):
self.assertEqual(120, np.math.factorial(5))
if __name__ == '__main__':
unittest.main()