Opened 19 hours ago

Closed 5 hours ago

Last modified 5 hours ago

#37096 closed Bug (fixed)

test_invalid_choice_db_option fails on Python 3.14.5+

Reported by: Kasey Owned by: Kasey
Component: Core (Management commands) Version: dev
Severity: Release blocker Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

On Python 3.14.5+, admin_scripts.tests.CommandDBOptionChoiceTests.test_invalid_choice_db_option fails with:

AssertionError: "Error: argument --database: invalid choice: 'deflaut',
maybe you meant 'default'\? \(choose from default, other\)" does not match
"Error: argument --database: invalid choice: 'deflaut', maybe you meant
'default'? (choose from 'default', 'other')"

Cause

CPython 3.14.5 restored quoting of choice values in argparse's "invalid choice" error messages via cpython#149385 (3.14 backport of cpython#130751, tracked in cpython#130750). The choices formatter changed from:

'choices': ', '.join(map(str, action.choices))           # 3.14.0–3.14.4

to:

'choices': ', '.join(repr(str(choice)) for choice in action.choices)  # 3.14.5+

so the message goes from (choose from default, other) to (choose from 'default', 'other').

The PY314 branch of the test (added in commit b1a65eac7c, fixing #36321) expected the unquoted form. The pre-3.14 branch already handles both forms via '?default'?, '?other'?; aligning the PY314 branch with the same pattern fixes the test on all Python 3.14.x releases.

Scope

main only. stable/6.0.x and stable/5.2.x are unaffected — neither branch enables suggest_on_error (added in #36321 on main), and both already use the flexible '?default'?, '?other'? pattern.

Patch

Patch ready (one-line test regex fix). PR link will follow in a comment once the ticket is accepted.

Change History (6)

comment:1 by Kasey, 19 hours ago

Owner: set to Kasey
Status: newassigned

comment:2 by Jacob Walls, 12 hours ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

comment:3 by Kasey, 8 hours ago

Has patch: set

comment:5 by Jacob Walls <jacobtylerwalls@…>, 5 hours ago

Resolution: fixed
Status: assignedclosed

In ed13a58:

Fixed #37096 -- Fixed test_invalid_choice_db_option on Python 3.14.5+.

comment:6 by Jacob Walls, 5 hours ago

Triage Stage: AcceptedReady for checkin
Note: See TracTickets for help on using tickets.
Back to Top