Unset PYTHONWARNINGS envvar before running subprocess tests.

The extra warnings in the subprocesses were causing test failures.

Closes gh-5218

Also, explicitly close a file, to squash some warnings seen while running the tests.