summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_shutil.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-05-01 21:09:44 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-05-01 21:09:44 (GMT)
commit7fff09629811ff43d77aca27c6b999634f775fee (patch)
treef6153f684e381d57ce75fed0a4946386b83d9c3c /Lib/test/test_shutil.py
parentedc364717ecd31be14c86cc73af1920c9efedf5f (diff)
downloadcpython-7fff09629811ff43d77aca27c6b999634f775fee.zip
cpython-7fff09629811ff43d77aca27c6b999634f775fee.tar.gz
cpython-7fff09629811ff43d77aca27c6b999634f775fee.tar.bz2
Merged revisions 72178 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r72178 | antoine.pitrou | 2009-05-01 22:55:35 +0200 (ven., 01 mai 2009) | 4 lines Issue #3002: `shutil.copyfile()` and `shutil.copytree()` now raise an error when a named pipe is encountered, rather than blocking infinitely. ........
Diffstat (limited to 'Lib/test/test_shutil.py')
-rw-r--r--Lib/test/test_shutil.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index 86c7b64..cdb039d 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -9,6 +9,7 @@ import os
import os.path
from test import support
from test.support import TESTFN
+TESTFN2 = TESTFN + "2"
class TestShutil(unittest.TestCase):
def test_rmtree_errors(self):
@@ -226,6 +227,38 @@ 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)
+
+ 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:
+ 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)
+
class TestMove(unittest.TestCase):