예제 #1
0
 def test_returnsEmptyStringIfFileNotInPackage(self):
     try:
         # this doesnt have __init__.py file, so
         # isnt package
         os.makedirs("a")
         writeFile(os.path.join("a","foo.py"),"pass")
         pkg = bikefacade._deducePackageOfFile(os.path.join("a","foo.py"))
         assert pkg == ""
     finally:
         os.remove(os.path.join("a","foo.py"))
         os.removedirs(os.path.join("a"))
예제 #2
0
 def test_returnsEmptyStringIfFileNotInPackage(self):
     try:
         # this doesnt have __init__.py file, so
         # isnt package
         os.makedirs("a")
         writeFile(os.path.join("a", "foo.py"), "pass")
         pkg = bikefacade._deducePackageOfFile(os.path.join("a", "foo.py"))
         assert pkg == ""
     finally:
         os.remove(os.path.join("a", "foo.py"))
         os.removedirs(os.path.join("a"))
예제 #3
0
 def test_returnsNestedPackage(self):
     try:
         os.makedirs(os.path.join("a","b"))
         writeFile(os.path.join("a","__init__.py"),"# ")
         writeFile(os.path.join("a","b","__init__.py"),"# ")
         writeFile(os.path.join("a","b","foo.py"),"pass")
         pkg = bikefacade._deducePackageOfFile(os.path.join("a","b","foo.py"))
         assert pkg == "a.b"
     finally:
         os.remove(os.path.join("a","__init__.py"))
         os.remove(os.path.join("a","b","__init__.py"))
         os.remove(os.path.join("a","b","foo.py"))
         os.removedirs(os.path.join("a","b"))
예제 #4
0
 def test_returnsNestedPackage(self):
     try:
         os.makedirs(os.path.join("a", "b"))
         writeFile(os.path.join("a", "__init__.py"), "# ")
         writeFile(os.path.join("a", "b", "__init__.py"), "# ")
         writeFile(os.path.join("a", "b", "foo.py"), "pass")
         pkg = bikefacade._deducePackageOfFile(
             os.path.join("a", "b", "foo.py"))
         assert pkg == "a.b"
     finally:
         os.remove(os.path.join("a", "__init__.py"))
         os.remove(os.path.join("a", "b", "__init__.py"))
         os.remove(os.path.join("a", "b", "foo.py"))
         os.removedirs(os.path.join("a", "b"))