mirror of https://github.com/python/cpython.git
make sure os.symlink presence is tested before running some shutil tests -- also refactored the tests to use unittest.skipUnless
This commit is contained in:
parent
14284c2f3b
commit
51a6f72d19
|
@ -263,7 +263,7 @@ def _filter(src, names):
|
||||||
shutil.rmtree(src_dir)
|
shutil.rmtree(src_dir)
|
||||||
shutil.rmtree(os.path.dirname(dst_dir))
|
shutil.rmtree(os.path.dirname(dst_dir))
|
||||||
|
|
||||||
if hasattr(os, "symlink"):
|
@unittest.skipUnless(hasattr(os, 'symlink'), 'requires os.symlink')
|
||||||
def test_dont_copy_file_onto_link_to_itself(self):
|
def test_dont_copy_file_onto_link_to_itself(self):
|
||||||
# bug 851123.
|
# bug 851123.
|
||||||
os.mkdir(TESTFN)
|
os.mkdir(TESTFN)
|
||||||
|
@ -292,6 +292,7 @@ def test_dont_copy_file_onto_link_to_itself(self):
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@unittest.skipUnless(hasattr(os, 'symlink'), 'requires os.symlink')
|
||||||
def test_rmtree_on_symlink(self):
|
def test_rmtree_on_symlink(self):
|
||||||
# bug 1669.
|
# bug 1669.
|
||||||
os.mkdir(TESTFN)
|
os.mkdir(TESTFN)
|
||||||
|
@ -304,7 +305,7 @@ def test_rmtree_on_symlink(self):
|
||||||
finally:
|
finally:
|
||||||
shutil.rmtree(TESTFN, ignore_errors=True)
|
shutil.rmtree(TESTFN, ignore_errors=True)
|
||||||
|
|
||||||
if hasattr(os, "mkfifo"):
|
@unittest.skipUnless(hasattr(os, 'mkfifo'), 'requires os.mkfifo')
|
||||||
# Issue #3002: copyfile and copytree block indefinitely on named pipes
|
# Issue #3002: copyfile and copytree block indefinitely on named pipes
|
||||||
def test_copyfile_named_pipe(self):
|
def test_copyfile_named_pipe(self):
|
||||||
os.mkfifo(TESTFN)
|
os.mkfifo(TESTFN)
|
||||||
|
@ -316,6 +317,7 @@ def test_copyfile_named_pipe(self):
|
||||||
finally:
|
finally:
|
||||||
os.remove(TESTFN)
|
os.remove(TESTFN)
|
||||||
|
|
||||||
|
@unittest.skipUnless(hasattr(os, 'mkfifo'), 'requires os.mkfifo')
|
||||||
def test_copytree_named_pipe(self):
|
def test_copytree_named_pipe(self):
|
||||||
os.mkdir(TESTFN)
|
os.mkdir(TESTFN)
|
||||||
try:
|
try:
|
||||||
|
@ -351,6 +353,7 @@ def _copy(src, dst):
|
||||||
shutil.copytree(src_dir, dst_dir, copy_function=_copy)
|
shutil.copytree(src_dir, dst_dir, copy_function=_copy)
|
||||||
self.assertEquals(len(copied), 2)
|
self.assertEquals(len(copied), 2)
|
||||||
|
|
||||||
|
@unittest.skipUnless(hasattr(os, 'symlink'), 'requires os.symlink')
|
||||||
def test_copytree_dangling_symlinks(self):
|
def test_copytree_dangling_symlinks(self):
|
||||||
|
|
||||||
# a dangling symlink raises an error at the end
|
# a dangling symlink raises an error at the end
|
||||||
|
|
Loading…
Reference in New Issue