Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemanspiff2007 committed Dec 10, 2024
1 parent 685ccd6 commit 31579c5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/HABApp/runtime/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
class Runtime:

def __init__(self) -> None:
self.config: HABApp.config.Config = None

# Rule engine
self.rule_manager: HABApp.rule_manager.RuleManager = None

Expand Down
21 changes: 19 additions & 2 deletions tests/rule_runner/rule_runner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from types import TracebackType
from inspect import getmembers
from types import ModuleType, TracebackType

from astral import Observer
from eascheduler.producers import prod_sun as prod_sun_module
Expand All @@ -8,13 +9,28 @@
import HABApp.core.lib.exceptions.format
import HABApp.rule.rule as rule_module
import HABApp.rule.scheduler.job_builder as job_builder_module
from HABApp.core.asyncio import loop
from HABApp.core.internals import EventBus, ItemRegistry, setup_internals
from HABApp.core.internals.proxy import ConstProxyObj
from HABApp.core.internals.wrapped_function import wrapped_thread, wrapper
from HABApp.core.internals.wrapped_function.wrapped_thread import WrappedThreadFunction
from HABApp.core.lib.exceptions.format import fallback_format
from HABApp.rule.rule_hook import HABAppRuleHook
from HABApp.runtime import Runtime
from tests.helpers.inspect.habapp import habapp_modules


def _get_loop_modules() -> tuple[ModuleType, ...]:
ret = []
for module in habapp_modules():
for name, obj in getmembers(module):
if obj is loop:
ret.append(module)
assert name == 'loop'
return tuple(ret)


LOOP_MODULES = _get_loop_modules()


def suggest_rule_name(obj: object) -> str:
Expand Down Expand Up @@ -115,7 +131,8 @@ def process_events(self) -> None:
def __enter__(self) -> None:
self.set_up()

def __exit__(self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None) -> bool:
def __exit__(self, exc_type: type[BaseException] | None, exc_val: BaseException | None,
exc_tb: TracebackType | None) -> bool:
self.tear_down()
# do not supress exception
return False

0 comments on commit 31579c5

Please sign in to comment.