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"))
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"))
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"))
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"))