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

Revert "Freeze timezone in bmw_connected_drive tests (#113533)" #115243

Closed
wants to merge 1 commit into from

Conversation

rikroe
Copy link
Contributor

@rikroe rikroe commented Apr 8, 2024

Proposed change

This reverts #113533.

While the implemented solution looks better, I am unable to get it working in my local environment in CE(S)T. Diff of the updated snapshot against dev branch:

--- a/tests/components/bmw_connected_drive/snapshots/test_diagnostics.ambr
+++ b/tests/components/bmw_connected_drive/snapshots/test_diagnostics.ambr
@@ -141,13 +141,13 @@
         }),
         'climate': dict({
           'account_timezone': dict({
-            '_dst_offset': '0:00:00',
-            '_dst_saved': '0:00:00',
-            '_hasdst': False,
-            '_std_offset': '0:00:00',
+            '_dst_offset': '2:00:00',
+            '_dst_saved': '1:00:00',
+            '_hasdst': True,
+            '_std_offset': '1:00:00',
             '_tznames': list([
-              'UTC',
-              'UTC',
+              'CET',
+              'CEST',
             ]),
           }),
           'activity': 'INACTIVE',

There seem to be long-standing issues in freezegun for exactly this issue: spulec/freezegun#299.

CC @Thomas55555 @gjohansson-ST @emontnemery as you all looked into timezones here or other PRs.

If you have any suggestions (or the existing code works for you when your host is a non-UTC system), I'd be happy to try it out as well.

Using Ubuntu 22.04 (WSL) with 3.12.2 and latest HA dev.

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 Ruff (ruff format 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
Copy link

home-assistant bot commented Apr 8, 2024

Hey there @gerard33, mind taking a look at this pull request as it has been labeled with an integration (bmw_connected_drive) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of bmw_connected_drive can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign bmw_connected_drive Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@jbouwh
Copy link
Contributor

jbouwh commented Apr 8, 2024

My dev container runs UTC and the test passes. May be some tests depend on the local time, and this should be changed.

@rikroe
Copy link
Contributor Author

rikroe commented Apr 9, 2024

Yeah, if the environment where the test is run is using UTC (e.g. a dev container or github actions runner) then all is fine.

The issue is when it is not in UTC (e.g.in WSL or you changed the tz of the dev Container).

The underlying reason is that freezegun deliberately converts a tz-aware (fake) timestamp to a tz-naive one. Python then uses tzlocal(), i.e. the host's timezone.

@rikroe
Copy link
Contributor Author

rikroe commented May 27, 2024

#118179 introduced another way of handling local times so this is not needed anymore.

@rikroe rikroe closed this May 27, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 28, 2024
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.

2 participants