Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#33082 closed Cleanup/optimization (fixed)

test_subparser_invalid_option regression with Python 3.9.7

Reported by: Michał Górny Owned by: Mariusz Felisiak
Component: Core (Other) Version: 3.2
Severity: Normal 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 (last modified by Michał Górny)

I'm getting the following test failure with Python 3.9.7:

======================================================================
FAIL: test_subparser_invalid_option (user_commands.tests.CommandTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.9/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/usr/lib/python3.9/unittest/case.py", line 592, in run
    self._callTestMethod(testMethod)
  File "/usr/lib/python3.9/unittest/case.py", line 550, in _callTestMethod
    method()
  File "/tmp/portage/dev-python/django-3.2.7/work/Django-3.2.7/tests/user_commands/tests.py", line 339, in test_subparser_invalid_option
    management.call_command('subparser', 'test', 12)
  File "/usr/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/tmp/portage/dev-python/django-3.2.7/work/Django-3.2.7/django/test/testcases.py", line 693, in _assert_raises_or_warns_cm
    self.assertIn(expected_message, str(getattr(cm, cm_attr)))
  File "/usr/lib/python3.9/unittest/case.py", line 1096, in assertIn
    self.fail(self._formatMessage(msg, standardMsg))
  File "/usr/lib/python3.9/unittest/case.py", line 668, in fail
    raise self.failureException(msg)
AssertionError: "Error: invalid choice: 'test' (choose from 'foo')" not found in "Error: argument {foo}: invalid choice: 'test' (choose from 'foo')"

It seems that the output change has been backported from Python 3.10 to 3.9.7.

Change History (7)

comment:1 by Michał Górny, 3 years ago

Description: modified (diff)

comment:2 by Mariusz Felisiak, 3 years ago

Component: UncategorizedCore (Other)
Has patch: set
Owner: changed from nobody to Mariusz Felisiak
Status: newassigned
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

Ahh yes, see https://github.com/python/cpython/commit/097801844c99ea3916bebe1cc761257ea7083d34. Thanks for the report.

I don't think it's worth switching msg between Python versions, PR.

comment:3 by Carlton Gibson, 3 years ago

Triage Stage: AcceptedReady for checkin

comment:4 by GitHub <noreply@…>, 3 years ago

Resolution: fixed
Status: assignedclosed

In 50ed545e:

Fixed #33082 -- Fixed CommandTests.test_subparser_invalid_option on Python 3.9.7+.

Thanks Michał Górny for the report.

comment:5 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

In b61f44c:

[3.2.x] Fixed #33082 -- Fixed CommandTests.test_subparser_invalid_option on Python 3.9.7+.

Thanks Michał Górny for the report.

Backport of 50ed545e2fa02c51e0d1559b83624f256e4b499b from main.

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

In 9dd1f957:

[3.1.x] Fixed #33082 -- Fixed CommandTests.test_subparser_invalid_option on Python 3.9.7+.

Thanks Michał Górny for the report.

Backport of 50ed545e2fa02c51e0d1559b83624f256e4b499b from main.

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

In 05bc1c81:

[2.2.x] Fixed #33082 -- Fixed CommandTests.test_subparser_invalid_option on Python 3.9.7+.

Thanks Michał Górny for the report.

Backport of 50ed545e2fa02c51e0d1559b83624f256e4b499b from main.

Note: See TracTickets for help on using tickets.
Back to Top