Commit ff3405d
authored
Make script and OIDC logout tests robust to serial (-n0) execution (#3507)
## Description
Makes four tests robust to running serially with pytest-xdist disabled
(`-n0`). They pass under the normal xdist test run but fail under `-n0`,
which is how the backwards-compatibility CI check (#3506) runs a
previous release's database suite against the current schema.
- **Three script tests** (`test_equivalents`, `test_novelist`,
`test_search`) constructed a `Script` with no `cmd_args` and called
`do_run()`, so the script's argparse fell back to `sys.argv[1:]`. Under
xdist each worker has a clean execnet `sys.argv`, but under `-n0`
`sys.argv` is the real pytest command line. That caused argparse to
error on unrecognized arguments (`equivalents`, `novelist`), and the
leaked `-m db` marker matched `RebuildSearchIndexScript`'s
`-m/--migration` flag, sending it down the migration path so
`search_reindex.delay` was never called (`search`). Each now passes an
explicit `cmd_args=[]` to express "no arguments" independent of
`sys.argv`.
- **The OIDC logout test**
(`test_oidc_logout_initiate_no_stored_id_token`) asserted on `caplog`
without setting a capture level. Under serial execution the effective
log level is left raised by an earlier test, so the warning was not
captured and `caplog.text` was empty. It now sets the level explicitly,
matching its passing sibling
`test_oidc_logout_initiate_revocation_only`.
No production code changes — scripts intentionally default `cmd_args` to
`sys.argv` for real CLI use via `Script.run()`.
## Motivation and Context
The backwards-compatibility check added in #3506 runs the previous
release's `-m db` suite under `-n0` (external-schema mode requires
serial execution — the single shared database can't be used by parallel
xdist workers). Its first real run surfaced these four latent
test-isolation bugs, which xdist had been masking. None are
schema-compatibility failures; all four fail identically against the
previous release's own schema. Fixing them here means that once a
release containing these fixes becomes the "previous release", the check
will pass against it.
## How Has This Been Tested?
Reproduced the failures on the unfixed tests by running them under `-n0`
in the docker test environment (`tox -e py312-docker -- -n0 ...`),
observing the argparse `unrecognized arguments` errors. With the fixes
applied, all four pass under `-n0` (including with `-m db` present,
which exercises the `search` flag-collision case): `60 passed, 19
deselected`.
## Checklist
- [x] I have updated the documentation accordingly.
- [x] All new and existing tests passed.1 parent e5d6c25 commit ff3405d
4 files changed
Lines changed: 4 additions & 3 deletions
File tree
- tests/manager
- integration/patron_auth/oidc
- scripts
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
971 | 971 | | |
972 | 972 | | |
973 | 973 | | |
| 974 | + | |
974 | 975 | | |
975 | 976 | | |
976 | 977 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
0 commit comments