On 14Feb.2019 0948, Brett Cannon wrote:
> On Thu, Feb 14, 2019 at 7:26 AM Giampaolo Rodola' <g.rod...@gmail.com
> <mailto:g.rod...@gmail.com>> wrote:
>     Extra: an argument in favor of using tempfile.mkdtemp() instead of
>     TESTFN is parallel testing, but I think we're not using it.
> 
> 
> With -j you can do parallel testing and I know I always run with that
> on. But TESTFN does /attempt /to account for that
> <https://github.com/python/cpython/blob/8a1657b93469580ef345c7c91738587f3d76e87d/Lib/test/support/__init__.py#L835>
> by using the PID in the name.
> 
> Having said that, I do use tempfile like Eric, Ronald, and Tim when I
> write tests as I have real-world experience using tempfile so I usually
> remember to clean up versus TESTFN which is Python stdlib internals only
> and I have to remember that it won't clean up itself.

I spend a decent amount of time rewriting tests to use TESTFN, since
that enables us to keep all test files constrained to either a default
directory or the one specified by --tempdir (which is a relatively
recent addition, I'll grant, but it's been useful for improving test
performance and stability when the default TEMP locations are not
reliable - e.g. if $tmp is a mount point it breaks some tests, if it's a
symlink it breaks others, if it's got particular permissions it breaks
others again, etc.).

That said, I'd love to have a context manager that we can use to make
this easier. Really, none of us should be having to decide "how am I
going to use a temporary location on the file system in my test",
because we should have one obvious (and easy!) way to do it.

But please, don't keep reinventing the functions we already have in
test.support for doing this (unless you're putting better versions in
test.support!)

Cheers,
Steve
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to