Title: Defer xfail condition evaluation with xfail_if_raises context manager by elovelan · Pull Request #2153 · gitpython-developers/GitPython · GitHub
Open Graph Title: Defer xfail condition evaluation with xfail_if_raises context manager by elovelan · Pull Request #2153 · gitpython-developers/GitPython
X Title: Defer xfail condition evaluation with xfail_if_raises context manager by elovelan · Pull Request #2153 · gitpython-developers/GitPython
Description: Summary This PR introduces xfail_if_raises, a context manager that approximates @pytest.mark.xfail(..., raises=...) behavior inside a test body rather than as a decorator. Problem @pytest.mark.xfail evaluates its condition argument during test collection (module import time). In test_index_mutation, this condition includes Git().config("core.symlinks") == "true", which: Spawns an external git config process even when the test is not being run Can fail or behave unexpectedly during collection if git configuration is unavailable Relies on in-repo code during test discovery, which may not be appropriate in all contexts Solution xfail_if_raises moves the xfail logic into the test body. The side-effectful condition is only evaluated if the test actually raises the specified exception(s). This keeps test collection lightweight and avoids relying on in-repo code as part of module import/test discovery. This change is applied to test_index_mutation in test/test_index.py. AI disclosure This PR description was prepared with assistance from an agent. All code was written by hand.
Open Graph Description: Summary This PR introduces xfail_if_raises, a context manager that approximates @pytest.mark.xfail(..., raises=...) behavior inside a test body rather than as a decorator. Problem @pytest.mark.xfai...
X Description: Summary This PR introduces xfail_if_raises, a context manager that approximates @pytest.mark.xfail(..., raises=...) behavior inside a test body rather than as a decorator. Problem @pytest.mark.xfai...
Opengraph URL: https://github.com/gitpython-developers/GitPython/pull/2153
X: @github
Domain: redirect.github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:f910ab78-7503-40ea-130a-3e5331ad7686 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A90A:DD91C:5913BD:7FF2AD:6A61EC9A |
| html-safe-nonce | c35da9d3583ad6bb69aec2106a18f13fd00dd7b4924c53eb90e2775e5918635b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTBBOkREOTFDOjU5MTNCRDo3RkYyQUQ6NkE2MUVDOUEiLCJ2aXNpdG9yX2lkIjoiNzEwMzM0NDY4NjMzODc5NjY5OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fc9a9c80cf3762b8b3654ff80802f01da8e9dbfe13bab96838ef9cf3bfcc6efe |
| hovercard-subject-tag | pull_request:3690633339 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/2153/files |
| twitter:image | https://avatars.githubusercontent.com/u/563397?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/563397?s=400&v=4 |
| og:image:alt | Summary This PR introduces xfail_if_raises, a context manager that approximates @pytest.mark.xfail(..., raises=...) behavior inside a test body rather than as a decorator. Problem @pytest.mark.xfai... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5dd1217fff37e297563b9d318ee02bf6378c8957c6195b77786bb8896fc9c95d |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 554667f6dda2a53c83687de64fabc457970f0f04 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width