Esempio n. 1
0
 def testMult(self):
     self.assertEqual(calc.mult(1, 2), 2)
     self.assertEqual(calc.mult(10, 10), 100)
Esempio n. 2
0
 def test_mult(self):
     result = calc.mult(4,3)
     self.assertEqual(result,12)
 def test_mul2(self):
     self.assertEqual(1.2, calc.mult(12, 0.1))
Esempio n. 4
0
def test_check_multiply():
    assert mult(6, 10) == 60
Esempio n. 5
0
def test_multiplication_of_simple_numbers():
    assert (calc.mult(1, 1) == 1)
    assert (calc.mult(2, 4) == 8)
    assert (calc.mult(4, -3) == -12)
 def test_mul_string(self):
     self.assertEqual('Invalid input', calc.mult(1, '1'))
Esempio n. 7
0
 def test_mult(self):
     self.assertEqual(calc.mult(3, 8), 24)
Esempio n. 8
0
#creating ur own modules in file calc.py
print(__name__)
import calc as c
print(__name__)
print(c.add(2,3))
print(c.sub(4,3))
print(c.mult(11,3))
print(c.div(9,3))

import calc
print(__name__)         #name varible in main code prints main if name varible is mentioned
                        #in imported module in main program it prints name of module
Esempio n. 9
0
 def test_mult(self):
     result = calc.mult(10, 5)
     self.assertEqual(result, 50)
Esempio n. 10
0
# archivo que contiene codigo PY, permite reutilizar codigo de distintos proyectos
# from calc import *
from calc import (suma, resta, div, mult)
# el nombre del modulo = nombre de archivo para importar (no haria falta poner el llamado al modulo)
resta = resta(10, 2)
print(resta)

mult = mult(10, 2)
print(mult)

div = div(10, 2)
print(div)

# se le pueden poner alias -> from calc import suma as ALIAS
Esempio n. 11
0
 def test_mult(self):
     self.assertEqual(calc.mult(10, 5), 50)
def test_mult():
    assert calc.mult(2, 3) == 6
    assert calc.mult(2, 0) == 0
Esempio n. 13
0
from calc import soma, sub, mult

print(soma(3, 3), sub(3, 3), mult(3, 3))
Esempio n. 14
0
import calc

if __name__ == "__main__":
    print(calc.mult(2, 3))
    a = [2, 5, 68, 9, 12, 34]
    print(a[0:4])
Esempio n. 15
0
import calc

a = int(input("Enter first number: "))

b = int(input("Enter second number: "))

c = str(input("What are we going to do today?: "))

if c == "addition":
    print(calc.plus(a, b))

if c == "subtraction":
    print(calc.minus(a, b))

if c == "multiolication":
    print(calc.mult(a, b))
Esempio n. 16
0
            print request
            (App, rest) = self.select(request)
            parsedRequest = App.parse(request, rest)
            (returnCode, Answer) = App.process(parsedRequest)
            print 'Answering...'
            recvSocket.send("HTTP/1.1 " + returnCode + " \r\n\r\n" + Answer +
                            "\r\n")
            recvSocket.close()


if __name__ == "__main__":
    anApp = app()
    otherApp = app()
    suma = calc.plus()
    resta = calc.subtract()
    multi = calc.mult()
    div = calc.div()
    testWebApp = webApp(
        "localhost", 1234, {
            '/app': anApp,
            '/other': otherApp,
            '/suma': suma,
            '/+': suma,
            '/resta': resta,
            '/-': resta,
            '/mult': multi,
            '/x': multi,
            '/div': div,
            '/:': div
        })
Esempio n. 17
0
 def test_M(self):
     result = calc.mult(5, 6)
     self.assertEqual(result, 30)
Esempio n. 18
0
# archivo que contiene codigo PY, permite reutilizar codigo de distintos proyectos
import calc
# el nombre del modulo = nombre de archivo para importar
resta = calc.resta(10, 2)
print(resta)

mult = calc.mult(10, 2)
print(mult)

div = calc.div(10, 2)
print(div)

div = calc.div(10, 2)
print(div)
Esempio n. 19
0
 def test_should_return_two_values_mult(self):
     esperado = 1 * 2
     self.assertEqual(esperado, mult(1, 2))
def test_mult(a, b, x):
    assert mult(a, b) == x
Esempio n. 21
0
# 第13章 模块
# python中可通过import与from...import...这两种方式导入文件
# import test
# test.test()
# print(test.a)

# from test import test
# test()

# 模块搜索路径
import sys
print(sys.path)

# python模块的开头通常会定义一个__all__属性,确定了from...import *语句导入的内容
from calc import *
from calc import mult
print(add(3, 4))
print(mult(3, 4))

# python中的包
# import package.module
# 包中的__init__.py文件的功能与模块文件中的__all__属性的功能相同

# 第13章 模块完结,python初级部分完结
# TODO: python高级部分 第17章 多线程编程 第18章网络编程 第19章 数据库编程 第20章 web编程
# TODO: 测试需要 第15章 正则表达式 第16章图形用户界面编程
# TODO: 了解python内存划分 第14章 内存管理
 def test_mul_string_2(self):
     self.assertEqual('Invalid input', calc.mult('1', 1))
Esempio n. 23
0
 def test_mult(self):
     self.assertEqual(calc.mult(10, 5), 50)
     self.assertEqual(calc.mult(-1, 1), -1)
     self.assertEqual(calc.mult(-1, -1), 1)
 def test_div_double_negative(self):
     self.assertEqual(1, calc.mult(-1, -1))
Esempio n. 25
0
def test_mult():
	
	assert mult(5, 5) == 25
	assert mult(3, 3) == 9
Esempio n. 26
0
 def test_mult(self):
     self.assertEqual(calc.mult(10, 5), 50)
     self.assertEqual(calc.mult(-2, 2), -4)
     self.assertEqual(calc.mult(-2, -3), 6)
Esempio n. 27
0
 def test_mult(self):
     self.assertEqual(calc.mult(10, 5), 50)
     self.assertEqual(calc.mult(-1, 5), -5)  # edge caases
     self.assertEqual(calc.mult(-5, -3), 15)  # edge cases
Esempio n. 28
0
 def test_mult(self):
     self.assertEqual(calc.mult(10.2, 4.2), 42.839999999999996)
     self.assertEqual(calc.mult(-1, 1), -1)
     self.assertEqual(calc.mult(1.1, 1.5), 1.6500000000000001)
     self.assertEqual(calc.mult(0, 1.5), 0)
Esempio n. 29
0
def test_muliplication():
    assert calc.mult(1, 2) == 2
Esempio n. 30
0
 def test_mult_fail(self):
     result = calc.mult(4,3)
     self.assertEqual(result,7)
 def test_mul(self):
     self.assertEqual(12, calc.mult(3, 4))
 def test_mult_2arg(self):
     # Make sure 4 * 3 = 12
     self.assertEqual(mult(4, 3), 12, 'multiplying three and four')
 def test_mul_float(self):
     self.assertEqual(6.25, calc.mult(2.5, 2.5))
Esempio n. 34
0
	def test_calc_mult(self):
		result = calc.mult(self.a, self.b)
		self.assertEqual(result, self.a * self.b)
 def test_mul_commutative(self):
     self.assertEqual(calc.mult(2, 1), calc.mult(1, 2))
Esempio n. 36
0
 def test_mult(self):
     self.assertEqual(calc.mult(5, 2), 10)
 def test_mul_associative(self):
     self.assertEqual(calc.mult(2, calc.mult(3, 4)), calc.mult(calc.mult(2, 3), 4))
Esempio n. 38
0
 def test_mult(self):
     result = calc.mult(5, 5)
     self.assertEqual(result, 25)
 def test_mul_negative(self):
     self.assertEqual(-1, calc.mult(1, -1))
Esempio n. 40
0
def test_multiplication_of_simple_numbers():
    assert (calc.mult(1, 'd4') in range(1, 5))
    assert (calc.mult(2, 'd4') in range(2, 9))
    assert (calc.mult('d8', -3) in range(-24, -2))
Esempio n. 41
0
            (recvSocket, address) = mySocket.accept()
            print 'HTTP request received (going to process):'
            request = recvSocket.recv(2048)
            print request
            (App, rest) = self.select(request)
            parsedRequest = App.parse(request, rest)
            (returnCode, Answer) = App.process(parsedRequest)
            print 'Answering...'
            recvSocket.send("HTTP/1.1 " + returnCode + " \r\n\r\n"
                            + Answer + "\r\n")
            recvSocket.close()

if __name__ == "__main__":
    anApp = app()
    otherApp = app()
    suma = calc.plus()
    resta = calc.subtract()
    multi = calc.mult()
    div = calc.div()
    testWebApp = webApp("localhost", 1234, {'/app': anApp,
					    '/other': otherApp,
					    '/suma': suma,
					    '/+' :suma,
                                            '/resta': resta,
					    '/-' : resta,
					    '/mult' : multi,
                                            '/x': multi,
                                            '/div': div,
					    '/:' : div})