Commit 4f5e8e3
committed
fix(oauth): cover Python 3.10/3.11 partial-branch coverage gap
Python 3.10/3.11 で coverage.py (sys.settrace backend) が
async_auth_flow の以下 4 行で `if` の False 分岐を partial として誤認識し、
fail_under=100 を満たせず CI が落ちていた:
- line 536: `if not is_token_valid() and can_refresh_token():` (Phase 1)
- line 546: 同 (Phase 2 double-check inside refresh_lock)
- line 548: `if refresh_request is not None:` (re-check skip path)
- line 553: `if not await _handle_refresh_response(...):` (refresh success path)
Python 3.12+ (sys.monitoring) では同コードで 100% に到達するため、
4 行に `# pragma: no branch` を付けて legacy backend 用 workaround とする
(行頭に意図を 5 行のコメントブロックで明記)。
加えて、4 branch をテストで踏んでいることを担保する unit test を 2 件追加:
- test_phase1_skips_refresh_when_token_valid:
Phase 1 で `is_token_valid=True` のため Phase 2 をスキップする経路
- test_refresh_success_proceeds_to_phase3_without_resetting_initialized:
`_handle_refresh_response` が True (=200) を返し `_initialized` リセットを
スキップして Phase 3 に進む success path
ローカル検証 (Python 3.10):
pytest tests/client/test_auth.py -n auto + coverage report
→ 99.43% (旧 98.30%, BrPart 1, Missing は test 範囲外の line 206 のみ)
全 test 走行で 100% を期待。1 parent b4320fb commit 4f5e8e3
2 files changed
Lines changed: 78 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
533 | 533 | | |
534 | 534 | | |
535 | 535 | | |
536 | | - | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
537 | 542 | | |
538 | 543 | | |
539 | 544 | | |
| |||
543 | 548 | | |
544 | 549 | | |
545 | 550 | | |
546 | | - | |
| 551 | + | |
547 | 552 | | |
548 | | - | |
| 553 | + | |
549 | 554 | | |
550 | 555 | | |
551 | 556 | | |
552 | 557 | | |
553 | | - | |
| 558 | + | |
554 | 559 | | |
555 | 560 | | |
556 | 561 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2818 | 2818 | | |
2819 | 2819 | | |
2820 | 2820 | | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
| 2824 | + | |
| 2825 | + | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + | |
| 2830 | + | |
| 2831 | + | |
| 2832 | + | |
| 2833 | + | |
| 2834 | + | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
| 2851 | + | |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
| 2862 | + | |
| 2863 | + | |
| 2864 | + | |
| 2865 | + | |
| 2866 | + | |
| 2867 | + | |
| 2868 | + | |
| 2869 | + | |
| 2870 | + | |
| 2871 | + | |
| 2872 | + | |
| 2873 | + | |
| 2874 | + | |
| 2875 | + | |
| 2876 | + | |
| 2877 | + | |
| 2878 | + | |
| 2879 | + | |
| 2880 | + | |
| 2881 | + | |
| 2882 | + | |
| 2883 | + | |
| 2884 | + | |
| 2885 | + | |
| 2886 | + | |
| 2887 | + | |
| 2888 | + | |
| 2889 | + | |
0 commit comments