Issue 1071513: test_sutil fails on cygwin (original) (raw)

[10:23] $python -V Python 2.4c1 [10:25] $python -c 'from test.test_shutil import test_main; test_main()' -v test_dont_copy_file_onto_link_to_itself (test.test_shutil.TestShutil) ... ok test_dont_move_dir_in_itself (test.test_shutil.TestShutil) ... ok test_on_error (test.test_shutil.TestShutil) ... ERROR test_rmtree_dont_delete_file (test.test_shutil.TestShutil) ... ok test_rmtree_errors (test.test_shutil.TestShutil) ... ok

====================================================================== ERROR: test_on_error (test.test_shutil.TestShutil)

Traceback (most recent call last): File "/usr/lib/python2.4/test/test_shutil.py", line 34, in test_on_error os.chmod(TESTFN, old_dir_mode) OSError: [Errno 2] No such file or directory: '@test'


Ran 5 tests in 0.036s

FAILED (errors=1) Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.4/test/test_shutil.py", line 99, in test_main test_support.run_unittest(TestShutil) File "/usr/lib/python2.4/test/test_support.py", line 290, in run_unittest run_suite(suite, testclass) File "/usr/lib/python2.4/test/test_support.py", line 275, in run_suite raise TestFailed(err) test.test_support.TestFailed: Traceback (most recent call last): File "/usr/lib/python2.4/test/test_shutil.py", line 34, in test_on_error os.chmod(TESTFN, old_dir_mode) OSError: [Errno 2] No such file or directory: '@test'

Logged In: YES user_id=358087

I disagree, chmod seems to work: [11:35] - adp96: touch zzz [11:35] - adp96: ll zzz -rw-rw-rw- 1 mikit Domain U 0 Nov 23 11:35 zzz [11:35] - adp96: python -c 'from os import chmod; chmod("zzz", 0700)' [11:36] - adp96: ll zzz -rwx------ 1 mikit Domain U 0 Nov 23 11:35 zzz

Logged In: YES user_id=469548

Hmm, strange. I should perhaps have provided the link that I based this on: http://www.cygwin.com/faq/faq_3.html#SEC41. The thing is, the test needs a permissions error so it can check shutil.rmtree's error handling. Setting the permissions for the directory to stat.S_IREAD (0400) doesn't seem to prevent Python from removing the file. I don't know enough about the intricacies of Cygwin+chmod (I don't have a Windows machine) to make this work reliably, but I'll be happy to take another patch.

Note, by the way, that this is not a problem with shutil itself, but just with the test.