Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
 def test_is_even_positive(self):
     """
     This method is used to test even or odd functionality
     """
     my_number = MyNumber()  # Arrange
     result = my_number.is_even(10)  # Action
     self.assertEqual(result, True)  # Assert
Exemplo n.º 4
0
 def test_is_even_negative(self):
     """
     This will test the is_even method with odd value
     """
     my_number = MyNumber()
     result = my_number.is_even(11)
     self.assertEqual(result, False)
Exemplo n.º 5
0
def test_gets():
    count = 1000
    numbers = MyNumber.gets(count)
    assert len(numbers) == count

    for num in numbers:
        print num
        assert MyNumber.validate(num), num
Exemplo n.º 6
0
def test_iter():
    ct = 1
    for m in MyNumber():
        ct += 1
        assert MyNumber.validate(m), m
        if ct > 1000:
            return
    raise
Exemplo n.º 7
0
def test_validate():
    num_group = [
        123456789018,
        190852597007,
        664559681879,
        317115269465,
        636234891610,
        759492641118,
        653148356959,
        712502608231,
        845344637296,
        626150900081,
        250059391352,
        220009988475,
        518472892796,
        971973656959,
        142943093120,
        661945516417,
        275391807883,
        422468354448,
        345381273668,
        282612367782,
        993274102186,
        101951472043,
        288204947884,
        459810701741,
        673630519726,
        428367052872,
        656861725106,
        559958524339,
        727514382775,
        858986774968,
        633284231620,
        457474026230,
    ]

    for num in num_group:
        assert MyNumber.validate(num), MyNumber.validate(num)
Exemplo n.º 8
0
def test_divide():
    num = 123456789018
    inspection, check_sum = MyNumber.divide(num)
    assert inspection == 10987654321
    assert check_sum == 8
Exemplo n.º 9
0
 def setUp(self):
     self.num = MyNumber()
Exemplo n.º 10
0
 def setUp(self):
     self.num = MyNumber()
Exemplo n.º 11
0
 def test_is_even_negative_boundary(self):
     my_number = MyNumber()
     result = my_number.is_even('hello')