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: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:7ad69bcd-a43e-2181-2ab8-293b80a3ec12 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9772:23F271:15C9E8A:1D50EAC:6A59692C |
| html-safe-nonce | c97d38515fb919f2d3080fc641f41a3588881e50177c17ca038656b1bfda6257 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NzcyOjIzRjI3MToxNUM5RThBOjFENTBFQUM6NkE1OTY5MkMiLCJ2aXNpdG9yX2lkIjoiNDU4ODQzNzU3Njk4Njc0OTIyOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a6e2cb505dde2ca92cb15783aa04819482595e37ead713374e05e2afdedc1035 |
| 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 | a540949572872b935b393b36db38922db390ae71c859537d741b8f3eb7e545b5 |
| 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 | 4aa391d605ba491481565840251a4b0fec3f4807 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width