Skip to content

AttributeError: 'Config' object has no attribute 'cache' with cacheprovider disabled #408

@mandeepsandhu

Description

@mandeepsandhu

Python Version

3.8.10

pytest Version

6.2.5

Package Version

3.10.1

Description

pytest fails to run tests if cacheprovider plugin is disabled during test execution.

Steps to reproduce error

  1. Sample test:
$ cat test_pass.py
def test_pass1():
    assert True

def test_pass2():
    assert True
  1. Run test with pytest caching disabled:
$ pytest -p no:cacheprovider test_pass.py -v
================================================================================= test session starts =================================================================================
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3
rootdir: /tmp/pytest-of-mandeepsandhu/mytest
collected 2 items                                                                                                                                                                     

test_pass.py::test_pass1 PASSED                                                                                                                                                 [ 50%]
test_pass.py::test_pass2 PASSED                                                                                                                                                 [100%]

================================================================================== 2 passed in 0.00s ==================================================================================

  1. Install pytest-randomly and repeat step 2
$ pip install --user pytest-randomly
...
Successfully installed pytest-randomly-3.10.1
$ pytest -p no:cacheprovider test_pass.py -v
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/mandeepsandhu/.local/lib/python3.8/site-packages/_pytest/main.py", line 265, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>   File "/home/mandeepsandhu/.local/lib/python3.8/site-packages/_pytest/config/__init__.py", line 982, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>   File "/home/mandeepsandhu/.local/lib/python3.8/site-packages/pluggy/hooks.py", line 308, in call_historic
INTERNALERROR>     res = self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/home/mandeepsandhu/.local/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/home/mandeepsandhu/.local/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR>   File "/home/mandeepsandhu/.local/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/mandeepsandhu/.local/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/mandeepsandhu/.local/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/mandeepsandhu/.local/lib/python3.8/site-packages/pytest_randomly/__init__.py", line 116, in pytest_configure
INTERNALERROR>     assert config.cache is not None
INTERNALERROR> AttributeError: 'Config' object has no attribute 'cache'
  1. Running with randomly disabled, works:
$ pytest -p no:cacheprovider -p no:randomly test_pass.py -v
================================================================================= test session starts =================================================================================
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3
rootdir: /tmp/pytest-of-mandeepsandhu/mytest
collected 2 items                                                                                                                                                                     

test_pass.py::test_pass1 PASSED                                                                                                                                                 [ 50%]
test_pass.py::test_pass2 PASSED                                                                                                                                                 [100%]

================================================================================== 2 passed in 0.00s ==================================================================================

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