#https://docs.python.org/3/py-modindex.html "Modules" #A file containing a set of functions you want to include in your application. #packages are collection of modules """We can define our most used functions in a module and import it, instead of copying their definitions into different programs.""" import Example #we want to create example.py module in local machine Example.add(4, 5) 'Or' from Example import add add(22, 2) import math #import statement access the definitions of it print("The value of pi is", math.pi) int(math.sqrt(9)) #renaming import math as m m.pi #We can import specific names from a module without importing the module as a whole. from math import pi math.pi #import all by *
def testAddPositiv(self): self.assertEqual(3, ex.add(1, 2))
def testAddWrongInput(self): self.assertRaises(TypeError, ex.add("a", "b"))
def mockExample(self, mock1, mock2): self.assertEqual(True, ex.returnFalse()) self.assertEqual(0, ex.add(100, 100))
def testAddNegative(self): self.assertEqual(-8, ex.add(-3, -5))