(root: Union[Path, str], dirs: bool = True)
return "\n".join(str(result.relative_to(root)) for result in results)
A test helper simulating 'find'.

    Iterates over directories and filenames, given as relative paths to the
    root.
A test helper simulating 'find'.
A test helper simulating find .
def find(root: Union[Path, str], dirs: bool = True) -> str:
    """A test helper simulating 'find'.

    Iterates over directories and filenames, given as relative paths to the
    root.

    """
    # TODO: account for alternative backends
    if isinstance(root, str):
        root = Path(root)

    results: List[Path] = []
    for dirpath, dirnames, filenames in os.walk(root):
        names = filenames
        if dirs:
            names += dirnames
        for name in names:
            results.append(Path(dirpath) / name)
    results.sort()
    return "\n".join(str(result.relative_to(root)) for result in results)
def find ( root : Union [ Path , str ] , dirs : bool = True ) -> str : # TODO: account for alternative backends if isinstance ( root , str ) : root = Path ( root ) results : List [ Path ] = [ ] for dirpath , dirnames , filenames in os . walk ( root ) : names = filenames if dirs : names += dirnames for name in names : results . append ( Path ( dirpath ) / name ) results . sort ( ) return "\n" . join ( str ( result . relative_to ( root ) ) for result in results )