Run cat_file.py
fixture without site customizations
#2052
Merged
+1
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes a new
TestGit::test_handle_process_output
test failure on Cygwin where aCoverageWarning
was printed to stderr in the Python interpreter subprocess running thecat_file.py
fixture.Background
We usually run the test suite with
pytest-cov
enabled. This is configured inpyproject.toml
to happen by default.pytest-cov
uses thecoverage
module, but it adds some more functionality. This includes instrumenting subprocesses, which is achieved by installing itspytest-cov.pth
file intosite-packages
to be run by all Python interpreter instances. This causes interpeters to check for environment variables such asCOV_CORE_SOURCE
and to conditionally initializepytest_cov
. For details, see: https://pytest-cov.readthedocs.io/en/latest/subprocess-support.htmlcoverage
7.9.0 was recently released. One of the changes is to start issuing a warning if it can't import the C tracer core. See: https://github.com/nedbat/coveragepy/releases/tag/7.9.0Interaction with
cat_file.py
If this warning is issued in the
cat_file.py
subprocess used intest_handle_process_output
, it causes the test to fail, because the subprocess writes two more lines to its standard error stream, which cause the line count to come out as two more than expected:The Cygwin failure
On most platforms, there is no failure, because the condition the warnings describe does not occur, so there are no warnings. But on Cygwin it does occur, resulting in a new test failure, showing
where the first two elements of the list are from the lines of the warning message, and the others are as expected. (The above is a highly abridged extract, with the
...
at the end standing for many more list items obtained through thecat_file.py
fixture.)This new failure is triggered specifically by the new
coverage
package version. It is not due to any recent changes in GitPython. It can be observed by rerunning CI checks that have previously passed, or in:https://github.com/EliahKagan/GitPython/actions/runs/15598239952/job/43940156308#step:14:355
The fix
There is more than one possible way to fix this, including fixing the underlying condition being warned about on Cygwin, or sanitizing environment variables for the subprocess.
The approach taken here instead is based on the idea that the
cat_file.py
fixture is very simple, and that it is conceptually just a standalone Python script that doesn't do anything meant to depend on the current Python environment.Accordingly, this passes the
-S
option to the interpreter for thecat_file.py
subprocess, so that interpreter refrains from loading thesite
module. This includes, among other simplifying effects, that the subprocess performs no.pth
customizations.