The tests now have two convenience functions to wrap os.path.join, open
and read or write instead of four or six slightly different functions.
The new functions accept a tuple of path segments but not a list
anymore, as it makes no sense to use a list here; I have also removed
the default value for the contents in write_file, as I find it better to
have the contents at the call site.
For simple open then read/write calls, I have left the usual idiom (with
open + read/write), as it is short and readable enough.
I’ve also changed some convoluted cleanup code to just use rmtree, and
removed dubious LBYL os.path.exists checks. The tests still pass on my
machine, and leave no file in $TMP. test_shutil is not as clean as it
could be, but I’ll stop here.
Initial patch provided by Hynek Schlawack, in preparation for a new
feature with new tests in #12715.
The line about the test suite will still get printed for changes in
Tools for example, which aren’t covered by the test suite, but it’s not
a big deal IMO.
A reminder: distutils only gets bug fixes. Cosmetic changes, especially
in tests, are not worth the time spent, and can even make future merges
of bugfixes a bit less easy.
I simplified the quote code to use a regex instead of a loop+test when I
moved pipes.quote to shlex in 5966eeb0457d; Ezio Melotti pointed out
that my regex contained redundant parts (now removed) and allowed
non-ASCII characters (now disallowed).
I think common UNIX shells don’t quote non-ASCII characters, but there’s
no harm in doing so. We’ll see if users request a change.
That pipes.quote thinks all non-ASCII characters need to be quoted may
be a bug, but right now I’m committing this test to make sure I haven’t
introduced a behavior change in 3.3 when I simplified the code to use a
regex (in 5966eeb0457d).