[Python-Dev] Tests broken on Windows

Johannes Gijsbers jlg at dds.nl
Sun Oct 31 22:06:10 CET 2004


On Sun, Oct 31, 2004 at 04:00:43PM -0500, Tim Peters wrote:
> [Johannes Gijsbers]
> > Hum, I didn't realize os.chmod() worked this differently on Windows. Seems like
> > I bumped into bug #755617 (os module: Need a better description of "mode"). Per
> > that bug, I googled for '_chmod msdn' and came up with the attached patch.
> > However, I don't have a Windows machine handy to test. Could someone with a
> > Windows machine try the patch?
> 
> I'll try it, but there were no attachments. 

Oops. Here you go.

Johannes
-------------- next part --------------
*** test_shutil.py	31 okt 2004 12:49:56 +0100	1.8
--- test_shutil.py	31 okt 2004 20:47:57 +0100	
***************
*** 22,34 ****
              os.mkdir(TESTFN)
              f = open(os.path.join(TESTFN, 'a'), 'w')
              f.close()
              # Make TESTFN unwritable.
!             os.chmod(TESTFN, stat.S_IRUSR)
  
              shutil.rmtree(TESTFN, onerror=self.check_args_to_onerror)
  
              # Make TESTFN writable again.
!             os.chmod(TESTFN, stat.S_IRWXU)
              shutil.rmtree(TESTFN)
  
      def check_args_to_onerror(self, func, arg, exc):
--- 22,35 ----
              os.mkdir(TESTFN)
              f = open(os.path.join(TESTFN, 'a'), 'w')
              f.close()
+             oldmode = os.stat(TESTFN).st_mode
              # Make TESTFN unwritable.
!             os.chmod(TESTFN, stat.S_IREAD)
  
              shutil.rmtree(TESTFN, onerror=self.check_args_to_onerror)
  
              # Make TESTFN writable again.
!             os.chmod(TESTFN, oldmode)
              shutil.rmtree(TESTFN)
  
      def check_args_to_onerror(self, func, arg, exc):


More information about the Python-Dev mailing list