def test_run_time_imports_do_not_add_edges_to_graph(tmp_path_factory):
    files = {
        'a.py':
        'x = 1',
        'b.py': ('''
            def f():
                import a
            '''),
    }
    with _test_package(tmp_path_factory, files) as package:
        import b
        b.f()
        assert not _dependency_graph.has_edge('b', 'a')
Ejemplo n.º 2
0
def main():
    print(f(42))
Ejemplo n.º 3
0
def main():
    for k in range(10): 
        print f(g(k))
    print A().h(8)
Ejemplo n.º 4
0
def main():
    print(f(-1))
Ejemplo n.º 5
0
def test(x):
    if x > 0:
        out = f()
    else:
        out = g()
    out.startswith('foo')  # pass
Ejemplo n.º 6
0
import b
c = b.f(2, 3)
print(c)
Ejemplo n.º 7
0
import b
from b import pi
#pi = 2

def g():
	global pi
	pi = 1
	return pi
g()
print(pi)

###defect 1:
#b.f()
#print(pi) #prints out 3.14 while we suppose 4.14

###solution:
##the only way is to use only ***b.pi*** instead of ***pi***
##to to modify variables on other modules from another modules.
b.f()
pi = pi + 10 #this has no effect on b.pi
#b.pi = 20 we can modify b.pi variable from main module too
#b.f() # but it is better to update b.pi variable from b module by b functions instead of main module directly
print(b.pi)

###defect 2:
##can not update global variable ***b.pi*** with a function.
#def h():
#	global b.pi
#	b.pi = 1
#	return pi
Ejemplo n.º 8
0
from b import f

print f("http://example.com/")
Ejemplo n.º 9
0
def g():
    return f()
Ejemplo n.º 10
0
x = 11          # x глобальна только для этого файла
import b        # получаем доступ к именам в модуле b
b.f()           # изменяет переменную b.x, но не х этого файла
print(x, b.x)   # 11 99
Ejemplo n.º 11
0
def f_usage():
    return f(14)
Ejemplo n.º 12
0
def f():
    b.init()
    c.init()
    b.f()
    c.f()
    return
Ejemplo n.º 13
0
def test(x):
    if x > 0:
        out = f()
    else:
        out = g()
    out.startswith('foo') # pass
Ejemplo n.º 14
0
import b
import c
import c.d
import c as x
import c.d as y
import b, c as z, c.d as w

b.func()
b.C()

from b import func
from b import func as f
from b import func as f, C
from b import *
from c import d
from c.d import v

func()
f()
C()
d

# from . import b as b_alias
# from . import *
from .b import func as g

g()
# b_alias.func()
Ejemplo n.º 15
0
import b
import c
import c.d
import c as x
import c.d as y
import b, c as z, c.d as w

b.func()
b.C()

from b import func
from b import func as f
from b import func as f, C
from b import *
from c import d
from c.d import v

func()
f()
C()
d

# from . import b as b_alias
# from . import *
from .b import func as g
g()
# b_alias.func()
Ejemplo n.º 16
0
Archivo: a.py Proyecto: lw1a2/test
#! /usr/bin/env python3

import b

if __name__ == "__main__":
    b.f()
Ejemplo n.º 17
0
def main():
    print(b.f(42))