# HG changeset patch # User Paul Boddie # Date 1479071909 -3600 # Node ID b7860ad65334408782d9e9023227095fd0073ecc # Parent fc5056a50cba44ef4520aa1f5c0413f6642287d5 Added some tests of "from" importing. diff -r fc5056a50cba -r b7860ad65334 tests/from_import/another.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/from_import/another.py Sun Nov 13 22:18:29 2016 +0100 @@ -0,0 +1,7 @@ +class C: + d = 123 + +c = C() + +def f(): + return c diff -r fc5056a50cba -r b7860ad65334 tests/from_import/main.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/from_import/main.py Sun Nov 13 22:18:29 2016 +0100 @@ -0,0 +1,17 @@ +from another import f, c + +def function(): + return c + +def fn(): + return f() + +def altname(): + c = fn() + return c + +d = c.d +e = function().d +g = f().d +h = fn().d +i = altname().d diff -r fc5056a50cba -r b7860ad65334 tests/from_import_redefine_bad/another.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/from_import_redefine_bad/another.py Sun Nov 13 22:18:29 2016 +0100 @@ -0,0 +1,7 @@ +class C: + d = 123 + +c = C() + +def f(): + return c diff -r fc5056a50cba -r b7860ad65334 tests/from_import_redefine_bad/main.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/from_import_redefine_bad/main.py Sun Nov 13 22:18:29 2016 +0100 @@ -0,0 +1,15 @@ +from another import f, c, C + +def function(): + return c + +def fn(): + return f() + +def f(): # would redefine f from another + return c + +d = c.d +e = function().d +g = f().d +h = fn().d diff -r fc5056a50cba -r b7860ad65334 tests/from_import_replace_bad/another.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/from_import_replace_bad/another.py Sun Nov 13 22:18:29 2016 +0100 @@ -0,0 +1,7 @@ +class C: + d = 123 + +c = C() + +def f(): + return c diff -r fc5056a50cba -r b7860ad65334 tests/from_import_replace_bad/main.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/from_import_replace_bad/main.py Sun Nov 13 22:18:29 2016 +0100 @@ -0,0 +1,14 @@ +from another import f, c, C + +def function(): + return c + +def fn(): + return f() + +d = c.d +c = C() # would replace c from another +e = function().d +f = function # would replace f from another +g = f().d +h = fn().d