mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #18702: All skipped tests now reported as skipped.
This commit is contained in:
parent
7a07cc90c7
commit
43767638a9
21 changed files with 967 additions and 925 deletions
|
@ -195,37 +195,37 @@ class TestShutil(unittest.TestCase):
|
|||
self.assertIn(errors[1][2][1].filename, possible_args)
|
||||
|
||||
|
||||
# See bug #1071513 for why we don't run this on cygwin
|
||||
# and bug #1076467 for why we don't run this as root.
|
||||
if (hasattr(os, 'chmod') and sys.platform[:6] != 'cygwin'
|
||||
and not (hasattr(os, 'geteuid') and os.geteuid() == 0)):
|
||||
def test_on_error(self):
|
||||
self.errorState = 0
|
||||
os.mkdir(TESTFN)
|
||||
self.addCleanup(shutil.rmtree, TESTFN)
|
||||
@unittest.skipUnless(hasattr(os, 'chmod'), 'requires os.chmod()')
|
||||
@unittest.skipIf(sys.platform[:6] == 'cygwin',
|
||||
"This test can't be run on Cygwin (issue #1071513).")
|
||||
@unittest.skipIf(hasattr(os, 'geteuid') and os.geteuid() == 0,
|
||||
"This test can't be run reliably as root (issue #1076467).")
|
||||
def test_on_error(self):
|
||||
self.errorState = 0
|
||||
os.mkdir(TESTFN)
|
||||
self.addCleanup(shutil.rmtree, TESTFN)
|
||||
|
||||
self.child_file_path = os.path.join(TESTFN, 'a')
|
||||
self.child_dir_path = os.path.join(TESTFN, 'b')
|
||||
support.create_empty_file(self.child_file_path)
|
||||
os.mkdir(self.child_dir_path)
|
||||
old_dir_mode = os.stat(TESTFN).st_mode
|
||||
old_child_file_mode = os.stat(self.child_file_path).st_mode
|
||||
old_child_dir_mode = os.stat(self.child_dir_path).st_mode
|
||||
# Make unwritable.
|
||||
new_mode = stat.S_IREAD|stat.S_IEXEC
|
||||
os.chmod(self.child_file_path, new_mode)
|
||||
os.chmod(self.child_dir_path, new_mode)
|
||||
os.chmod(TESTFN, new_mode)
|
||||
self.child_file_path = os.path.join(TESTFN, 'a')
|
||||
self.child_dir_path = os.path.join(TESTFN, 'b')
|
||||
support.create_empty_file(self.child_file_path)
|
||||
os.mkdir(self.child_dir_path)
|
||||
old_dir_mode = os.stat(TESTFN).st_mode
|
||||
old_child_file_mode = os.stat(self.child_file_path).st_mode
|
||||
old_child_dir_mode = os.stat(self.child_dir_path).st_mode
|
||||
# Make unwritable.
|
||||
new_mode = stat.S_IREAD|stat.S_IEXEC
|
||||
os.chmod(self.child_file_path, new_mode)
|
||||
os.chmod(self.child_dir_path, new_mode)
|
||||
os.chmod(TESTFN, new_mode)
|
||||
|
||||
self.addCleanup(os.chmod, TESTFN, old_dir_mode)
|
||||
self.addCleanup(os.chmod, self.child_file_path, old_child_file_mode)
|
||||
self.addCleanup(os.chmod, self.child_dir_path, old_child_dir_mode)
|
||||
self.addCleanup(os.chmod, TESTFN, old_dir_mode)
|
||||
self.addCleanup(os.chmod, self.child_file_path, old_child_file_mode)
|
||||
self.addCleanup(os.chmod, self.child_dir_path, old_child_dir_mode)
|
||||
|
||||
shutil.rmtree(TESTFN, onerror=self.check_args_to_onerror)
|
||||
# Test whether onerror has actually been called.
|
||||
self.assertEqual(self.errorState, 3,
|
||||
"Expected call to onerror function did not "
|
||||
"happen.")
|
||||
shutil.rmtree(TESTFN, onerror=self.check_args_to_onerror)
|
||||
# Test whether onerror has actually been called.
|
||||
self.assertEqual(self.errorState, 3,
|
||||
"Expected call to onerror function did not happen.")
|
||||
|
||||
def check_args_to_onerror(self, func, arg, exc):
|
||||
# test_rmtree_errors deliberately runs rmtree
|
||||
|
@ -807,38 +807,39 @@ class TestShutil(unittest.TestCase):
|
|||
finally:
|
||||
shutil.rmtree(TESTFN, ignore_errors=True)
|
||||
|
||||
if hasattr(os, "mkfifo"):
|
||||
# Issue #3002: copyfile and copytree block indefinitely on named pipes
|
||||
def test_copyfile_named_pipe(self):
|
||||
os.mkfifo(TESTFN)
|
||||
try:
|
||||
self.assertRaises(shutil.SpecialFileError,
|
||||
shutil.copyfile, TESTFN, TESTFN2)
|
||||
self.assertRaises(shutil.SpecialFileError,
|
||||
shutil.copyfile, __file__, TESTFN)
|
||||
finally:
|
||||
os.remove(TESTFN)
|
||||
# Issue #3002: copyfile and copytree block indefinitely on named pipes
|
||||
@unittest.skipUnless(hasattr(os, "mkfifo"), 'requires os.mkfifo()')
|
||||
def test_copyfile_named_pipe(self):
|
||||
os.mkfifo(TESTFN)
|
||||
try:
|
||||
self.assertRaises(shutil.SpecialFileError,
|
||||
shutil.copyfile, TESTFN, TESTFN2)
|
||||
self.assertRaises(shutil.SpecialFileError,
|
||||
shutil.copyfile, __file__, TESTFN)
|
||||
finally:
|
||||
os.remove(TESTFN)
|
||||
|
||||
@support.skip_unless_symlink
|
||||
def test_copytree_named_pipe(self):
|
||||
os.mkdir(TESTFN)
|
||||
@unittest.skipUnless(hasattr(os, "mkfifo"), 'requires os.mkfifo()')
|
||||
@support.skip_unless_symlink
|
||||
def test_copytree_named_pipe(self):
|
||||
os.mkdir(TESTFN)
|
||||
try:
|
||||
subdir = os.path.join(TESTFN, "subdir")
|
||||
os.mkdir(subdir)
|
||||
pipe = os.path.join(subdir, "mypipe")
|
||||
os.mkfifo(pipe)
|
||||
try:
|
||||
subdir = os.path.join(TESTFN, "subdir")
|
||||
os.mkdir(subdir)
|
||||
pipe = os.path.join(subdir, "mypipe")
|
||||
os.mkfifo(pipe)
|
||||
try:
|
||||
shutil.copytree(TESTFN, TESTFN2)
|
||||
except shutil.Error as e:
|
||||
errors = e.args[0]
|
||||
self.assertEqual(len(errors), 1)
|
||||
src, dst, error_msg = errors[0]
|
||||
self.assertEqual("`%s` is a named pipe" % pipe, error_msg)
|
||||
else:
|
||||
self.fail("shutil.Error should have been raised")
|
||||
finally:
|
||||
shutil.rmtree(TESTFN, ignore_errors=True)
|
||||
shutil.rmtree(TESTFN2, ignore_errors=True)
|
||||
shutil.copytree(TESTFN, TESTFN2)
|
||||
except shutil.Error as e:
|
||||
errors = e.args[0]
|
||||
self.assertEqual(len(errors), 1)
|
||||
src, dst, error_msg = errors[0]
|
||||
self.assertEqual("`%s` is a named pipe" % pipe, error_msg)
|
||||
else:
|
||||
self.fail("shutil.Error should have been raised")
|
||||
finally:
|
||||
shutil.rmtree(TESTFN, ignore_errors=True)
|
||||
shutil.rmtree(TESTFN2, ignore_errors=True)
|
||||
|
||||
def test_copytree_special_func(self):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue