Prune actual file paths from test/testPackageImports.krk

This commit is contained in:
K. Lange 2021-01-31 11:13:21 +09:00
parent 8388e53235
commit 0b6b6468a6
2 changed files with 25 additions and 20 deletions

View File

@ -1,6 +1,11 @@
def printPackage(p):
let s = repr(p)
let a,b,c,d = s.split(' ')
print(' '.join([a,b,c]),'...>')
def testTop():
import foo
print(foo)
printPackage(foo)
try:
print(foo.bar, "Fail")
except:
@ -8,23 +13,23 @@ def testTop():
def testCaching():
from foo.bar import baz
print(baz)
printPackage(baz)
import foo
print(foo)
print(foo.bar)
print(foo.bar.baz)
printPackage(foo)
printPackage(foo.bar)
printPackage(foo.bar.baz)
print(foo.bar.baz.qux)
def testDirect():
import foo.bar.baz
print(foo)
print(foo.bar)
print(foo.bar.baz)
printPackage(foo)
printPackage(foo.bar)
printPackage(foo.bar.baz)
print(foo.bar.baz.qux)
def testFromImport():
from foo.bar import baz
print(baz)
printPackage(baz)
print(baz.qux)
try:
print(foo, "Fail")
@ -33,7 +38,7 @@ def testFromImport():
def testRenames():
import foo.bar.baz as blah
print(blah)
printPackage(blah)
print(blah.qux)
try:
print(foo, "Fail")

View File

@ -1,21 +1,21 @@
Imported foo.__init__ as foo
<module 'foo' from './modules/foo/__init__.krk'>
<module 'foo' from ...>
AttributeError: 'module' object has no attribute 'bar'
Imported bar.__init__ as foo.bar
imported baz.krk as foo.bar.baz
<module 'foo.bar.baz' from './modules/foo/bar/baz.krk'>
<module 'foo' from './modules/foo/__init__.krk'>
<module 'foo.bar' from './modules/foo/bar/__init__.krk'>
<module 'foo.bar.baz' from './modules/foo/bar/baz.krk'>
<module 'foo.bar.baz' from ...>
<module 'foo' from ...>
<module 'foo.bar' from ...>
<module 'foo.bar.baz' from ...>
This is it!
<module 'foo' from './modules/foo/__init__.krk'>
<module 'foo.bar' from './modules/foo/bar/__init__.krk'>
<module 'foo.bar.baz' from './modules/foo/bar/baz.krk'>
<module 'foo' from ...>
<module 'foo.bar' from ...>
<module 'foo.bar.baz' from ...>
This is it!
<module 'foo.bar.baz' from './modules/foo/bar/baz.krk'>
<module 'foo.bar.baz' from ...>
This is it!
NameError: Undefined variable 'foo'.
<module 'foo.bar.baz' from './modules/foo/bar/baz.krk'>
<module 'foo.bar.baz' from ...>
This is it!
NameError: Undefined variable 'foo'.
This is it!