[Python-Dev] fixing tests on windows
Gregory P. Smith
greg at krypto.org
Wed Apr 2 08:26:20 CEST 2008
On Tue, Apr 1, 2008 at 9:13 AM, Tim Golden <mail at timgolden.me.uk> wrote:
> Tim Golden wrote:
> > Steven Bethard wrote:
> >> At the sprints, I ran into a bunch of similar errors running the test
> >> suite on my Windows Vista box, even on tests that were properly
> >> cleaning up after themselves in tearDown(). I even tried putting in
> >> sleeps as long as 1 second, to no avail. The only way to get the test
> >> suite to run without these errors was to stop the Windows Search
> >> Service, fully disable Icon Overlays for TortoiseSVN, and then close
> >> down all open folders.
> >> Any chance the boxes the tests are being run on are running the
> >> Windows Search Service or have Icon Overlays enabled for TortoiseSVN?
> >> (If anyone has any ideas of how to get around these problems, I'd love
> >> to hear them. Seems like I shouldn't have to disable these services.)
> > I'm not sure I'm going to help here, but the reason that
> > this happens is that certain services -- and the Desktop
> > Search tools are notorious for this -- get file handles with
> > FILE_SHARE_DELETE, which means that the file isn't actually
> > removed when it's deleted; only when the last of those handles
> > closes.
> > I did see a suggestion somewhere that, to circumvent this issue,
> > instead of removing it a file you need to move it to %TEMP%
> > (or wherever) and delete it there. I'll try to knock up a test
> > case to see if this works.
> OK: to confirm, the following test seems to indicate that
> doing a (local - same volume) rename followed by a remove
> will do the right thing, even when a FILE_SHARE_DELETE handle
> is held.
> If this is the thing to do, presumably test_support should
> grow a "remove_file" which does something of this sort?
> import os, sys
> import win32file
> FILENAME = "test"
> def rename_and_remove (filename):
> os.rename (filename, filename + ".deleted")
> os.remove (filename + ".deleted")
Isn't this still going to run into problems when the rename fails because
the earlier tests remove still left the .deleted file around due to some
other running desktop search service that now has the .deleted file open?
+1 on not supporting OSes with such bad filesystem semantics? ;)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev