pytest: pytest 5.0.1 cannot start with Python 3.5.2
python3 -mpytest -p no:cacheprovider test_example.py
[13:54:06] File "/home/automake/venvs/testenv/lib/python3.5/site-packages/pytest.py", line 102, in <module>
[13:54:06] raise SystemExit(pytest.main())
[13:54:06] File "/home/automake/venvs/testenv/lib/python3.5/site-packages/_pytest/config/__init__.py", line 55, in main
[13:54:06] config = _prepareconfig(args, plugins)
[13:54:06] File "/home/automake/venvs/testenv/lib/python3.5/site-packages/_pytest/config/__init__.py", line 200, in _prepareconfig
[13:54:06] pluginmanager=pluginmanager, args=args
[13:54:06] File "/home/automake/venvs/testenv/lib/python3.5/site-packages/pluggy/hooks.py", line 289, in __call__
[13:54:06] return self._hookexec(self, self.get_hookimpls(), kwargs)
[13:54:06] File "/home/automake/venvs/testenv/lib/python3.5/site-packages/pluggy/manager.py", line 87, in _hookexec
[13:54:06] return self._inner_hookexec(hook, methods, kwargs)
[13:54:06] File "/home/automake/venvs/testenv/lib/python3.5/site-packages/pluggy/manager.py", line 81, in <lambda>
[13:54:06] firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
[13:54:06] File "/home/automake/venvs/testenv/lib/python3.5/site-packages/pluggy/callers.py", line 203, in _multicall
[13:54:06] gen.send(outcome)
[13:54:06] File "/home/automake/venvs/testenv/lib/python3.5/site-packages/_pytest/helpconfig.py", line 89, in pytest_cmdline_parse
[13:54:06] config = outcome.get_result()
[13:54:06] File "/home/automake/venvs/testenv/lib/python3.5/site-packages/pluggy/callers.py", line 80, in get_result
[13:54:06] raise ex[1].with_traceback(ex[2])
[13:54:06] File "/home/automake/venvs/testenv/lib/python3.5/site-packages/pluggy/callers.py", line 187, in _multicall
[13:54:06] res = hook_impl.function(*args)
[13:54:06] File "/home/automake/venvs/testenv/lib/python3.5/site-packages/_pytest/config/__init__.py", line 661, in pytest_cmdline_parse
[13:54:06] self.parse(args)
[13:54:06] File "/home/automake/venvs/testenv/lib/python3.5/site-packages/_pytest/config/__init__.py", line 869, in parse
[13:54:06] self._preparse(args, addopts=addopts)
[13:54:06] File "/home/automake/venvs/testenv/lib/python3.5/site-packages/_pytest/config/__init__.py", line 803, in _preparse
[13:54:06] self._initini(args)
[13:54:06] File "/home/automake/venvs/testenv/lib/python3.5/site-packages/_pytest/config/__init__.py", line 728, in _initini
[13:54:06] args, namespace=copy.copy(self.option)
[13:54:06] File "/home/automake/venvs/testenv/lib/python3.5/site-packages/_pytest/config/argparsing.py", line 116, in parse_known_and_unknown_args
[13:54:06] optparser = self._getparser()
[13:54:06] File "/home/automake/venvs/testenv/lib/python3.5/site-packages/_pytest/config/argparsing.py", line 86, in _getparser
[13:54:06] optparser = MyOptionParser(self, self.extra_info, prog=self.prog)
[13:54:06] File "/home/automake/venvs/testenv/lib/python3.5/site-packages/_pytest/config/argparsing.py", line 333, in __init__
[13:54:06] allow_abbrev=False,
[13:54:06]TypeError: __init__() got an unexpected keyword argument 'allow_abbrev'
Caused by this commit: https://github.com/pytest-dev/pytest/commit/d72fb73fa091534a862dbe462257efeef7ecaa2f
It seems allow_abbrev doesn’t exist as a valid kwarg to argparse.ArgumentParser in Python 3.5.2:
>>> parser = argparse.ArgumentParser(prog='PROG', allow_abbrev=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __init__() got an unexpected keyword argument 'allow_abbrev'
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 31 (17 by maintainers)
IDK if it helps or not, but I encountered this problem with pytest 5.2.0 when I pip3 installed an unrelated package which (probably erroneously) installed the 1.4.0 version of argparse over the one installed in the standard library.
unless you’re doing weird things with
PYTHONPATH
even that shouldn’t matter –site-packages
is after the stdlib insys.path
ordering (unless something wacky / incorrect is going on)the closest I can get is
but that’s pretty nonsense :S
I just got this with Python 3.7, but I have no idea why. As I’m about to reinstall everything and I might never see it again, here it is:
@hexaclock I suspect you have either a poisoned
lib
directory (maybe from runningvirtualenv
against the same dir with an older python?) or a poisonedsys.path
(maybe fromPYTHONPATH
environment variable?)could you provide reproduction steps?