예제 #1
0
 def testImportFromMultiple(self):
     imp1 = util.Import('foo.bar')
     imp1.add_binding(util.Import.MODULE, 'bar', util.Import.LEAF)
     imp2 = util.Import('foo.baz')
     imp2.add_binding(util.Import.MODULE, 'baz', util.Import.LEAF)
     self._assert_imports_equal(
         [imp1, imp2], self._visit_import('from foo import bar, baz'))
예제 #2
0
 def testImportMultiple(self):
     imp1 = util.Import('foo')
     imp1.add_binding(util.Import.MODULE, 'foo', util.Import.ROOT)
     imp2 = util.Import('bar')
     imp2.add_binding(util.Import.MODULE, 'bar', util.Import.ROOT)
     self._assert_imports_equal([imp1, imp2],
                                self._visit_import('import foo, bar'))
예제 #3
0
 def testImportFromNativeAs(self):
     imp = util.Import('fmt', is_native=True)
     imp.add_binding(util.Import.MEMBER, 'foo', 'Printf')
     self._assert_imports_equal(
         imp, self._visit_import('from __go__.fmt import Printf as foo'))
예제 #4
0
 def testImportFromAs(self):
     imp = util.Import('foo.bar')
     imp.add_binding(util.Import.MODULE, 'baz', util.Import.LEAF)
     self._assert_imports_equal(
         imp, self._visit_import('from foo import bar as baz'))
예제 #5
0
 def testImportAs(self):
     imp = util.Import('foo')
     imp.add_binding(util.Import.MODULE, 'bar', util.Import.LEAF)
     self._assert_imports_equal(imp,
                                self._visit_import('import foo as bar'))
예제 #6
0
 def testImport(self):
     imp = util.Import('foo')
     imp.add_binding(util.Import.MODULE, 'foo', util.Import.ROOT)
     self._assert_imports_equal(imp, self._visit_import('import foo'))