Repository navigation
Fail fstat for chains.py alone in the descriptor test (closes #713) - #714
Conversation
test_a_descriptor_that_cannot_be_inspected_is_closed_and_refused replaced os.fstat for the whole process. pytest 9.2.0's fd-level capture calls os.fstat on its own buffer at the end of the call phase, before the monkeypatch is undone, so the fake failed pytest itself and deps-latest went red on every cell that runs the test (PR pytest-dev/pytest#14687). cookie_auth was right throughout: it closed the descriptor and raised FetchError. The fake replaces the os module chains.py sees, with fstat failing, so the code under test is the only caller that meets it. The match names "no fstat", so the test also shows that it is the fake's error that cookie_auth turned into FetchError. The issue proposed a fake that delegates to the real fstat for every file but the cookie. At the locked pytest nothing reaches that delegate, and tests is under the 100% coverage floor. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Ferdinando Ametrano <[email protected]>
There was a problem hiding this comment.
ACK 22fb92a
Not checked: the pull request's evidence table was not run. That is the targeted test with -n 0 at pytest 9.1.1 and at 9.2.0 (after uv lock --upgrade-package pytest), on main's chains.py and on the mutant without os.close(fd).
|
Claimed: a /btclib-pr session of pmazzocchi is reviewing this pull request toward approval, night of 2026-10-29. It pushes nothing to the branch without saying so here first. |
pmazzocchi
left a comment
There was a problem hiding this comment.
Approved at 22fb92a: the descriptor test fails os.fstat for chains.py alone, so pytest 9.2.0's capture keeps working (closes #713).
A fresh review cleared this head: patching bitcoin_core_rpc.chains.os reaches only cookie_auth, the new match= takes the fake's message and no other, and deps-latest dispatched on the branch passed on pytest 9.2.0 in every cell. The only file is a test, the bot acknowledged this sha, no thread is open, and every check passed.
deps-latest is red on main because a test in
tests/chains_test.pyreplacedos.fstatfor the whole process. pytest 9.2.0's capture callsos.fstaton its own buffer at the end of the call phase, before the monkeypatch is undone, so the fake failed pytest itself (PR pytest-dev/pytest#14687).cookie_authbehaves correctly.The test now gives
chains.pyalone a copy ofoswhosefstatfails, and its match names the fake's error. The issue proposed a fake that delegates to the realfstatfor every other file. At the locked pytest nothing reaches that delegate, andtestsis under the 100% coverage floor.Evidence
Each run is the targeted test with
-n 0. The pytest 9.2.0 environment is the lock afteruv lock --upgrade-package pytest. The mutant removes theos.close(fd)incookie_auth's fstatexcept.OSError: no fstatThe whole suite (
uv run --locked pytest, coverage 100%),uv run --locked pre-commit run --all-filesand the docs build exit 0 on 22fb92a. A deps-latest run dispatched on the branch at e835688 passed on all eight jobs (run 40804121574); 22fb92a differs from it only in a test comment and the commit message. Local review: dedicated reviewerCLEARED e835688, fresh reviewerCLEARED 22fb92a466473c348b10a568d7d673781593bffe.Closes #713
🤖 Generated with Claude Code