Tavern Marks Broken with Pytest 7.3.0
bramwelt opened this issue · 5 comments
Pytest's most recent release of 7.3.0 removes their reliance on the external attrs
package. This package is used for custom marks and the following kinds of errors are reported when ran with it:
/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/tavern/_core/pytest/file.py:361: in collect
for i in self._generate_items(test_spec):
/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/tavern/_core/pytest/file.py:336: in _generate_items
item.add_markers(pytest_marks)
/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/tavern/_core/pytest/item.py:127: in add_markers
new_mark = attr.evolve(pm.mark, args=pm.mark.args[0])
/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/attr/_funcs.py:357: in evolve
attrs = fields(cls)
/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/attr/_make.py:1923: in fields
raise NotAnAttrsClassError(f"{cls!r} is not an attrs-decorated class.")
E attr.exceptions.NotAnAttrsClassError: <class '_pytest.mark.structures.Mark'> is not an attrs-decorated class.
------------------------------- Captured stderr --------------------------------
/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/tavern/_core/pytest/file.py:62: PytestUnknownMarkWarning: Unknown pytest.mark.zoom - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
pytest_marks.append(getattr(pytest.mark, m))
Including attrs
in dependencies isn't enough to fix the issue. Restricting pytest<7.3.0
is currently the only fix I've found.
Can Tavern be updated to work with the newest version of pytest?
Workaround I used:
pip uninstall pytest
pip install pytest==7.2.2
Same issue here, same work around works (pinning in poetry).
yeah, same here.
pytest < 7.3.0 solves it, but should't be the permanent solution.
https://github.com/pytest-dev/pytest/blob/ef982aaf2bce28d6b27e24756a4d29377a593a1d/src/_pytest/mark/structures.py#L211 pytest has done some weird thing where they've defined the Mark
as a dataclass but then also overridden the init method so that the names of the arguments are different so I can't even do dataclasses.replace
onm it. I think this will end up having to be a horrible hack but I am just going to pin pytest to <7.3 for now
#901 This does fix it , unsure of what effect this will have on downstream projects though. I'd hope that most people wouldn't be depending on a specific version of Pytest