summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_shutil.py
diff options
context:
space:
mode:
authorHynek Schlawack <hs@ox.cx>2013-02-05 07:22:44 (GMT)
committerHynek Schlawack <hs@ox.cx>2013-02-05 07:22:44 (GMT)
commit0beab058dd431a7c0d62cfc50d8503616e01fd17 (patch)
tree6c8e1f435c931c2bc8edd7127cb72c4529e9ab7b /Lib/test/test_shutil.py
parent844b0e69717bf97bd7fbd055368ac398b99ec7e1 (diff)
downloadcpython-0beab058dd431a7c0d62cfc50d8503616e01fd17.zip
cpython-0beab058dd431a7c0d62cfc50d8503616e01fd17.tar.gz
cpython-0beab058dd431a7c0d62cfc50d8503616e01fd17.tar.bz2
#17076: Make copying of xattrs more permissive of missing FS support
Patch by Thomas Wouters.
Diffstat (limited to 'Lib/test/test_shutil.py')
-rw-r--r--Lib/test/test_shutil.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index 8ac350a..3b1b694 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -449,6 +449,17 @@ class TestShutil(unittest.TestCase):
self.assertIn('user.bar', os.listxattr(dst))
finally:
os.setxattr = orig_setxattr
+ # the source filesystem not supporting xattrs should be ok, too.
+ def _raise_on_src(fname, *, follow_symlinks=True):
+ if fname == src:
+ raise OSError(errno.ENOTSUP, 'Operation not supported')
+ return orig_listxattr(fname, follow_symlinks=follow_symlinks)
+ try:
+ orig_listxattr = os.listxattr
+ os.listxattr = _raise_on_src
+ shutil._copyxattr(src, dst)
+ finally:
+ os.listxattr = orig_listxattr
# test that shutil.copystat copies xattrs
src = os.path.join(tmp_dir, 'the_original')