MatthewFlamm / pytest-homeassistant-custom-component

Package to automatically extract testing plugins from Home Assistant for custom component testing
MIT License
66 stars 10 forks source link

Fixture paths don't seem compatible with core #169

Open ScottG489 opened 1 year ago

ScottG489 commented 1 year ago

So I just synced my custom_component repo with some changes from my integration in core and came across an issue with paths to fixtures.

As the docs require, the fixtures in both instances (core and custom) are in the fixtures dir alongside the tests. However, when calling load_fixture it was necessary for me to remove the integration's domain name from the path for the custom component.

Compare this example from core and example from my custom_component. If I don't have the domain name (trello) in the path when in core, the test breaks, and if I do have in the path in the custom component, it breaks on that side.

Keeping it the same as in core (domain included) results in this error:

FileNotFoundError: [Errno 2] No such file or directory: '<path to project>/tests/components/<domain>/fixtures/batch.json'

From looking at the docs, it seems like things should work without modification and I seem to be following what's necessary (a fixtures dir). Am I missing something here?

I'm on version 0.13.66.

MatthewFlamm commented 9 months ago

It seems like you are asking for this package to support more or less drop-in behavior to home-assistant core component. If we do this, we should track items needed for this goal. I assume you can put your tests in tests/components/<domain>/test_*.py, but I haven't tested this.

Also it would be good to ensure we support both cases as there are probably equally or more users who have standalone custom components and this would be a breaking change for them.