-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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
Convert test helpers to get hass instance to contextmanagers #109990
Convert test helpers to get hass instance to contextmanagers #109990
Conversation
Hey there @bdraco, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Hey there @corneyl, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
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.
LGTM. Was much easier to check with white space turned off in the diff
Proposed change
Atm using either
get_test_home_assistant
orasync_test_home_assistant
has the side effect of setting the timezone. Thus the caller has to remember to reset it afterwards which is easy to forget / even missing in some cases. Thus currently the CI test only pass because the order of execution isn't changed and it happens to work out ok. The pytestv8.0
update will change that though and subsequently tests start to fail. #109876This PR aims to provide a long term solution by changing the helper functions to contextmanagers which cleanup / reset the timezone themself so the caller doesn't have to anymore.
Note
This turned out to be a larger change mostly because the indentation needed to be updated in a lot of cases. It's probably best to look each commit individually. I spilt them in a way that each can be applied on its own, one after the other.
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
..coveragerc
.To help with the load of incoming pull requests: