I need to copy this file in another test too, so I moved the support
code to distutils.tests.support and improved it to use proper skip
machinery instead of custom print/return/test suite fiddling.
Contrary to my similar change in distutils tests, I did not add support
for finding xxmodule.c when running a test from the tests directory,
because in that case my compiler didn’t find Python.h, so I figured it’s
better to skip than to fail.
It is not possible to unload a module written in C, so use a subprocess to run
the tests on the module compiled by test_build_ext(). Using a subprocess, we
don't have to unload the module, save/restore sys.path, and the test can be run
more than once.
This commit fixes also an access error on rmtree() on Windows: because the
module was not really unloaded, it was not possible to remove the temporary
directory (it is not possible to remove a directory on Windows if it still
contains an open file).
The two public functions in database default to sys.path if the given
*paths* argument is None; the private functions don’t have default
values for their arguments anymore, which is fine as the public
functions that call them pass their arguments down. Likewise in
install, the functions will pass down their *paths* arguments down to
database functions.
A one-line unneeded function in install was removed instead of being
changed, and the few remaining tests that used brute-force restoration
of sys.path have been cleaned up to use sys.path.remove.