def test_resolve_local(self): origpath = os.getcwd() os.chdir(os.path.join(get_data(""))) def norm(uri): if onWindows(): return uri.lower() else: return uri try: root = Path.cwd() rooturi = root.as_uri() self.assertEqual(norm(rooturi+"/tests/echo.cwl"), norm(resolve_local(None, os.path.join("tests", "echo.cwl")))) self.assertEqual(norm(rooturi+"/tests/echo.cwl#main"), norm(resolve_local(None, os.path.join("tests", "echo.cwl")+"#main"))) self.assertEqual(norm(rooturi+"/tests/echo.cwl"), norm(resolve_local(None, str(root / "tests" / "echo.cwl")))) self.assertEqual(norm(rooturi+"/tests/echo.cwl#main"), norm(resolve_local(None, str(root / "tests" / "echo.cwl")+"#main"))) finally: os.chdir(origpath)
def test_resolve_local(self): origpath = os.getcwd() os.chdir(os.path.join(get_data(""))) def norm(uri): if onWindows(): return uri.lower() else: return uri try: root = Path.cwd() rooturi = root.as_uri() self.assertEqual( norm(rooturi + "/tests/echo.cwl"), norm(resolve_local(None, os.path.join("tests", "echo.cwl")))) self.assertEqual( norm(rooturi + "/tests/echo.cwl#main"), norm( resolve_local(None, os.path.join("tests", "echo.cwl") + "#main"))) self.assertEqual( norm(rooturi + "/tests/echo.cwl"), norm(resolve_local(None, str(root / "tests" / "echo.cwl")))) self.assertEqual( norm(rooturi + "/tests/echo.cwl#main"), norm( resolve_local(None, str(root / "tests" / "echo.cwl") + "#main"))) finally: os.chdir(origpath)
def working_directory(path): """Changes working directory and returns to previous on exit.""" prev_cwd = Path.cwd() # before python 3.6 chdir doesn't support paths from pathlib os.chdir(str(path)) try: yield finally: os.chdir(str(prev_cwd))