Title: Run `cat_file.py` fixture without site customizations by EliahKagan · Pull Request #2052 · gitpython-developers/GitPython · GitHub
Open Graph Title: Run `cat_file.py` fixture without site customizations by EliahKagan · Pull Request #2052 · gitpython-developers/GitPython
X Title: Run `cat_file.py` fixture without site customizations by EliahKagan · Pull Request #2052 · gitpython-developers/GitPython
Description: This fixes a new TestGit::test_handle_process_output test failure on Cygwin where a CoverageWarning was printed to stderr in the Python interpreter subprocess running the cat_file.py fixture. Background We usually run the test suite with pytest-cov enabled. This is configured in pyproject.toml to happen by default. pytest-cov uses the coverage module, but it adds some more functionality. This includes instrumenting subprocesses, which is achieved by installing its pytest-cov.pth file into site-packages to be run by all Python interpreter instances. This causes interpeters to check for environment variables such as COV_CORE_SOURCE and to conditionally initialize pytest_cov. For details, see: https://pytest-cov.readthedocs.io/en/latest/subprocess-support.html coverage 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.0 Interaction with cat_file.py If this warning is issued in the cat_file.py subprocess used in test_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: /cygdrive/d/a/GitPython/GitPython/.venv/lib/python3.9/site-packages/coverage/core.py:96: CoverageWarning: Couldn't import C tracer: No module named 'coverage.tracer' (no-ctracer) warn(f"Couldn't import C tracer: {IMPORT_ERROR}", slug="no-ctracer", once=True) 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 > self.assertEqual(len(actual_lines[2]), expected_line_count, repr(actual_lines[2])) E AssertionError: 5004 != 5002 : ["/cygdrive/d/a/GitPython/GitPython/.venv/lib/python3.9/site-packages/coverage/core.py:96: CoverageWarning: Couldn't import C tracer: No module named 'coverage.tracer' (no-ctracer)\n", ' warn(f"Couldn\'t import C tracer: {IMPORT_ERROR}", slug="no-ctracer", once=True)\n', 'From github.com:jantman/gitpython_issue_301\n', ' = [up to date] master -> origin/master\n', ' = [up to date] testcommit1 -> origin/testcommit1\n', ' = [up to date] testcommit10 -> origin/testcommit10\n', ... 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 the cat_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 the cat_file.py subprocess, so that interpreter refrains from loading the site module. This includes, among other simplifying effects, that the subprocess performs no .pth customizations.
Open Graph Description: This fixes a new TestGit::test_handle_process_output test failure on Cygwin where a CoverageWarning was printed to stderr in the Python interpreter subprocess running the cat_file.py fixture. Backg...
X Description: This fixes a new TestGit::test_handle_process_output test failure on Cygwin where a CoverageWarning was printed to stderr in the Python interpreter subprocess running the cat_file.py fixture. Backg...
Opengraph URL: https://github.com/gitpython-developers/GitPython/pull/2052
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:71eff8ed-a14f-bf4e-a916-d8076e5ca2a3 |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | 9990:17C3B9:1083589:16D14C8:6968A911 |
| html-safe-nonce | 83df0e367918fcc0a5f0780f0c773beac7e4b51dd80835ae1009193006b0957b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTkwOjE3QzNCOToxMDgzNTg5OjE2RDE0Qzg6Njk2OEE5MTEiLCJ2aXNpdG9yX2lkIjoiNDcxMjkxNjY3Mjc4NTcyMTYxNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2a75d67be488212e41dff7445eb8d5402ea208f2047202be4aba20da5c536500 |
| hovercard-subject-tag | pull_request:2586316376 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/gitpython-developers/GitPython/pull/2052/checks |
| twitter:image | https://avatars.githubusercontent.com/u/1771172?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1771172?s=400&v=4 |
| og:image:alt | This fixes a new TestGit::test_handle_process_output test failure on Cygwin where a CoverageWarning was printed to stderr in the Python interpreter subprocess running the cat_file.py fixture. Backg... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | fdc7c66bd36a6c12eb8e771e806db863266e573fc299e77f27505a768d4f8a98 |
| turbo-cache-control | no-cache |
| go-import | github.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126087 |
| octolytics-dimension-repository_nwo | gitpython-developers/GitPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126087 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/GitPython |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3223a6503d318917691422cdadfbe16cd8fb21e5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width