Skip to content

UserWarning in test_argparse #124245

Closed
Closed
@serhiy-storchaka

Description

@serhiy-storchaka

Running test_argparse with option -We fails:

$ ./python -We -m test -vuall test_argparse -m test_invalid_args
...
======================================================================
ERROR: test_invalid_args (test.test_argparse.TestIntermixedArgs.test_invalid_args)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/test_argparse.py", line 5815, in test_invalid_args
    parser.parse_intermixed_args(['hello', '--foo'])
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/home/serhiy/py/cpython/Lib/argparse.py", line 2386, in parse_intermixed_args
    args, argv = self.parse_known_intermixed_args(args, namespace)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/serhiy/py/cpython/Lib/argparse.py", line 2440, in parse_known_intermixed_args
    warn('Do not expect %s in %s' % (action.dest, namespace))
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UserWarning: Do not expect foo in Namespace(foo=[])

----------------------------------------------------------------------

The test was added in gh-103558. cc @gaogaotiantian

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixestestsTests in the Lib/test dir

    Projects

    Status

    Doc issues

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions