Open wbyoung opened 1 month ago
I'm guessing that if Syrupy is loaded second, that the options to configure the directory override what's setup by
pytest_homeassistant_custom_component
, but I can't be sure.
This seems very plausible, see
where homeassistant uses the same name of the fixture as syrupy itself. Given that this package is a plugin whereas the homeassistant tests conftest.py
is not a plugin, this could explain the difference why homeassistant CI does not have this problem. It would be ideal if we could fix it in this package somehow, but I'm not sure it is possible.
Your fix is mentioned in this thread https://github.com/pytest-dev/pytest/issues/935, which still seems unresolved. I'm not sure we can do anything about it other than putting it in the README for now.
Yup, I was reading that thread earlier. Your assessment seems in line with the (little) I know about this. Putting it in the Readme seems like a good resolution.
I have encountered a situation where tests pass locally and fail in CI because the snapshots generated by Syrupy can't be found.
I am getting the same symptom, but also it fails because the custom serializer is not used (e.g. timestamps are not set to <ANY>
).
The workaround that works for me is to duplicate the snapshot
fixture in my CC's conftest.py:
from pytest_homeassistant_custom_component.syrupy import HomeAssistantSnapshotExtension
from syrupy.assertion import SnapshotAssertion
...
@pytest.fixture
def snapshot(snapshot: SnapshotAssertion) -> SnapshotAssertion:
"""Return snapshot assertion fixture with the Home Assistant extension."""
return snapshot.use_extension(HomeAssistantSnapshotExtension)
I have encountered a situation where tests pass locally and fail in CI because the snapshots generated by Syrupy can't be found. I've found a solution to this issue which is to run the tests as
pytest -p syrupy
(or adding it toaddopts
under[tool:pytest]
in my config).I'm guessing that if Syrupy is loaded second, that the options to configure the directory override what's setup by
pytest_homeassistant_custom_component
, but I can't be sure.I don't know if there's a way to configure this to say it must be loaded after Syrupy, but that would probably be good. If not, maybe it may be useful to document it.