-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path47-Test_assert.py
More file actions
32 lines (25 loc) · 784 Bytes
/
47-Test_assert.py
File metadata and controls
32 lines (25 loc) · 784 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
28
29
30
31
32
'''
author : Jaydatt Patel
syntax : assert expression, error statement
.assertEqual(a, b) a == b
.assertTrue(x) bool(x) is True
.assertFalse(x) bool(x) is False
.assertIs(a, b) a is b
.assertIsNone(x) x is None
.assertIn(a, b) a in b
.assertIsInstance(a, b) isinstance(a, b)
.assertNotIn(a, b) a not in b
.assertNotIsInstance(a,b) not isinstance(a, b)
.assertIsNot(a, b) a is not b
'''
def square(x):
return x*x
print('Test: square(10) == 100 ')
assert (square(10) == 100) , 'It should be 100'
print('Pass')
print('Test: square(10) == 101 ')
assert square(10) == 101 , 'It should be 100' # runtime error and terminate program
print('Pass')
print('Test: square(10) == 101 ')
assert square(10) == 101 , 'It should be 100' # runtime error and terminate program
print('Pass')