-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Description
https://docs.pytest.org/en/stable/how-to/cache.html#the-new-config-cache-object
in this example recommends accessing pytestconfig.cache which will crash at runtime if the cacheprovider plugin has been disabled as mentioned here:
_______________________________________________________________________________ ERROR at setup of test_function ________________________________________________________________________________
pytestconfig = <_pytest.config.Config object at 0x749189eaa7b0>
@pytest.fixture
def mydata(pytestconfig):
> val = pytestconfig.cache.get("example/value", None)
E AttributeError: 'Config' object has no attribute 'cache'
python/tests/test_asdf.py:12: AttributeError
=================================================================================== short test summary info ====================================================================================
ERROR python/tests/test_asdf.py::test_function - AttributeError: 'Config' object has no attribute 'cache'
======================================================================================= 1 error in 0.07s =======================================================================================
pytest should set the cache object to None when the plugin isn't enabled. that way, type checkers will report an error when attempting to use it without checking whether it's None
Metadata
Metadata
Assignees
Labels
No labels