[issue7712] Add a context manager to change cwd in test.test_support

Ezio Melotti report at bugs.python.org
Tue Jan 19 16:47:13 CET 2010


Ezio Melotti <ezio.melotti at gmail.com> added the comment:

The patch looks good, I'd just move _test_cwd inside the function and drop the [:-3] from TESTFN, but apart from that it's OK. I also agree that functools.wraps should be added.

To summarize the discussion we had on #python-dev:
1) the context manager should always create a writable cwd and to be able to run with -J it should contain the process id. Using TESTFN as first-level dir solves both the issues;
2) a suffix is added to TESTFN to let the tests use TESTFN as a valid filename;
3) the second-level dir is 'tempcwd' by default or can be passed to the function in case a test needs a specific name for the cwd;

The result will be something like '@test_xxxx_tmp_cwd/dirname'.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7712>
_______________________________________


More information about the Python-bugs-list mailing list