def test_incorrect_permissions(self): # If permissions on existing im dir are not correct, # a new one should be created. tmpdir = tempfile.mkdtemp() try: im_dir = catalog.create_intermediate_dir(tmpdir) root_im_dir = os.path.dirname(im_dir) try: os.chmod(root_im_dir, 0o777) except OSError: raise KnownFailureTest("Can't set file permissions.") else: self.dirs_are_valid(im_dir, tmpdir) finally: remove_tree(tmpdir)
def test_incorrect_ownership(self): # Test if new intermediate dir is created when there is only one # im dir owned by improper user. import pwd tmpdir = tempfile.mkdtemp() try: im_dir = catalog.create_intermediate_dir(tmpdir) root_im_dir = os.path.dirname(im_dir) nobody = pwd.getpwnam('nobody')[2] nobody_g = pwd.getpwnam('nobody')[3] try: os.chown(root_im_dir, nobody, nobody_g) except OSError: raise KnownFailureTest("Can't change owner.") else: self.dirs_are_valid(im_dir, tmpdir) finally: remove_tree(tmpdir)
def test_symlink_raise(self): """ if existing im dir is a symlink, new one should be created """ tmpdir = tempfile.mkdtemp() try: im_dir = catalog.create_intermediate_dir(tmpdir) root_im_dir = os.path.dirname(im_dir) tempdir = tempfile.mkdtemp(prefix='scipy-test', dir=tmpdir) try: os.rename(root_im_dir, tempdir) except OSError: raise KnownFailureTest("Can't move intermediate dir.") try: os.symlink(tempdir, root_im_dir) except OSError: raise KnownFailureTest( "Can't create symlink to intermediate dir.") else: self.dirs_are_valid(im_dir, tmpdir) finally: remove_tree(tmpdir)
def test_symlink_raise(self): # If existing im dir is a symlink, new one should be created. tmpdir = tempfile.mkdtemp() try: im_dir = catalog.create_intermediate_dir(tmpdir) root_im_dir = os.path.dirname(im_dir) tempdir = tempfile.mkdtemp(prefix='scipy-test', dir=tmpdir) try: os.rename(root_im_dir, tempdir) except OSError: raise KnownFailureTest("Can't move intermediate dir.") try: os.symlink(tempdir, root_im_dir) except OSError: raise KnownFailureTest( "Can't create symlink to intermediate dir.") else: self.dirs_are_valid(im_dir, tmpdir) finally: remove_tree(tmpdir)