alex-rudakov / sphinx-argparse

Sphinx extension that automatically document argparse commands and options
MIT License
49 stars 40 forks source link

0.2.5: pytest is failing #137

Open kloczek opened 3 years ago

kloczek commented 3 years ago
+ /usr/bin/python3 -Bm pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.9, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
Using --randomly-seed=164615581
rootdir: /home/tkloczko/rpmbuild/BUILD/sphinx-argparse-0.2.5
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, httpbin-1.0.0, xdist-2.2.1, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, pyfakefs-4.4.0, freezegun-0.4.2, cases-3.4.6, case-1.5.3, isort-1.3.0, aspectlib-1.5.2, asyncio-0.15.1, toolbox-0.5, xprocess-0.17.1, flaky-3.7.0, aiohttp-0.3.0, checkdocs-2.7.0, mock-3.6.1, rerunfailures-9.1.1, requests-mock-1.9.3, hypothesis-6.13.7, Faker-8.4.0, cov-2.12.1, randomly-3.8.0
collected 16 items

test/test_parser.py ..F.....FF.F                                                                                                                                     [ 75%]
. .                                                                                                                                                                  [ 81%]
test/test_parser.py ...                                                                                                                                              [100%]

================================================================================= FAILURES =================================================================================
__________________________________________________________________________ test_aliased_traversal __________________________________________________________________________

    def test_aliased_traversal():
        parser = argparse.ArgumentParser()

        subparsers1 = parser.add_subparsers()
        subparsers1.add_parser('level1', aliases=['l1'])

        data = parse_parser(parser)

        data2 = parser_navigate(data, 'level1')

>       assert(data2 == {
            'bare_usage': 'py.test level1 [-h]',
            'help': '',
            'usage': 'usage: py.test level1 [-h]',
            'name': 'level1 (l1)',
            'identifier': 'level1'})
E       AssertionError: assert {'bare_usage'...l1 (l1)', ...} == {'bare_usage'...l1 (l1)', ...}
E         Omitting 3 identical items, use -vv to show
E         Differing items:
E         {'usage': 'usage: __main__.py level1 [-h]'} != {'usage': 'usage: py.test level1 [-h]'}
E         {'bare_usage': '__main__.py level1 [-h]'} != {'bare_usage': 'py.test level1 [-h]'}
E         Use -v to get the full diff

test/test_parser.py:261: AssertionError
_______________________________________________________________________ test_parse_nested_with_alias _______________________________________________________________________

    def test_parse_nested_with_alias():
        parser = argparse.ArgumentParser()
        parser.add_argument('foo', default=False, help='foo help')
        parser.add_argument('bar', default=False)

        subparsers = parser.add_subparsers()

        subparser = subparsers.add_parser('install', aliases=['i'], help='install help')
        subparser.add_argument('ref', type=str, help='foo1 help')
        subparser.add_argument('--upgrade', action='store_true', default=False, help='foo2 help')

        data = parse_parser(parser)

        assert data['action_groups'][0]['options'] == [
            {
                'name': ['foo'],
                'help': 'foo help',
                'default': False
            }, {
                'name': ['bar'],
                'help': '',
                'default': False
            }
        ]

>       assert data['children'] == [
            {
                'name': 'install (i)',
                'identifier': 'install',
                'help': 'install help',
                'usage': 'usage: py.test install [-h] [--upgrade] ref',
                'bare_usage': 'py.test install [-h] [--upgrade] ref',
                'action_groups': [
                    {
                        'title': 'Positional Arguments',
                        'description': None,
                        'options': [
                            {
                                'name': ['ref'],
                                'help': 'foo1 help',
                                'default': None
                            }
                        ]
                    },
                    {
                        'description': None,
                        'title': 'Named Arguments',
                        'options': [
                            {
                                'name': ['--upgrade'],
                                'default': False,
                                'help': 'foo2 help'
                            }
                        ]
                    }
                ]
            }
        ]
E       AssertionError: assert [{'action_gro...nstall', ...}] == [{'action_gro...nstall', ...}]
E         At index 0 diff: {'name': 'install (i)', 'help': 'install help', 'usage': 'usage: __main__.py install [-h] [--upgrade] ref', 'bare_usage': '__main__.py install [-h] [--upgrade] ref', 'identifier': 'install', 'action_groups': [{'title': 'Positional Arguments', 'description': None, 'options': [{'name': ['ref'], 'default': None, 'help': 'foo1 help'}]}, {'title': 'Named Arguments', 'description': None, 'options': [{'name': ['--upgrade'], 'default': False, 'help': 'foo2 help'}]}]} != {'name': 'install (i)', 'identifier': 'install', 'help': 'install help', 'usage': 'usage: py...
E
E         ...Full output truncated (2 lines hidden), use '-vv' to show

test/test_parser.py:217: AssertionError
_______________________________________________________________________ test_parse_nested_traversal ________________________________________________________________________

    def test_parse_nested_traversal():
        parser = argparse.ArgumentParser()

        subparsers1 = parser.add_subparsers()
        subparser1 = subparsers1.add_parser('level1')

        subparsers2 = subparser1.add_subparsers()
        subparser2 = subparsers2.add_parser('level2')

        subparsers3 = subparser2.add_subparsers()
        subparser3 = subparsers3.add_parser('level3')

        subparser3.add_argument('foo', help='foo help')
        subparser3.add_argument('bar')

        data = parse_parser(parser)

        data3 = parser_navigate(data, 'level1 level2 level3')

        assert data3['action_groups'][0]['options'] == [
            {
                'name': ['foo'],
                'help': 'foo help',
                'default': None
            }, {
                'name': ['bar'],
                'help': '',
                'default': None
            }
        ]

        data2 = parser_navigate(data, 'level1 level2')
>       assert data2['children'] == [
            {
                'name': 'level3',
                'help': '',
                'usage': 'usage: py.test level1 level2 level3 [-h] foo bar',
                'bare_usage': 'py.test level1 level2 level3 [-h] foo bar',
                'action_groups': [
                    {
                        'title': 'Positional Arguments',
                        'description': None,
                        'options': [
                            {
                                'default': None,
                                'name': ['foo'],
                                'help': 'foo help'
                            }, {
                                'name': ['bar'],
                                'help': '',
                                'default': None
                            }
                        ]
                    }
                ]
            }
        ]
E       AssertionError: assert [{'action_gro...level3', ...}] == [{'action_gro...level3', ...}]
E         At index 0 diff: {'name': 'level3', 'help': '', 'usage': 'usage: __main__.py level1 level2 level3 [-h] foo bar', 'bare_usage': '__main__.py level1 level2 level3 [-h] foo bar', 'action_groups': [{'title': 'Positional Arguments', 'description': None, 'options': [{'name': ['foo'], 'default': None, 'help': 'foo help'}, {'name': ['bar'], 'default': None, 'help': ''}]}]} != {'name': 'level3', 'help': '', 'usage': 'usage: py.test level1 level2 level3 [-h] foo bar', 'bare_usage': 'py.test level1 level2 level3 [-h] foo bar', 'action_groups': [{'title': 'Positional Arguments', 'd...
E
E         ...Full output truncated (2 lines hidden), use '-vv' to show

test/test_parser.py:301: AssertionError
____________________________________________________________________________ test_parse_nested _____________________________________________________________________________

    def test_parse_nested():
        parser = argparse.ArgumentParser()
        parser.add_argument('foo', default=False, help='foo help')
        parser.add_argument('bar', default=False)

        subparsers = parser.add_subparsers()

        subparser = subparsers.add_parser('install', help='install help')
        subparser.add_argument('ref', type=str, help='foo1 help')
        subparser.add_argument('--upgrade', action='store_true', default=False, help='foo2 help')

        data = parse_parser(parser)

        assert data['action_groups'][0]['options'] == [
            {
                'name': ['foo'],
                'help': 'foo help',
                'default': False
            }, {
                'name': ['bar'],
                'help': '',
                'default': False
            }
        ]

>       assert data['children'] == [
            {
                'name': 'install',
                'help': 'install help',
                'usage': 'usage: py.test install [-h] [--upgrade] ref',
                'bare_usage': 'py.test install [-h] [--upgrade] ref',
                'action_groups': [
                    {
                        'title': 'Positional Arguments',
                        'description': None,
                        'options': [
                            {
                                'name': ['ref'],
                                'help': 'foo1 help',
                                'default': None
                            }
                        ]
                    },
                    {
                        'description': None,
                        'title': 'Named Arguments',
                        'options': [
                            {
                                'name': ['--upgrade'],
                                'default': False,
                                'help': 'foo2 help'
                            }
                        ]
                    }
                ]
            }
        ]
E       AssertionError: assert [{'action_gro...nstall', ...}] == [{'action_gro...nstall', ...}]
E         At index 0 diff: {'name': 'install', 'help': 'install help', 'usage': 'usage: __main__.py install [-h] [--upgrade] ref', 'bare_usage': '__main__.py install [-h] [--upgrade] ref', 'action_groups': [{'title': 'Positional Arguments', 'description': None, 'options': [{'name': ['ref'], 'default': None, 'help': 'foo1 help'}]}, {'title': 'Named Arguments', 'description': None, 'options': [{'name': ['--upgrade'], 'default': False, 'help': 'foo2 help'}]}]} != {'name': 'install', 'help': 'install help', 'usage': 'usage: py.test install [-h] [--upgrade] ref', 'bare_usage': 'py.tes...
E
E         ...Full output truncated (2 lines hidden), use '-vv' to show

test/test_parser.py:157: AssertionError
========================================================================= short test summary info ==========================================================================
FAILED test/test_parser.py::test_aliased_traversal - AssertionError: assert {'bare_usage'...l1 (l1)', ...} == {'bare_usage'...l1 (l1)', ...}
FAILED test/test_parser.py::test_parse_nested_with_alias - AssertionError: assert [{'action_gro...nstall', ...}] == [{'action_gro...nstall', ...}]
FAILED test/test_parser.py::test_parse_nested_traversal - AssertionError: assert [{'action_gro...level3', ...}] == [{'action_gro...level3', ...}]
FAILED test/test_parser.py::test_parse_nested - AssertionError: assert [{'action_gro...nstall', ...}] == [{'action_gro...nstall', ...}]
======================================================================= 4 failed, 12 passed in 6.80s =======================================================================