Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(27634)

Side by Side Diff: Lib/test/test_shutil.py

Issue 15238: shutil.copystat should copy Linux extended attributes
Patch Set: Created 6 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/shutil.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (C) 2003 Python Software Foundation 1 # Copyright (C) 2003 Python Software Foundation
2 2
3 import unittest 3 import unittest
4 import shutil 4 import shutil
5 import tempfile 5 import tempfile
6 import sys 6 import sys
7 import stat 7 import stat
8 import os 8 import os
9 import os.path 9 import os.path
10 import errno 10 import errno
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 else: 403 else:
404 orig_setxattr(fname, attr, val, **kwargs) 404 orig_setxattr(fname, attr, val, **kwargs)
405 try: 405 try:
406 orig_setxattr = os.setxattr 406 orig_setxattr = os.setxattr
407 os.setxattr = _raise_on_user_foo 407 os.setxattr = _raise_on_user_foo
408 shutil._copyxattr(src, dst) 408 shutil._copyxattr(src, dst)
409 self.assertIn('user.bar', os.listxattr(dst)) 409 self.assertIn('user.bar', os.listxattr(dst))
410 finally: 410 finally:
411 os.setxattr = orig_setxattr 411 os.setxattr = orig_setxattr
412 412
413 # test that shutil.copystat copies xattrs
414 src = os.path.join(tmp_dir, 'the_original')
415 write_file(src, src)
416 os.setxattr(src, 'user.the_value', b'fiddly')
417 dst = os.path.join(tmp_dir, 'the_copy')
418 write_file(dst, dst)
419 shutil.copystat(src, dst)
420 self.assertEqual(os.listxattr(src), ['user.the_value'])
413 @support.skip_unless_symlink 421 @support.skip_unless_symlink
414 @support.skip_unless_xattr 422 @support.skip_unless_xattr
415 @unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() == 0, 423 @unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() == 0,
416 'root privileges required') 424 'root privileges required')
417 def test_copyxattr_symlinks(self): 425 def test_copyxattr_symlinks(self):
418 # On Linux, it's only possible to access non-user xattr for symlinks; 426 # On Linux, it's only possible to access non-user xattr for symlinks;
419 # which in turn require root privileges. This test should be expanded 427 # which in turn require root privileges. This test should be expanded
420 # as soon as other platforms gain support for extended attributes. 428 # as soon as other platforms gain support for extended attributes.
421 tmp_dir = self.mkdtemp() 429 tmp_dir = self.mkdtemp()
422 src = os.path.join(tmp_dir, 'foo') 430 src = os.path.join(tmp_dir, 'foo')
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 1609
1602 self.assertEqual(expected, actual) 1610 self.assertEqual(expected, actual)
1603 1611
1604 1612
1605 def test_main(): 1613 def test_main():
1606 support.run_unittest(TestShutil, TestMove, TestCopyFile, 1614 support.run_unittest(TestShutil, TestMove, TestCopyFile,
1607 TermsizeTests, TestWhich) 1615 TermsizeTests, TestWhich)
1608 1616
1609 if __name__ == '__main__': 1617 if __name__ == '__main__':
1610 test_main() 1618 test_main()
OLDNEW
« no previous file with comments | « Lib/shutil.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+