Skip to content

KeyError: 'testpaths' exception raised when using --override-ini command line option #2105

Closed
@mbukatov

Description

@mbukatov

Summary of the issue

When I use --override-ini feature while specifying particular test to run, py.test crashes with KeyError: 'testpaths' exception.

Description of a reproducer

Create minimal test case in ~/tmp directory so that:

$ cd ~/tmp
$ ls
test_foo.py
$ cat test_foo.py
def test_foo():
    assert True

Execution of this test case works as expected:

$ py.test 
============================== test session starts ===============================
platform linux -- Python 3.5.1, pytest-3.0.4, py-1.4.31, pluggy-0.4.0
rootdir: /home/usmqe/tmp, inifile: 
collected 1 items 

test_foo.py .

============================ 1 passed in 0.01 seconds ===========================

And there are no problems with invocations listed below either:

  • py.test test_foo.py
  • py.test --override-ini xfail_strict=True

But when I both reconfigure any configuration option via --override-ini and specify a test case at the same time, py.test crashes:

$ py.test --override-ini xfail_strict=True test_foo.py 
Traceback (most recent call last):
  File "/home/usmqe/.local/lib/python3.5/site-packages/_pytest/config.py", line 1064, in getini
    return self._inicache[name]
KeyError: 'testpaths'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/usmqe/.local/bin/py.test", line 11, in <module>
    sys.exit(main())
  File "/home/usmqe/.local/lib/python3.5/site-packages/_pytest/config.py", line 47, in main
    config = _prepareconfig(args, plugins)
  File "/home/usmqe/.local/lib/python3.5/site-packages/_pytest/config.py", line 132, in _prepareconfig
    pluginmanager=pluginmanager, args=args)
  File "/home/usmqe/.local/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/home/usmqe/.local/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/usmqe/.local/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/home/usmqe/.local/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File "/home/usmqe/.local/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
    wrap_controller.send(call_outcome)
  File "/home/usmqe/.local/lib/python3.5/site-packages/_pytest/helpconfig.py", line 32, in pytest_cmdline_parse
    config = outcome.get_result()
  File "/home/usmqe/.local/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/usmqe/.local/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
    self.result = func()
  File "/home/usmqe/.local/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
    res = hook_impl.function(*args)
  File "/home/usmqe/.local/lib/python3.5/site-packages/_pytest/config.py", line 882, in pytest_cmdline_parse
    self.parse(args)
  File "/home/usmqe/.local/lib/python3.5/site-packages/_pytest/config.py", line 1045, in parse
    args = self.getini('testpaths')
  File "/home/usmqe/.local/lib/python3.5/site-packages/_pytest/config.py", line 1066, in getini
    self._inicache[name] = val = self._getini(name)
  File "/home/usmqe/.local/lib/python3.5/site-packages/_pytest/config.py", line 1074, in _getini
    value = self._get_override_ini_value(name)
  File "/home/usmqe/.local/lib/python3.5/site-packages/_pytest/config.py", line 1123, in _get_override_ini_value
    (key, user_ini_value) = ini_config.split("=", 1)
ValueError: not enough values to unpack (expected 2, got 1)

Enviroment

I'm using Python 3.5.1 (from rh-python35 collection on RHEL 7):

$ python --version
Python 3.5.1
$ rpm -qf $(which python)
rh-python35-python-3.5.1-6.el7.x86_64

And Pytest 3.0.4:

$ py.test --version
This is pytest version 3.0.4, imported from /home/usmqe/.local/lib/python3.5/site-packages/pytest.py

The rest of python environment:

$ pip list
You are using pip version 7.1.0, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
docutils (0.12)
Jinja2 (2.8)
MarkupSafe (0.23)
mrglog (0.1.1)
pip (7.1.0)
plumbum (1.6.2)
py (1.4.31)
pytest (3.0.4)
PyYAML (3.10)
requests (2.11.1)
setuptools (18.0.1)
virtualenv (13.1.2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions