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

Use freezegun in DST tests #58939

Merged
merged 1 commit into from
Nov 2, 2021
Merged

Use freezegun in DST tests #58939

merged 1 commit into from
Nov 2, 2021

Conversation

emontnemery
Copy link
Contributor

Proposed change

Use freezegun in some DST related tests

Includes changes from spulec/freezegun#424

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)
  • 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
  • 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.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

Copy link
Member

@bdraco bdraco left a comment

Choose a reason for hiding this comment

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

@emontnemery emontnemery merged commit 30f7bc0 into dev Nov 2, 2021
@emontnemery emontnemery deleted the dst_tests_freezegun branch November 2, 2021 17:11
@cgtobi
Copy link
Contributor

cgtobi commented Nov 2, 2021

Can we now start using freezegun for other tests as well? Because last time I tried to introduce freezegun @balloob did not like it. Don't get me wrong, I am all for it.

@bdraco
Copy link
Member

bdraco commented Nov 2, 2021

Can we now start using freezegun for other tests as well? Because last time I tried to introduce freezegun @balloob did not like it. Don't get me wrong, I am all for it.

Not sure. I wouldn't have approved this one knowing that. These tests have been a constant source of flapping CI failures so we need a solution here even if we decide freezegun isn't the right one.

@cgtobi
Copy link
Contributor

cgtobi commented Nov 2, 2021

For reference here is his comment on that PR of mine. #46392

@emontnemery
Copy link
Contributor Author

emontnemery commented Nov 3, 2021

I discussed this PR with @balloob yesterday before merging, and he's OK with it.

In general, patching homeassistant.util.dt.utcnow is error-prone as we use other methods than that to get the time, and it may be imported under a different name so we end up not patching it everywhere.
In particular, the DST tests were prone to breaking because they failed when trying to set a date in the past, so we instead intended to set them to DST the next year. Before the big DST issue hit, they had been broken for several years because the DST date had not been bumped 🤦

Since we're now using freezegun for these tests, I'd say we should use them also in other places where exact timing is important.

natekspencer pushed a commit to natekspencer/home-assistant-core that referenced this pull request Nov 4, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants