Commit 9a22a76
Review
fix(tests): reset session adapters after import-time HTTP calls
The test conftest opens HTTP connections at import time via
``run_until_complete`` to check ``app_api`` capability and (later) NC
version. After the sync removal in v0.31.0 those connections live in
niquests AsyncSession pools bound to whatever event loop ran the
``run_until_complete`` call. pytest-asyncio runs the actual tests on a
different loop, so the first request hits a stale pooled connection and
fails with::
RuntimeError: got Future <Future pending> attached to a different loop
Recreate the session adapters (``init_adapter(restart=True)`` and
``init_adapter_dav(restart=True)``) right after the import-time check so
pytest's loop populates fresh empty pools lazily on first use. Apply the
same reset after the version lookup in ``pytest_collection_modifyitems``,
and short-circuit that hook entirely when no test carries the
``require_nc`` marker.1 parent 1354abe commit 9a22a76
1 file changed
Lines changed: 22 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
13 | 26 | | |
14 | 27 | | |
15 | 28 | | |
| |||
23 | 36 | | |
24 | 37 | | |
25 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
26 | 42 | | |
27 | 43 | | |
28 | 44 | | |
| |||
105 | 121 | | |
106 | 122 | | |
107 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
108 | 130 | | |
109 | 131 | | |
110 | 132 | | |
111 | 133 | | |
112 | 134 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | 135 | | |
117 | 136 | | |
118 | 137 | | |
| |||
0 commit comments