Skip to content

Fix flaky updater tests#26221

Merged
MartinHjelmare merged 1 commit into
devfrom
fix_updater_tests
Aug 27, 2019
Merged

Fix flaky updater tests#26221
MartinHjelmare merged 1 commit into
devfrom
fix_updater_tests

Conversation

@andrewsayre
Copy link
Copy Markdown
Member

Description:

Fixes an issue where dt_util.utcnow was not properly being patch in the updater tests, which (I believe) resulted in periodic failures. Also updates the code in the file to use the async keywords and some linting. No functional changes to code.

Related issue (if applicable): fixes #26187

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the [development checklist][dev-checklist]

@pytest.fixture(name="mock_utcnow")
def mock_utcnow_fixture():
"""Fixture to mock utcnow."""
with patch("homeassistant.components.updater.dt_util.utcnow") as mock:
Copy link
Copy Markdown
Member Author

@andrewsayre andrewsayre Aug 27, 2019

Choose a reason for hiding this comment

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

This is where the root of the issue was. The tests weren't even using the fixture, probably because the patch wasn't working. I'm not sure why this didn't work (it does in other places in the tests, but none of those were in a fixture), but when debugging I could see it wasn't mocking. Changing it to the module then returning the method inside the yield fixed the issue.

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Thanks!

@MartinHjelmare MartinHjelmare merged commit 9dc4019 into dev Aug 27, 2019
@delete-merged-branch delete-merged-branch Bot deleted the fix_updater_tests branch August 27, 2019 08:30
@lock lock Bot locked and limited conversation to collaborators Aug 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed core has-tests small-pr PRs with less than 30 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky Updater Test

3 participants