Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.13: Some tests fail when run with latest Python pre-release #480

Closed
penguinpee opened this issue Apr 8, 2024 · 5 comments
Closed

Comments

@penguinpee
Copy link

penguinpee commented Apr 8, 2024

Fedora is preparing for updating Python to the next major release. During testing some tests were observed to fail when run with Python 3.13.0a5.

Output from 'python3 test/test.py -vv'
======================================================================
ERROR: test_repl_parse_after_complete (__main__.TestArgcompleteREPL.test_repl_parse_after_complete)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/argcomplete-3.2.3/test/test.py", line 934, in test_repl_parse_after_complete
    args = p.parse_args(["--foo", "spam", "bar"])
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.13/argparse.py", line 1916, in parse_args
    args, argv = self.parse_known_args(args, namespace)
                 ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.13/argparse.py", line 1949, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
                      ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/argcomplete-3.2.3/argcomplete/packages/_argparse.py", line 299, in _parse_known_args
    start_index = consume_optional(start_index)
                  ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/builddir/build/BUILD/argcomplete-3.2.3/argcomplete/packages/_argparse.py", line 165, in consume_optional
    action, option_string, explicit_arg = option_tuple
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: too many values to unpack (expected 3)
======================================================================
FAIL: test_choices (__main__.TestArgcomplete.test_choices)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/argcomplete-3.2.3/test/test.py", line 179, in test_choices
    self.assertEqual(set(self.run_completer(make_parser(), cmd)), set(output))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Items in the first set but not the second:
'--help'
'-h'
'--ship'
Items in the second set but not the first:
'speedboat'
'submarine'
======================================================================
FAIL: test_completers (__main__.TestArgcomplete.test_completers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/argcomplete-3.2.3/test/test.py", line 300, in test_completers
    self.assertEqual(set(self.run_completer(make_parser(), cmd)), set(output))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Items in the first set but not the second:
'--help'
'--email'
'-h'
'--url'
Items in the second set but not the first:
'http://url1'
'http://url2'
======================================================================
FAIL: test_default_completer (__main__.TestArgcomplete.test_default_completer)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/argcomplete-3.2.3/test/test.py", line 424, in test_default_completer
    self.assertEqual(set(self.run_completer(make_parser(), cmd)), set(output))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Items in the first set but not the second:
'--many'
'--one'
Items in the second set but not the first:
'test/'
======================================================================
FAIL: test_escape_special_chars (__main__.TestArgcomplete.test_escape_special_chars)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/argcomplete-3.2.3/test/test.py", line 832, in test_escape_special_chars
    self.assertEqual(set(self.run_completer(make_parser(), "prog -1 ")), {r"bar\<\$\>baz "})
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Items in the first set but not the second:
'-3'
'-2'
'-1'
Items in the second set but not the first:
'bar\\<\\$\\>baz '
======================================================================
FAIL: test_exclusive (__main__.TestArgcomplete.test_exclusive)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/argcomplete-3.2.3/test/test.py", line 773, in test_exclusive
    self.assertEqual(set(self.run_completer(make_parser(), cmd)), set(output))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Items in the first set but not the second:
'--no-bar'
======================================================================
FAIL: test_exclusive_class (__main__.TestArgcomplete.test_exclusive_class)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/argcomplete-3.2.3/test/test.py", line 822, in test_exclusive_class
    self.assertEqual(set(self.run_completer(parser, cmd, completer=completer)), set(output))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Items in the first set but not the second:
'--foo'
'--bar'
'--baz'
'--no-bar'
Items in the second set but not the first:
'baz1'
'baz2'
======================================================================
FAIL: test_filescompleter_filetype_integration (__main__.TestArgcomplete.test_filescompleter_filetype_integration)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/argcomplete-3.2.3/test/test.py", line 378, in test_filescompleter_filetype_integration
    self.assertEqual(set(self.run_completer(make_parser(), cmd)), set(output))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Items in the first set but not the second:
'--r'
'--help'
'-h'
'--w'
Items in the second set but not the first:
'abcxyz'
'abcaha/'
'abcdefж/'
======================================================================
FAIL: test_mixed_optional_positional (__main__.TestArgcomplete.test_mixed_optional_positional)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/argcomplete-3.2.3/test/test.py", line 793, in test_mixed_optional_positional
    self.assertEqual(set(self.run_completer(make_parser(), cmd)), set(output))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Items in the first set but not the second:
'--set'
Items in the second set but not the first:
'name2'
'name1'
======================================================================
FAIL: test_non_ascii (__main__.TestArgcomplete.test_non_ascii)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/argcomplete-3.2.3/test/test.py", line 482, in test_non_ascii
    self.assertEqual(set(self.run_completer(make_parser(), cmd)), set(output))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Items in the first set but not the second:
'-h'
'--help'
'--книга'
Items in the second set but not the first:
'Трудно\\ быть\\ богом'
'Понедельник\\ начинается\\ в\\ субботу'
'Парень\\ из\\ преисподней'
======================================================================
FAIL: test_optional_nargs (__main__.TestArgcomplete.test_optional_nargs)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/argcomplete-3.2.3/test/test.py", line 697, in test_optional_nargs
    self.assertEqual(set(self.run_completer(make_parser(), cmd)), set(output))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Items in the first set but not the second:
'-h'
'--qux'
'--foobar'
'--baz'
'--bar'
'--help'
'--foo'
Items in the second set but not the first:
'foo1'
'foo2'
======================================================================
FAIL: test_positional_remainder (__main__.TestArgcomplete.test_positional_remainder)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/argcomplete-3.2.3/test/test.py", line 717, in test_positional_remainder
    self.assertEqual(set(self.run_completer(make_parser(), cmd)), set(output))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Items in the second set but not the first:
'pos'
'--opt'
======================================================================
FAIL: test_subparser_completers (__main__.TestArgcomplete.test_subparser_completers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/argcomplete-3.2.3/test/test.py", line 345, in test_subparser_completers
    self.assertEqual(set(self.run_completer(make_parser(), cmd)), set(output))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Items in the second set but not the first:
'val5'
======================================================================
FAIL: test_subparsers (__main__.TestArgcomplete.test_subparsers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/argcomplete-3.2.3/test/test.py", line 451, in test_subparsers
    self.assertEqual(set(self.run_completer(make_parser(), cmd)), set(output))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Items in the first set but not the second:
'eggs'
'--age'
'spam'
Items in the second set but not the first:
'in\\ the\\ rain'
'with\\ a\\ goat'
'on\\ a\\ train'
'on\\ a\\ boat'
----------------------------------------------------------------------
Ran 186 tests in 141.060s
FAILED (failures=13, errors=1, skipped=12, expected failures=5)
@kislyuk
Copy link
Owner

kislyuk commented Apr 8, 2024

Thanks. Pytest is not a supported way to run tests in this project. Please run the tests using unittest and let us know if you still encounter difficulties.

@kislyuk kislyuk closed this as completed Apr 8, 2024
@penguinpee
Copy link
Author

Sorry I messed up there. I'm so used to test being run with pytest, that I typed that from muscle memory. Tests are run using python test/test.py -vv. The output is from that command.

@kislyuk kislyuk reopened this Apr 8, 2024
@kislyuk
Copy link
Owner

kislyuk commented Apr 8, 2024

Sounds good, thanks. It looks like argparse has received a number of updates in recent Python releases and this might affect argcomplete functionality. I've started tracking this in #481 for Python 3.11.9 but I'll keep this issue open to track Python 3.13 compatibility (which I suspect might be caused by the same underlying changes). Thanks fro the heads up, I'll take a look when I can.

@penguinpee
Copy link
Author

For what it's worth, all tests succeed at our end using Python 3.12.

@kislyuk
Copy link
Owner

kislyuk commented Apr 14, 2024

Fix released in v3.3.0.

@kislyuk kislyuk closed this as completed Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants