예제 #1
0
 def testAdd(self):
     self.assertEqual(11, add(5, 6))
예제 #2
0
 def test_add(self):
     result = calculations.add(10, 5)
     self.assertEqual(result, 15)
예제 #3
0
## IF WE WANT WE CAN ALSO JUST IMPORT THE SPECIFIC FUNCTIONS FROM A FILE
## FOR EXAMPLE

from calculations import add
print(add(4, 5))  ##EXPECTED OUTPUT 9
예제 #4
0
def test_add_string():
    assert calculations.add('Hello', ' world!') == 'Hello world!'
    assert type(calculations.add('Hello', ' world!')) is str
예제 #5
0
def test_add():
    assert calculations.add(3, 3) == 6
    assert calculations.add(7) == 10
    assert calculations.add(9, 9) == 18
예제 #6
0
import calculations as cal   # WE IMPORT THE CALCLATIONS.PY FILE
                             # CAL is the variable name we assigned to the file object 

#=======================================================================================================================================
##   TO USE VARIABLES AND FUNCTIONS OF THE FILE WE FIRST HAVE TO WRITE THE VARIABLE NAME STORING THE FILE OBJECT
##   FOLLOWED BY '.' AND THE FUNCTIONS OR THE VARIABLE WHICH WE WANT TO USE 
#=======================================================================================================================================

num = 20

print(f'The value of num is {num}')  #this should print 20
print(f'The value of cal.num is {cal.num}') #this should print 10


print(cal.add(4,5))          # WE CALL ADD METHOD OF THE FILE OBJECT           
print(cal.mul(4,5))          # WE CALL MUL METHOD OF THE FILE OBJECT 
print(cal.sub(4,5))          # WE CALL SUB METHOD OF THE FILE OBJECT 

예제 #7
0
import calculations as calc

print(calc.add(10,30))
print(calc.multiply(10,30))
예제 #8
0
def test_add2():
    assert calculations.add('Hello', 'Du')=='HelloDu';
    assert calculations.add(10,10)==200;
예제 #9
0
def test_add1():
    assert calculations.add(1,2)==3;
    assert calculations.add(3,4)==7;
예제 #10
0
import calculations
a = int(input('enter first number = '))
b = int(input('enter second number = '))
c = calculations.add(a,b)
print(c)