Exemple #1
0
 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)
Exemple #2
0
 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)
Exemple #3
0
 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)
Exemple #4
0
 def testResolveImportEmptyPath(self):
     path = imputil.Path(None, 'foo', 'foo.py')
     self.assertEqual(path.resolve_import('bar'), (None, None))
Exemple #5
0
 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)