Skip to content

nib-roi help message test failure with python3.14 #1446

@emollier

Description

@emollier

Hi,

While working on Debian bug #1121007, we noticed the following error in addition to the one reported in #1390:

_______________________________ test_entrypoint ________________________________

capsys = <_pytest.capture.CaptureFixture object at 0x76384b117230>

    def test_entrypoint(capsys):
        # Check that we handle missing args as expected
        with mock.patch('sys.argv', ['nib-roi', '--help']):
            with pytest.raises(SystemExit):
                main()
        captured = capsys.readouterr()
>       assert captured.out.startswith('usage: nib-roi')
E       assert False
E        +  where False = <built-in method startswith of str object at
0x35bbc9f0>('usage: nib-roi')
E        +    where <built-in method startswith of str object at
0x35bbc9f0> = "usage: python3.14 -m pytest [-h] [--version] [-i
I1:I2[:-1]] [-j J1:J2[:-1]]\n

This looked to be related to changes in argparse's behavior: the default value for the prog variable changed for something more subtle than its legacy value, causing the test failure with the apparition of the pytest command invocation instead of the nib-roi command as expected. I have worked around the problem by setting ArgParser's prog by hand to os.path.basename(sys.argv[0]), to match the legacy behavior. There may be other occurrences of this issue happening in other commands, I have not checked closely, but thought you might like to be aware of the problem.

In hope this helps,
Étienne.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions