Commit ff57549
test(oauth): make token-request unwrap test hermetic
test_local_impl_token_request_unwraps drove a real refresh through HA's
LocalOAuth2Implementation._token_request, which builds an aiohttp clientsession
whose pycares DNS resolver leaves a daemon _run_safe_shutdown_loop thread. The
CI matrix runs Python 3.12, which backtracks to homeassistant 2025.1.4 +
pytest-homeassistant-custom-component 0.13.205 -- a build predating the
lingering-thread whitelist for that thread -- so teardown failed the test. It
passed locally on 3.13 / 0.13.316, which whitelists it.
Patch the superclass _token_request (HA's HTTP boundary) instead of mocking the
network, so no clientsession or pycares thread is created. The mixin unwrap
wiring is still exercised; {code,data} envelope handling stays covered by the
three pure _unwrap_utec_token tests and test_oauth_wiring.py. Version-agnostic:
passes on both the old and new pytest-HA-CC.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent a89d46c commit ff57549
1 file changed
Lines changed: 18 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
46 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
47 | 58 | | |
48 | 59 | | |
49 | 60 | | |
50 | | - | |
51 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
52 | 66 | | |
53 | 67 | | |
54 | 68 | | |
| |||
0 commit comments