예제 #1
0
def test_relative_from_root_no_shared_base_path(empty_directory):
    """A path can still be relative from root if the paths do not have a common
    prefix.

    For instance, if root is /path/to/root and given root/src/hello.py from the
    directory /path/to, return src/hello.py. This is a bit involved, but works
    out.
    """
    project = Project(empty_directory)
    parent = empty_directory.parent
    os.chdir(parent)
    assert project._relative_from_root(
        Path(f"{project.root.name}/src/hello.py")) == Path("src/hello.py")
예제 #2
0
def test_relative_from_root(empty_directory):
    """A simple test. Given /path/to/root/src/hello.py, return src/hello.py."""
    project = Project(empty_directory)
    assert project._relative_from_root(project.root /
                                       "src/hello.py") == Path("src/hello.py")