-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot get recorder_mock
fixture running
#132
Comments
I wonder if you cannot use the |
Nice catch! Yes I can confirm that the code above works when disabling the I just tried some other (combinations of) fixtures like I use the following |
Oh the order of the fixtures seems to be the solution! (Sorry it's my first time writing unit tests in python.) Just tried it with the async def test_sensor_service(recorder_mock, enable_custom_integrations, hass): Thank you for helping to understand this behaviour! |
No problem, your detailed information was really helpful. I debated for a long time whether to make |
If I may ask another question: Is there any way to disable the |
If all your tests need @pytest.fixture(autouse=True)
def my_fixture(recorder_mock, enable_custom_integrations):
pass If you don't need |
I've come across the very same issue and I've resolved this way.
You'll have to remove the As @MatthewFlamm correctly pointed out (this was one of the steps I went through) you could define your own auto_use with the correct ordering of fixtures call but then you would have to manage differentiating the tests as per his suggestion. |
Hi sorry to bug you with an issue but I cannot find any references online about this problem:
I'm finally trying to add some unit tests to my custom_component and basically need to make something like this for it: https://github.com/home-assistant/core/blob/dev/tests/components/tibber/test_statistics.py
Unfortunately whenever I use the
recorder_mock
fixture I get this error:I cannot find any setting I might need to set online. You can reproduce this error with a simple test like this:
The only "config" I set was
asyncio_mode
in thepyproject.toml
to get rid of the async errors:conftest.py
is basically unaltered from the template: https://github.com/custom-components/integration_blueprint/blob/master/tests/conftest.py (if this should make any difference)Do you know anything I might miss by chance as it seems that nobody who uses recorder functions inside a custom_component seem to use unit tests.
Additional infos:
pytest-homeassistant-custom-component==0.12.29
custom_componet uses the custom-components/integration_blueprint template
Full log:
The text was updated successfully, but these errors were encountered: