I ran into an error today related to the use of support.TESTFN throughout the regression test suite. In my Windows tests, test_base64 passed, but left a file (named by support.TESTFN) lying around: 'test_base64' left behind file '@test_3532_tmp' Much later in the run, a set of unrelated tests started failing, all apparently because of the left-behind file - for example, test_mailbox.setUp failed while trying to make a directory named by support.TESTFN: File "c:\Users\Vinay\Projects\pythonv\lib\mailbox.py", line 270, in __init__ os.mkdir(self._path, 0o700) PermissionError: [Error 5] Access is denied: 'c:\\Users\\Vinay\\Projects\\pythonv\\build\\test_python_3532\\@test_3532_tmp' Sorry if this has come up before, but why do we couple the tests in this way, so that failure to clean up in one test causes drive-by failures in other, unrelated tests? Regards, Vinay Sajip
On Tue, Nov 8, 2011 at 8:02 PM, Vinay Sajip <vinay_sajip@yahoo.co.uk> wrote:
Sorry if this has come up before, but why do we couple the tests in this way, so that failure to clean up in one test causes drive-by failures in other, unrelated tests?
Personally, I just use the tempfile module in tests that I write (historically via test.script_helper.temp_dir, these days via the public tempfile.TemporaryDirectory API). Given the other things regrtest cleans up between tests, I'm not sure why it doesn't also kill TESTFN, though. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
Nick Coghlan <ncoghlan <at> gmail.com> writes:
Given the other things regrtest cleans up between tests, I'm not sure why it doesn't also kill TESTFN, though.
Well, there's a function regrtest.cleanup_test_droppings which aims to do just this, and it's called in a finally: block from regrtest.runtest. It's supposed to print a message if removal fails, and appears to be what prints the "left behind" message. In my case no "couldn't remove" message was printed, and yet the file was there later - whether it wasn't properly removed, or whether it was created in an intervening test, is not easy to determine :-( Regards, Vinay Sajip
participants (2)
-
Nick Coghlan
-
Vinay Sajip