kislyuk / argcomplete

Python and tab completion, better together.
https://kislyuk.github.io/argcomplete/
Apache License 2.0
1.39k stars 129 forks source link

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

Closed penguinpee closed 2 months ago

penguinpee commented 2 months ago

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' ```python ====================================================================== 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 commented 2 months ago

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.

penguinpee commented 2 months ago

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 commented 2 months ago

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 https://github.com/kislyuk/argcomplete/issues/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 commented 2 months ago

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

kislyuk commented 2 months ago

Fix released in v3.3.0.