[Python-Dev] fixing tests on windows
Tim Golden
mail at timgolden.me.uk
Wed Apr 2 11:24:22 CEST 2008
Nick Coghlan wrote:
> Tim Golden wrote:
>> I admit: this did occur to me on the train this am. While I
>> try to think of a robust way to handle this, other people have
>> proposed variations on pid-based / tempdir based filenames instead
>> of the same name for each test. In principle this sounds good to me,
>> but I'm not at all well-placed to assess the impact it might have
>> on the unit tests in general.
>
> Personally, I've never really understood the purpose of
> test_support.TESTFN. Whenever I've needed a temporary file for a test, I
> just use the tempfile module (e.g. test_cmd_line_script, test_runpy).
> Tests using that module don't care if the old files take 'a while' to
> get deleted on Windows, as tempfile uses a different name each time anyway.
>
> Is using a fixed TESTFN just an old approach that predates the existence
> of a robust tempfile module in the standard library?
I'm a neophyte when it comes to core development, so I've simply
cloned existing tests, assumed that there was some kind of (possibly
unwritten) standard which used test_support.TESTFN. As I look at
it, though it seems a slightly odd choice, although it has variants
for testing unicode filenames specifically which I imagine are
useful in some places.
I'm perfectly happy to run through the test suite, patching it one
way or another. The trouble is that I've little confidence that I
can assess whether or not such a change will have affected the
actual meaning of a test. And, since these are tests,
Quis custodiet...?
TJG
More information about the Python-Dev
mailing list