Exemplo n.º 1
0
 def test_subtract_non_int_non_float_exception(self):
     """
     Validates that an exception raises when subtracting a non float
         or int
     """
     data_sets = [[], '', {}]
     for data_set in data_sets:
         with self.assertRaises(TypeError):
             calculator.subtract(data_set, data_set)
def main():
    """
        This function is used to execute the module as a standalone
        module.
    """
    parser = argparse.ArgumentParser()
    group1 = parser.add_argument_group()
    group2 = parser.add_mutually_exclusive_group(required=True)

    group1.add_argument('x',
                        help='The first value in the equation',
                        type=check_type)
    group1.add_argument('y',
                        help='The second value in the equation',
                        type=check_type)
    group2.add_argument('--add', action='store_true')
    group2.add_argument('--subtract', action='store_true')
    group2.add_argument('--multiply', action='store_true')
    group2.add_argument('--divide', action='store_true')
    group2.add_argument('--modulus', action='store_true')

    args = parser.parse_args()

    if args.add:
        print(add(args.x, args.y))
    if args.subtract:
        print(subtract(args.x, args.y))
    if args.multiply:
        print(multiply(args.x, args.y))
    if args.divide:
        print(divide(args.x, args.y))
    if args.modulus:
        print(modulus(args.x, args.y))
Exemplo n.º 3
0
 def test_subtract_numbers(self):
     self.assertEqual(subtract(5, 11), 6)
Exemplo n.º 4
0
 def test_subtract_float_and_integer_subtraction(self):
     """Validates that subtract yields the expected flotation results"""
     self.assertEqual(calculator.subtract(10.0, 6), 4.0)
Exemplo n.º 5
0
 def test_subtract_integer_subtraction(self):
     """Validates that subtract yields the expected integer results"""
     self.assertEqual(calculator.subtract(10, 6), 4)
Exemplo n.º 6
0
 def test_subtract_numbers(self):
     """Test that values are subtracted and returned"""
     self.assertEqual(subtract(5, 11), 6)
Exemplo n.º 7
0
 def test_sub(self):
     assert 5 == calculator.subtract(10, 5)
Exemplo n.º 8
0
 def test_subtract(self):
     assert 0 == calc.subtract(5, 5)