コード例 #1
0
 def test_returnsParentDirectoryIfFileNotInPackage(self):
     try:
         # this doesnt have __init__.py file, so
         # isnt package
         os.makedirs("a")
         writeFile(os.path.join("a", "foo.py"), "pass")
         dir = loadmodule.getRootDirectory(os.path.join("a", "foo.py"))
         assert dir == "a"
     finally:
         os.remove(os.path.join("a", "foo.py"))
         os.removedirs(os.path.join("a"))
コード例 #2
0
 def test_returnsDirIfDirIsTheRootDirectory(self):
     try:
         os.makedirs(os.path.join("root", "a", "b"))
         writeFile(os.path.join("root", "a", "__init__.py"), "# ")
         writeFile(os.path.join("root", "a", "b", "__init__.py"), "# ")
         writeFile(os.path.join("root", "a", "b", "foo.py"), "pass")
         dir = loadmodule.getRootDirectory("root")
         assert dir == "root"
     finally:
         os.remove(os.path.join("root", "a", "__init__.py"))
         os.remove(os.path.join("root", "a", "b", "__init__.py"))
         os.remove(os.path.join("root", "a", "b", "foo.py"))
         os.removedirs(os.path.join("root", "a", "b"))
コード例 #3
0
 def test_returnsFirstNonPackageParentDirectoryIfPathIsAPackage(self):
     try:
         os.makedirs(os.path.join("root", "a", "b"))
         writeFile(os.path.join("root", "a", "__init__.py"), "# ")
         writeFile(os.path.join("root", "a", "b", "__init__.py"), "# ")
         writeFile(os.path.join("root", "a", "b", "foo.py"), "pass")
         dir = loadmodule.getRootDirectory(os.path.join("root", "a", "b"))
         assert dir == "root"
     finally:
         os.remove(os.path.join("root", "a", "__init__.py"))
         os.remove(os.path.join("root", "a", "b", "__init__.py"))
         os.remove(os.path.join("root", "a", "b", "foo.py"))
         os.removedirs(os.path.join("root", "a", "b"))