You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AttributeError: 'DoctestItem' object has no attribute 'fixturenames' #5070
File "…/Vcs/pytest/src/_pytest/main.py", line 261, in pytest_collection
return session.perform_collect()
File "…/Vcs/pytest/src/_pytest/main.py", line 500, in perform_collect
session=self, config=self.config, items=items
File "…/Vcs/pluggy/pluggy/hooks.py", line 289, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "…/Vcs/pluggy/pluggy/manager.py", line 68, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "…/Vcs/pluggy/pluggy/manager.py", line 62, in <lambda>
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
File "…/Vcs/pluggy/pluggy/callers.py", line 208, in _multicall
return outcome.get_result()
File "…/Vcs/pluggy/pluggy/callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "…/Vcs/pluggy/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "…/Vcs/pytest/testing/conftest.py", line 6, in pytest_collection_modifyitems
for item in items:
AttributeError: 'DoctestItem' object has no attribute 'fixturenames'
This was fixed for --fixtures-per-test in #2789, but I think it would be better to just have an empty list there maybe?
Any pointers in how to address this?
It's really unfortunate that every possible plugin has to handle/ignore that - especially since it might only happen then when using doctests (as within pytest's own tests).
I think it should be a given that items ins pytest_collection_modifyitems have an fixturenames attribute, no?
i believe it will happen to practically all item types that have no direct fixture system integration (aka 3rd party plugins as well, its really tricky to touch
From a "pure" design POV it would not be nice, because items are generic and might be customizable. Fixtures are a feature only available on pytest.Function objects. On the other hand, from a practibility POV it might make sense.
But I lean towards the former, otherwise we now have this implicit contract that pytest.Itemneeds to support all methods/attributes a pytest.Function does.
I know it sucks and it trips some people, but down the road we might make things worse for ourselves if we have to guarantee that all items have a pytest.Function-like interface.
Activity
blueyed commentedon Nov 9, 2019
Any pointers in how to address this?
It's really unfortunate that every possible plugin has to handle/ignore that - especially since it might only happen then when using doctests (as within pytest's own tests).
I think it should be a given that items ins
pytest_collection_modifyitemshave anfixturenamesattribute, no?RonnyPfannschmidt commentedon Nov 10, 2019
i believe it will happen to practically all item types that have no direct fixture system integration (aka 3rd party plugins as well, its really tricky to touch
nicoddemus commentedon Nov 13, 2019
Yeah as @RonnyPfannschmidt said, custom items which don't implement fixtures, while uncommon, are a definite possibility (besides Doctests, pytest-cpp also has custom items).
Unfortunately I don't have any idea on how to improve this situation.
Unless somebody has a suggestion, I think we should close this. :/
blueyed commentedon Nov 13, 2019
What about a mixin / base class to have an empty list there?
nicoddemus commentedon Nov 13, 2019
From a "pure" design POV it would not be nice, because items are generic and might be customizable. Fixtures are a feature only available on
pytest.Functionobjects. On the other hand, from a practibility POV it might make sense.But I lean towards the former, otherwise we now have this implicit contract that
pytest.Itemneeds to support all methods/attributes apytest.Functiondoes.I know it sucks and it trips some people, but down the road we might make things worse for ourselves if we have to guarantee that all items have a
pytest.Function-like interface.