def testResolveImportPackageModuleAbsolute(self): spec = { 'bar/': { '__init__.py': None, 'baz.py': None, } } with _MaterializedPathTree(spec) as tree: path = imputil.Path(tree.rootdir, 'foo', 'foo.py') want = ('bar.baz', os.path.join(tree.pydir, 'bar', 'baz.py')) self.assertEqual(path.resolve_import('bar.baz'), want)
def testResolveImportPackageModuleRelative(self): spec = { 'bar/': { '__init__.py': None, 'baz.py': None, }, 'baz.py': None, } with _MaterializedPathTree(spec) as tree: bar_script = os.path.join(tree.pydir, 'bar', '__init__.py') path = imputil.Path(tree.rootdir, 'bar', bar_script, False) want = ('bar.baz', os.path.join(tree.pydir, 'bar', 'baz.py')) self.assertEqual(path.resolve_import('baz'), want)
def testResolveImportTopLevelPackage(self): with _MaterializedPathTree({'bar/': {'__init__.py': None}}) as tree: path = imputil.Path(tree.rootdir, 'foo', 'foo.py') want = ('bar', os.path.join(tree.pydir, 'bar', '__init__.py')) self.assertEqual(path.resolve_import('bar'), want)
def testResolveImportEmptyPath(self): path = imputil.Path(None, 'foo', 'foo.py') self.assertEqual(path.resolve_import('bar'), (None, None))
def testResolveImportTopLevelModule(self): with _MaterializedPathTree({'bar.py': None}) as tree: path = imputil.Path(tree.rootdir, 'foo', 'foo.py', False) want = ('bar', os.path.join(tree.pydir, 'bar.py')) self.assertEqual(path.resolve_import('bar'), want)