[Python-checkins] python/dist/src/Lib/test test_import.py, 1.15.2.2, 1.15.2.3

jhylton@users.sourceforge.net jhylton at users.sourceforge.net
Fri Oct 14 22:06:17 CEST 2005


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5863/Lib/test

Modified Files:
      Tag: ast-branch
	test_import.py 
Log Message:
Fix two dotted import problems uncovered by zope test suite

The symbol table did not handle dots in import names.  If you imported
"a.b.c", it would put "a.b.c" in the symbol table instead of "a".

The compiler did not generate the correct code for "import a.b.c as
d".  It bound a to d instead of c to d.

Add very simple tests cases to test_import to cover these failures.



Index: test_import.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_import.py,v
retrieving revision 1.15.2.2
retrieving revision 1.15.2.3
diff -u -d -r1.15.2.2 -r1.15.2.3
--- test_import.py	7 Jan 2005 06:59:09 -0000	1.15.2.2
+++ test_import.py	14 Oct 2005 20:06:13 -0000	1.15.2.3
@@ -192,3 +192,16 @@
             del sys.modules[TESTFN]
 
 test_failing_reload()
+
+def test_import_name_binding():
+    # import x.y.z binds x in the current namespace
+    import test as x
+    import test.test_support
+    assert x is test, x.__name__
+    assert hasattr(test.test_support, "__file__")
+
+    # import x.y.z as w binds z as w
+    import test.test_support as y
+    assert y is test.test_support, y.__name__
+
+test_import_name_binding()



More information about the Python-checkins mailing list