Ejemplo n.º 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"))
Ejemplo n.º 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"))
Ejemplo n.º 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"))
Ejemplo n.º 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"))