How to use the importlab.parsepy function in importlab

To help you get started, we’ve selected a few importlab examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google / importlab / tests / test_resolve.py View on Github external
def testResolveWithFilesystem(self):
        imp = parsepy.ImportStatement("a")
        r = self.make_resolver("b.py", "b")
        f = r.resolve_import(imp)
        self.assertTrue(isinstance(f, resolve.Local))
        self.assertEqual(f.fs, self.py_fs)
        self.assertEqual(f.path, "a.py")
        self.assertEqual(f.module_name, "a")
github google / importlab / tests / test_resolve.py View on Github external
def testResolveStarImport(self):
        # from foo.c import *
        imp = parsepy.ImportStatement("foo.c", is_from=True, is_star=True)
        r = self.make_resolver("x.py", "x")
        f = r.resolve_import(imp)
        self.assertEqual(f.path, "foo/c.py")
        self.assertEqual(f.module_name, "foo.c")
github google / importlab / tests / test_parsepy.py View on Github external
def test_multiple_4(self):
        self.assertEqual(self.parse("""
      import a
      import b
      import c
      import d
    """), [parsepy.ImportStatement(name='a'),
           parsepy.ImportStatement(name='b'),
           parsepy.ImportStatement(name='c'),
           parsepy.ImportStatement(name='d')])