fix: 리댁션 테스트를 릴리스 게이트가 실제로 돌리게 되돌린다 - #51
Merged
Merged
Conversation
`tests/test_speculative_redaction.py` 를 pytest 스타일(모듈 레벨 함수 + `parametrize`)로 쓴 것이 잘못이었다. CI 는 pytest 를 설치해서 돌리므로 초록색이었지만, **릴리스 워크플로는 `unittest discover` 로 게이트를 건다.** 거기에는 `requirements/release.txt` 만 설치되고 pytest 는 없다. 즉 이 파일은 릴리스 환경에서 import 부터 실패했고, import 가 통과하더라도 unittest 는 모듈 레벨 함수를 수집하지 않으므로 **334개 검사가 통째로 사라졌을 것이다.** 0.15.0 태그를 그대로 밀었으면 릴리스가 그 자리에서 깨졌다. 같은 이유로 `mypy --strict src tests` 도 이 파일에서 139개 오류를 냈다. 내가 `mypy --strict tools/` 만 돌려 놓고 통과했다고 본 탓이다. - 180개 테스트를 27개 TestCase 클래스로 옮긴다(구분 주석이 클래스 경계다). - `parametrize` 53개는 `for` + `self.subTest` 로 옮긴다. 잎 334개로 전과 같은 수다. - `monkeypatch.setenv` 는 베이스 클래스의 `setenv` 로 옮긴다. `addCleanup` 이 원래 값을 되돌린다. - 독스트링이 없던 테스트 7개에 독스트링을 붙인다. `tools/check_test_vacuity.py` 도 unittest 로 옮긴다. pytest 노드 ID 로 잎을 세던 것이 subTest 를 못 보고 **파라미터 단위 분해능을 잃었다** — 유출 방향 테스트가 "항등 리댁션에서도 통과" 로 잘못 분류됐다. 도구가 게이트와 다른 러너를 쓰면 게이트에서 돌지 않는 테스트를 검사됐다고 센다. 이제 227개 실패 / 107개 통과로 변환 전과 같다. `tests/test_suite_structure.py` 를 더한다. 수집 대상 모듈에 모듈 레벨 test 함수나 pytest import 가 있으면 실패한다 — 이번 사고의 두 원인이다. 변환 전 파일로 되돌려 세 검사가 모두 실패하는 것을 확인했다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
main이 빨간 상태이고, 이대로v0.15.0을 태그하면 릴리스 워크플로가build-candidate잡에서 그대로 깨진다.무엇이 잘못됐나
PR #50 에서
tests/test_speculative_redaction.py를 pytest 스타일(모듈레벨 함수 +
parametrize)로 썼다. 저장소의 나머지 59개 테스트 모듈은 모두표준 unittest 다.
unittest discover -s tests로 게이트를 건다 →requirements/release.txt에 pytest 가 없으므로 import 부터 실패한다.설령 import 가 통과해도 unittest 는 모듈 레벨
test_*함수를 수집하지않으므로, 334개 검사가 실패 없이 사라진다. 조용히 0 개를 도는 쪽이
더 나쁘다 — 초록색과 구분되지 않는다.
같은 파일에서
mypy --strict src tests가 139개 오류를 냈다(CI 의 유일한실패 잡). 내가
mypy --strict tools/만 돌리고 통과했다고 본 탓이다.무엇을 했나
TestCase클래스로 옮겼다. 라운드 구분 주석이 클래스경계가 됐다.
parametrize53개 →for+self.subTest. 잎 334개 로 전과 같은 수.monkeypatch.setenv→ 베이스 클래스의setenv(addCleanup으로 복원).도구도 같은 결함이 있었다
tools/check_test_vacuity.py는 pytest 노드 ID 로 잎을 셌다. subTest 는노드 ID 를 만들지 않으므로 파라미터 단위 분해능을 잃고 유출 방향 테스트를
"항등 리댁션에서도 통과" 로 잘못 분류했다. 도구가 게이트와 다른 러너를 쓰면
게이트에서 돌지 않는 테스트를 검사됐다고 센다. unittest 로 옮겨 잎을 직접
세게 했다.
재발 방지
tests/test_suite_structure.py— 수집 대상 모듈에 모듈 레벨test_*함수나pytest import 가 있으면 실패한다. 변환 전 파일로 되돌려 세 검사가 모두 실패하는
것을 확인했다(가드가 공허하지 않다).
게이트
unittest discover -s tests(릴리스 러너)pytest -q(CI 러너)ruff check ./ruff format --check .mypy --strict src testscheck_test_vacuity로컬 실패 1건은
test_parent_sentinel_is_absent로, 최소 PATH 의python3가 이 기계에서 다른 인터프리터로 풀리는 문제다. PR #50 이전 커밋
(
8ae5a8f)에서도 똑같이 실패 하고 CI 에서는 통과한다.