def METHOD_NAME(lab: typing.Optional[selftest.SelftestHost] = None) -> None:
    """Test accessing file via the Path class"""
    with lab or selftest.SelftestHost() as lh:
        f = lh.workdir / "test-file.dat"
        tbot.log.message("Testing text file access ...")
        content = "This is a test file\nwith multiple lines.\n"
        f.write_text(content)
        output = f.read_text()
        assert output == content, f"Sending {content!r} resulted in {output!r}"
        tbot.log.message("Testing binary file access ...")
        content_bin = b"\x00\x1b[m\x04\x01\x10"
        assert f.write_bytes(content_bin) == len(content_bin), "Length mismatch"
        output_bin = f.read_bytes()
        assert (
            output_bin == content_bin
        ), f"Sending {content_bin!r} resulted in {output_bin!r}"
        tbot.log.message("Test reading/writing invalid file ...")
        f = lh.workdir / "path-test.50278c53-3cfc-4983-9770-d571b29b3955"
        # Writing/reading a directory should always fail
        lh.exec0("mkdir", "-p", f)
        raised = False
        try:
            f.write_text("Hello World\n")
        except Exception:
            raised = True
        assert raised, "Writing invalid file supposedly succeeded (text mode)"
        raised = False
        try:
            f.read_text()
        except Exception:
            raised = True
        assert raised, "Reading invalid file supposedly succeeded (text mode)"
        raised = False
        try:
            f.write_bytes(b"Hello World\n")
        except Exception:
            raised = True
        assert raised, "Writing invalid file supposedly succeeded (binary mode)"
        raised = False
        try:
            f.read_bytes()
        except Exception:
            raised = True
        assert raised, "Reading invalid file supposedly succeeded (binary mode)"