Ejemplo n.º 1
0
def test1():
    with patch("module1.function1") as mocked_function:
        mocked_function.return_value = "*mocked*"

        print("*** test1 ***")
        value = module1.function1()
        print("function1 returns: {v}".format(v=value))
        print("mocked function called: {c}".format(c=mocked_function.called))
Ejemplo n.º 2
0
def test1():
    with patch("module1.function1", return_value="*mocked"):
        print("*** test1 ***")
        value = module1.function1()
        print("function1 returns: {v}".format(v=value))
Ejemplo n.º 3
0
import module1 as m1
import module2
from module3 import function5

m1.function1()
m1.function2()

module2.function3()
module2.function4()

print(m1.p_var)
print(m1.mylist)

function5()
Ejemplo n.º 4
0
import module1

print('revoke')
module1.function1()
Ejemplo n.º 5
0
'''
Created on Feb 9, 2020

@author: Bishwajit.
'''
'''
Modules
    Group of instructions or function.
    Every python file itself is a module.
    We can use properties of one module into another.
Import
    Normal import
        entire python file or module is imported.
        module name is used to access the properties of that module
        we can create alias name for the module.
    From import
       We can import required properties of a module.
       we access the properties of the module without using the module name. 
Built-in-Module
    Predefined modules in python.
'''
import module1 as mod1
mod1.function1()
print(mod1.a)

from module2 import a
print(a)

import math
print("SQRT of 10 : ", math.sqrt(100))
Ejemplo n.º 6
0
    n_record['number'] = number
    for v, k in record.items():
        n_record[v] = k
    return n_record


def merge2(number, **record):
    n_record = {}
    n_record['number'] = number
    for v, k in record.items():
        n_record[v] = k
    return n_record


record_dic = merge(2, w_dic)
print(record_dic)

record_dic2 = merge2(2, name='xiaoming', phone='18742241111')
print(record_dic2)

# 8.6 import module and function

module.studing()
module.overprint(3)

function3()
function1()

f4()
# from module import *         --- means import all functions
Ejemplo n.º 7
0
def test1(mocked_function):
    print("*** test1 ***")
    value = module1.function1()
    print("function1 returns: {v}".format(v=value))
Ejemplo n.º 8
0
def function2():
    function1_result = function1()
    return 2 * function1_result