def test_rmtree_read_only_directories(tmpdir): """Simulates the go module tree. See #1042""" tmpdir.join('x/y/z').ensure_dir().join('a').ensure() mode = os.stat(str(tmpdir.join('x'))).st_mode mode_no_w = mode & ~(stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH) tmpdir.join('x/y/z').chmod(mode_no_w) tmpdir.join('x/y/z').chmod(mode_no_w) tmpdir.join('x/y/z').chmod(mode_no_w) rmtree(str(tmpdir.join('x')))
def test_cmd_output_no_shebang(tmpdir, fn): f = tmpdir.join('f').ensure() make_executable(f) # previously this raised `OSError` -- the output is platform specific ret, out, _ = fn(str(f), retcode=None, stderr=subprocess.STDOUT) assert ret == 1 assert isinstance(out, bytes) assert out.endswith(b'\n')