def test_add(self, steps, num1, num2): with steps.start('Add'): assert add(num1, num2) == num1 + num2 with steps.start('Result > 0'): try: assert add(num1, num2) > 0 except AssertionError: self.skipped('Result < 0)')
def main(): inventory = (calculation.load_from_file()) while True: userInput = input( "Choices:\n[H] for [H]elp on information how to Add or Sell items.\n[A] and amount to [A]dd.\n[S] and amount to [S]ell\n[L] to [L]ist current stock\n[x] for E[x]it.\nEnter command: " ) userInput = userInput.upper().split(',') #On exit show current stock and break if userInput[0] == "X": current_stock(inventory) print("Good bye !") break elif userInput[0] == "H": help() #Show current stock elif userInput[0] == "L": current_stock(inventory) #On Add stock call add function from calculation module elif userInput[0] == "A": inventory = calculation.add(userInput, inventory) # On Sell stock call sell function from calculation module elif userInput[0] == "S": inventory = calculation.sell(userInput, inventory) else: try_again() #Save current inventory situation for later use calculation.save_to_file(inventory)
def add_test(self, num1, num2): if add(num1, num2) < 0: self.skipped( 'Test is skipped because of the result of the add(num1, num2) less then 0.' ) else: self.passed( 'Test passed because another requirements is satisfied!')
def magic_calculation(a, b): from calculation import add return add(a, b) return a < b a + b = c for h in range(90): for w in range(4, 6): c + i = c
def test_add_with_zero(self): """Test that the addition of value with 0, returns the correct total""" result = calculation.add(5, 0) self.assertEqual(result, 5)
def test_add_less_zero(self): """Test that the addition of two values less than 0, returns the correct total""" result = calculation.add(-2, -4) self.assertEqual(result, -6)
def test_add(self): self.assertEqual(calculation.add(10, 5), 15)
def test_add(self): result = calculation.add(5,6) self.assertEqual(11, result)
import calculation a = int(input("Enter the first number: ")) b = int(input("Enter the second number: ")) print("\n Addition:",calculation.add(a,b)) print("\n Subtraction:",calculation.sub(a,b)) print("\n Multiplication",calculation.mult(a,b)) print("\n Division",calculation.div(a,b))
def test_add1(): assert(calculation.add(5,71), 76)
def test_add(): assert(calculation.add(5,7), 12)
def test_add(self, num1, num2): """"Test addition functionality.""" if add(num1, num2) < 0: self.failed( f'Test failed because result of adding {num1} and {num2} is less then 0' )
# import sys # sys.path.append("c:\\Python_modules") import calculation as calc r = calc.add(2, 3) r2 = calc.divide(4, 2) r3 = calc.mulply(2, 2) r4 = calc.subtract(4, 3) print(r, r2, r3, r4) print(dir(calc))
def test_add(self, steps, num1, num2): """Test 'add' func in calculation.py. Test will be skipped if result less then 0 and passed in other cases""" with steps.start('Result bigger or equal 0'): if add(num1, num2) < 0: self.skipped('Result is less then 0)')
def add(self, num1, num2): if add(num1, num2) < 0: self.failed('Result < 0)')
def test_add_more_zero(self): """Test that the addition of two values more than 0, returns the correct total""" result = calculation.add(4, 5) self.assertEqual(result, 9)
def test_add(self, num1, num2): """method for testing add function""" if add(num1, num2) < 0: self.skipped('Result of add is less then 0')
import calculation print(calculation.add(2, 3)) print(calculation.sub(7, 3))
#from calculation import add import calculation print(calculation.add(1,2))
def test_add(self, steps, num1, num2): """Test addition functionality.""" with steps.start(f'Addition of {num1} and {num2}'): if add(num1, num2) < 0: self.skipped(f'Test was skipped because result of adding {num1} and {num2} is less then 0')