def test_file_subtract(self, path, recursive): path.touch() path.chmod(0o777) path_.chmod(path, 0o111, '-', recursive=recursive) assert_file_mode(path, 0o666) path_.chmod(path, 0o751, '-', recursive=recursive) assert_file_mode(path, 0o026)
def test_dir_subtract(self, root, child_dir, child_file, grand_child): with self.unchanged(child_dir, child_file, grand_child): root.chmod(mode=0o777) path_.chmod(root, 0o011, '-') assert_file_mode(root, 0o766) path_.chmod(root, 0o271, '-') assert_file_mode(root, 0o506)
def test_dir_assign_recursive(self, root, child_dir, child_file, grand_child): path_.chmod(root, mode=0o777, recursive=True) assert_file_mode(root, 0o777) assert_file_mode(child_dir, 0o777) assert_file_mode(child_file, 0o666) assert_file_mode(grand_child, 0o666) path_.chmod(root, mode=0o751, recursive=True) assert_file_mode(root, 0o751) assert_file_mode(child_dir, 0o751) assert_file_mode(child_file, 0o640) assert_file_mode(grand_child, 0o640)
def temp_dir_cwd(tmpdir): ''' pytest fixture which sets current working directory to a temporary directory. ''' original_cwd = Path.cwd() os.chdir(str(tmpdir)) yield tmpdir # ensure the user has full permissions on temp dir (so that pytest can remove it later) path_.chmod(Path(str(tmpdir)), 0o700, '+', recursive=True) os.chdir(str(original_cwd))
def test_dir_subtract_recursive(self, root, child_dir, child_file, grand_child): root.chmod(mode=0o777) child_dir.chmod(0o777) child_file.chmod(0o777) grand_child.chmod(0o777) path_.chmod(root, 0o222, '-', recursive=True) assert_file_mode(root, 0o555) assert_file_mode(child_dir, 0o555) assert_file_mode(child_file, 0o555) assert_file_mode(grand_child, 0o555) path_.chmod(root, 0o047, '-', recursive=True) assert_file_mode(root, 0o510) assert_file_mode(child_dir, 0o510) assert_file_mode(child_file, 0o511) assert_file_mode(grand_child, 0o511)
def test_dir_add(self, root, child_dir, child_file, grand_child): with self.unchanged(child_dir, child_file, grand_child): root.chmod(0o000) path_.chmod(root, 0o111, '+') assert_file_mode(root, 0o111) path_.chmod(root, 0o100, '+') assert_file_mode(root, 0o111) path_.chmod(root, 0o751, '+') assert_file_mode(root, 0o751)
def test_file_add(self, path, recursive): path.touch() path.chmod(0o000) path_.chmod(path, 0o111, '+', recursive=recursive) assert_file_mode(path, 0o111) path_.chmod(path, 0o100, '+', recursive=recursive) assert_file_mode(path, 0o111) path_.chmod(path, 0o751, '+', recursive=recursive) assert_file_mode(path, 0o751)
def test_dir_add_recursive(self, root, child_dir, child_file, grand_child): grand_child.chmod(0o000) child_dir.chmod(0o000) child_file.chmod(0o000) root.chmod(0o000) path_.chmod(root, 0o511, '+', recursive=True) assert_file_mode(root, 0o511) assert_file_mode(child_dir, 0o511) assert_file_mode(child_file, 0o400) assert_file_mode(grand_child, 0o400) path_.chmod(root, 0o500, '+', recursive=True) assert_file_mode(root, 0o511) assert_file_mode(child_dir, 0o511) assert_file_mode(child_file, 0o400) assert_file_mode(grand_child, 0o400) path_.chmod(root, 0o751, '+', recursive=True) assert_file_mode(root, 0o751) assert_file_mode(child_dir, 0o751) assert_file_mode(child_file, 0o640) assert_file_mode(grand_child, 0o640)
def test_dir_assign(self, root, child_dir, child_file, grand_child): with self.unchanged(child_dir, child_file, grand_child): path_.chmod(root, mode=0o777) assert_file_mode(root, 0o777) path_.chmod(root, mode=0o751) assert_file_mode(root, 0o751)
def test_file_assign(self, path, recursive): path.touch() path_.chmod(path, mode=0o777, recursive=recursive) assert_file_mode(path, 0o777) path_.chmod(path, mode=0o751, recursive=recursive) assert_file_mode(path, 0o751)