Skip to content

Commit

Permalink
Reset the threading.local _hass object every time (home-assistant#101728
Browse files Browse the repository at this point in the history
)

* Reset the threading.local _hass object every time

* Remove reset from hass fixture
  • Loading branch information
cdce8p authored Oct 10, 2023
1 parent f78199d commit 915f5bf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,13 @@ def verify_cleanup(
)


@pytest.fixture(autouse=True)
def reset_hass_threading_local_object() -> Generator[None, None, None]:
"""Reset the _Hass threading.local object for every test case."""
yield
ha._hass.__dict__.clear()


@pytest.fixture(autouse=True)
def bcrypt_cost() -> Generator[None, None, None]:
"""Run with reduced rounds during tests, to speed up uses."""
Expand Down Expand Up @@ -559,9 +566,6 @@ def exc_handle(loop, context):
# Restore timezone, it is set when creating the hass object
dt_util.DEFAULT_TIME_ZONE = orig_tz

# Reset the _Hass threading.local object
ha._hass.__dict__.clear()

for ex in exceptions:
if (
request.module.__name__,
Expand Down

0 comments on commit 915f5bf

Please sign in to comment.