petermr / amilib

Python library of `ami` software especially NLP, HTML, downloading and related convenience utilities
Apache License 2.0
1 stars 0 forks source link

argparse.ArgumentError: argument command: conflicting subparser: HTML #17

Open Smritiabcd opened 4 months ago

Smritiabcd commented 4 months ago

Windows 11, Python 3.12 '''

C:\Users\asus\Desktop\Semantic\amilib\test> pytest test_pdf.py::PDFMainArgTest::test_cannot_iterate ======================================================= test session starts ======================================================== platform win32 -- Python 3.12.3, pytest-8.2.0, pluggy-1.5.0 rootdir: C:\Users\asus\Desktop\Semantic\amilib collected 1 item

test_pdf.py F [100%]

============================================================= FAILURES ============================================================= ____ PDFMainArgTest.test_cannot_iterate ____

self =

def test_cannot_iterate(self):
    """
    Test that 'PDF' subcomand works without errors
    """
  AmiLib().run_command(

['HTML'])

test_pdf.py:1814:


..\amilib\amix.py:155: in run_command self.parse_and_run_args(args) ..\amilib\amix.py:169: in parse_and_run_args parser = self.create_arg_parser() ..\amilib\amix.py:95: in create_arg_parser amilib_parser = AmiLibArgs().make_sub_parser(subparsers) ..\amilib\util.py:829: in make_sub_parser self.parser = subparsers.add_parser(self.subparser_arg)


self = _SubParsersAction(option_strings=[], dest='command', nargs='A...', const=None, default=None, type=None, choices={'HTML...escriptionHelpFormatter'>, conflict_handler='error', add_help=True)}, required=False, help='subcommands', metavar=None) name = 'HTML', kwargs = {'prog': 'pytest HTML'}, aliases = ()

def add_parser(self, name, **kwargs):
    # set prog from the existing prefix
    if kwargs.get('prog') is None:
        kwargs['prog'] = '%s %s' % (self._prog_prefix, name)

    aliases = kwargs.pop('aliases', ())

    if name in self._name_parser_map:
      raise ArgumentError(self, _('conflicting subparser: %s') % name)

E argparse.ArgumentError: argument command: conflicting subparser: HTML

......\Internship\Lib\argparse.py:1219: ArgumentError ------------------------------------------------------- Captured stdout call ------------------------------------------------------- command: ['HTML'] ===================================================== short test summary info ====================================================== FAILED test_pdf.py::PDFMainArgTest::test_cannot_iterate - argparse.ArgumentError: argument command: conflicting subparser: HTML ======================================================== 1 failed in 9.94s =========================================================

petermr commented 4 months ago

I MAY have fixed this. I can't test it as it doesn't fail for me. BUT html_args behaves strangely. I have added try to the imports in amix.py

try:
    from html_args import HTMLArgs
except ModuleNotFoundError as e:
    from amilib.html_args import HTMLArgs

from amilib.pdf_args import PDFArgs

I have committed new source code. Please git pull and rerun pytest

petermr commented 4 months ago

Some of this may be down to relative-versus-absolute import. I have committed the latest main branch and also created a relative branch in case we need to explore that.

Smritiabcd commented 3 months ago

Tried running the test and still having the same issues

''' =============================================== short test summary info =============================================== FAILED test_pdf.py::PDFMainArgTest::test_cannot_iterate - argparse.ArgumentError: argument command: conflicting subparser: HTML FAILED test_pdf.py::PDFMainArgTest::test_pdf_help - argparse.ArgumentError: argument command: conflicting subparser: HTML FAILED test_pdf.py::PDFMainArgTest::test_pdf_html_ipcc_command_help - argparse.ArgumentError: argument command: conflicting subparser: HTML FAILED test_pdf.py::PDFMainArgTest::test_subcommands - argparse.ArgumentError: argument command: conflicting subparser: HTML FAILED test_pdf.py::PDFMainArgTest::test_subcommands_1 - argparse.ArgumentError: argument command: conflicting subparser: HTML