-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Enforce async_load_fixture in async test functions #145709
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
Conversation
Hey there @ispysoftware, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Hey there @bieniu, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Hey there @airgradienthq, @joostlek, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
acbc473
to
a2ab53f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enforces asynchronous fixture loading in async test functions by migrating existing calls and introducing a Pylint plugin to catch synchronous fixture usage.
- Replace synchronous
load_fixture
calls withasync_load_fixture
and addawait
in async tests - Introduce
hass_async_load_fixtures
Pylint plugin to flag any remaining sync fixture loads - Update
pyproject.toml
to load the new plugin
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
tests/util/test_location.py | Migrate load_fixture to async_load_fixture and add hass fixture parameter |
pyproject.toml | Add hass_async_load_fixtures to load-plugins |
pylint/plugins/hass_async_load_fixtures.py | New Pylint checker that enforces async fixture loading |
Comments suppressed due to low confidence (3)
pylint/plugins/hass_async_load_fixtures.py:1
- [nitpick] The module docstring is misleading. Update it to reflect that this plugin enforces asynchronous fixture loading in tests.
"""Plugin for logger invocations."""
tests/util/test_location.py:80
- The test function uses
HomeAssistant
in its type hint butHomeAssistant
is not imported. Addfrom homeassistant.core import HomeAssistant
at the top of the file.
hass: HomeAssistant,
pyproject.toml:164
- The Pylint plugin module path should be fully qualified. Change this to
"pylint.plugins.hass_async_load_fixtures"
so that Pylint can locate the plugin.
"hass_async_load_fixtures",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @epenet 👍
Proposed change
SSIA, as follow-up to #144534
If a function is async, and
load_fixture
, then the call should be migrated toasync_load_fixture
load_json_array_fixture
, then the call should be migrated toasync_load_json_array_fixture
load_json_object_fixture
, then the call should be migrated toasync_load_json_object_fixture
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: