-
Notifications
You must be signed in to change notification settings - Fork 0
/
mytest.py
41 lines (32 loc) · 969 Bytes
/
mytest.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
34
35
36
37
38
39
40
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__date__= 'Oct 08, 2015 '
__author__= 'samuel'
from mynumber import MyNumber
import unittest
import random
class TestMyNumber(unittest.TestCase):
def setUp(self):
self.num = MyNumber()
def test_add(self):
x = random.randint(1,10)
y = random.randint(1,10)
result = self.num.add(x,y)
self.assertTrue(result == (x + y))
def test_sub(self):
x = random.randint(1,10)
y = random.randint(1,10)
result = self.num.sub(x,y)
self.assertTrue(result == (x - y))
def test_mul(self):
x = random.randint(1,10)
y = random.randint(1,10)
result = self.num.mul(x,y)
self.assertTrue(result == (x * y))
def test_div(self):
x = random.randint(1,10)
y = random.randint(1,10)
result = self.num.div(x,y)
self.assertTrue(result == (x / y))
def tearDown(self):
del self.num