Brett Cannon wrote:
On Tue, May 13, 2008 at 12:41 PM, Jesus Cea <[EMAIL PROTECTED]> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1

 Brett Cannon wrote:
 | It is up to the tests to clean up after themselves since they can be
 | executed directly, so there is not magical location that gets cleaned
 | up in case a test screws up. You can use test.test_support.TESTFN if
 | you want a location. Or something from tempfile.

 I'm worried about the case when a test crashes and leave garbage
 behind... that will crash future test runs.


Then don't crash on tests. =)

 I guess I would delete the directory before using it, but I guess
 somebody already had this problem and solved it, somehow. :-?

That's usually the other way to go about it. In your test_main() or
your setUp() methods you make sure everything is clean before you
start.

Personally, I use the tempfile module to get a temporary directory and do anything I need in there (see test_runpy.py or test_cmdline_script.py for examples). That way, even if the test does manage to crash in a way that bypasses the shutil.rmtree cleanup call (which is actually fairly hard to do when the cleanup call is in a finally clause or a tearDown method), it won't affect subsequent executions (although it may accumulate clutter in the buildbot machine's temporary directories over time).

Cheers,
Nick.

--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
            http://www.boredomandlaziness.org
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to