updated/added import test (nested structures)

This commit is contained in:
David Halter
2012-08-02 13:49:40 +02:00
parent ffa736264e
commit 24f81ea75c
6 changed files with 60 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import evaluate
import modules
import debug
import imports
import os
class NotFoundError(Exception):
@@ -122,7 +123,10 @@ class Definition(object):
elif isinstance(d, (evaluate.Function, evaluate.parsing.Function)):
d = 'def ' + str(d.name)
elif isinstance(d, evaluate.parsing.Module):
d = 'module ' + str(d.path)
p = str(d.path)
# only show module name
p = re.sub(r'^.*?([\w\d]+)(/__init__)?.py$', r'\1', p)
d = 'module ' + p
else:
d = d.get_code().replace('\n', '')
return d

View File

@@ -67,3 +67,18 @@ def c():
c
#! 0 ['def c']
c()
# -----------------
# imports
# -----------------
#! ['module import_tree']
import import_tree
#! ['module mod1']
import import_tree.mod1
#! ['module mod1']
from import_tree import mod1

View File

@@ -0,0 +1 @@
a = ""

View File

@@ -0,0 +1 @@
a = 1

View File

@@ -1,3 +1,39 @@
# -----------------
# own structure
# -----------------
# do separate scopes
def scope_basic():
from import_tree import mod1
#? int()
mod1.a
#? []
import_tree.a
#? []
import_tree.mod1
import import_tree
#? str()
import_tree.a
#? []
import_tree.mod1
def scope_nested():
import import_tree.mod1
#? str()
import_tree.a
#? ['mod1']
import_tree.mod1
#? int()
import_tree.mod1.a
# -----------------
# std lib modules
# -----------------

View File

@@ -2,8 +2,9 @@ import pylab
pylab.
# two gotos
#! ['module /usr/lib/python2.7/dist-packages/numpy/__init__.py']
#! ['module numpy']
import numpy
#! ['module random']
import numpy.random