-
Notifications
You must be signed in to change notification settings - Fork 179
/
test.py
33 lines (22 loc) · 931 Bytes
/
test.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
import unittest
import script
class TestMain(unittest.TestCase): # inheriting TestCase class
def setUp(self): # this method will run before starting all the other test methods
print("Starting a method/test: ")
def test_add(self):
'''This is the info for this particular test'''
test_param = 10
result = script.add(test_param)
self.assertEqual(result,15)
def test_add2(self):
test_param = 'random string'
result = script.add(test_param)
self.assertTrue(isinstance(result,ValueError))
def tearDown(self): # this method will run after every test method. Generally used to reset/cleaning up data variables.
print("Cleaning up....")
class A:
print("\nClass A")
if __name__ == '__main__':
unittest.main() # this will run the entire classes present in the file
class B:
print("Class B")