Skip to content
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

Ensure config entries are unloaded in tests #90850

Merged
merged 13 commits into from
Apr 22, 2023

Conversation

epenet
Copy link
Contributor

@epenet epenet commented Apr 5, 2023

Proposed change

Linked to #89976

Needs:

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant home-assistant bot added cla-signed code-quality core small-pr PRs with less than 30 lines. labels Apr 5, 2023
Comment on lines 526 to 527
for config_entry in hass.config_entries.async_entries():
loop.run_until_complete(config_entry.async_unload(hass))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we unload them in a gather?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to revert it:
RuntimeError: Task got bad yield: <coroutine object ConfigEntry.async_unload at 0x7f2f09aa0ba0>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we want to use gather we need to make the whole hass fixture async.

I am not sure why it is not marked as async currently, but I figure there might be a reason for that.

I think we can always migrate to async in a follow-up PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opened #91264 to migrate the hass fixture.
I will adjust this PR accordingly if it is merged first.

Copy link
Contributor Author

@epenet epenet Apr 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#91264 has been merged.
I have adjusted this PR accordingly, and used gather again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aargh - going async has uncovered extra issues

@epenet epenet force-pushed the unload-config-entries branch from 8186a02 to 19bbbe0 Compare April 11, 2023 09:03
@epenet epenet force-pushed the unload-config-entries branch from 19bbbe0 to 17bd3e5 Compare April 11, 2023 09:30
@epenet epenet marked this pull request as ready for review April 12, 2023 06:09
@epenet epenet mentioned this pull request Apr 12, 2023
20 tasks
@epenet epenet marked this pull request as draft April 13, 2023 04:35
@epenet epenet marked this pull request as ready for review April 13, 2023 05:17
@epenet epenet marked this pull request as draft April 13, 2023 05:46
@epenet epenet force-pushed the unload-config-entries branch from 5c4a9f8 to 3953351 Compare April 13, 2023 07:00
@epenet epenet mentioned this pull request Apr 13, 2023
20 tasks
@epenet epenet marked this pull request as ready for review April 13, 2023 15:06
@epenet epenet mentioned this pull request Apr 13, 2023
89 tasks
@epenet epenet marked this pull request as draft April 13, 2023 17:15
@epenet epenet marked this pull request as ready for review April 18, 2023 07:37
@frenck frenck added the smash Indicator this PR is close to finish for merging or closing label Apr 22, 2023
Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @epenet 👍

../Frenck

@frenck frenck merged commit 98b1005 into home-assistant:dev Apr 22, 2023
@epenet epenet deleted the unload-config-entries branch April 22, 2023 20:45
joanwa pushed a commit to joanwa/home-assistant that referenced this pull request Apr 23, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed code-quality core small-pr PRs with less than 30 lines. smash Indicator this PR is close to finish for merging or closing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants