forked from uservidya/Python-buildsample
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsample.py
More file actions
37 lines (27 loc) · 684 Bytes
/
sample.py
File metadata and controls
37 lines (27 loc) · 684 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
33
34
35
36
37
import unittest
# Here's our "unit".
def my_partial_fn(x): # line 1
if x: # 2
y = 11 # 3
return y # 4
def IsEven(n):
if n % 2 == 0:
return True
else:
return False
def IsOdd(n):
return n % 2 == 1
# Here's our "unit tests".
class IsOddTests(unittest.TestCase):
def testOne(self):
self.failUnless(IsOdd(1))
def testTwo(self):
self.failIf(IsOdd(2))
def testThree(self):
self.failIf(IsEven(1))
def testFour(self):
self.failUnless(my_partial_fn(1));
def main():
unittest.main()
if __name__ == '__main__':
main()