Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemanspiff2007 committed Dec 6, 2024
1 parent b80ee51 commit 256a1a2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion run/conf_testing/lib/HABAppTests/event_waiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from collections.abc import Generator
from time import monotonic
from types import TracebackType
from typing import Any, TypeVar
from typing import Any

from HABApp.core.events.filter import EventFilter
from HABApp.core.internals import (
Expand Down
2 changes: 1 addition & 1 deletion run/conf_testing/lib/HABAppTests/test_rule/_com_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


class PatcherName:
def __init__(self, header: str):
def __init__(self, header: str) -> None:
self.header = header
self.logged = False

Expand Down
14 changes: 8 additions & 6 deletions run/conf_testing/lib/HABAppTests/test_rule/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,28 @@
from asyncio import sleep
from collections.abc import Callable
from inspect import iscoroutinefunction
from typing import Any, Coroutine, Final, Sequence
from typing import Optional, Type, Any, Final
from collections.abc import Coroutine, Sequence

import HABApp
from HABApp.core.events import NoEventFilter
from HABApp.core.internals import EventBusListener, wrap_func, WrappedFunctionBase
from HABApp.core.internals import EventBusListener, WrappedFunctionBase, wrap_func
from HABAppTests.test_rule._com_patcher import BasePatcher, MqttPatcher, RestPatcher, SsePatcher
from HABAppTests.test_rule.test_result import TestResult, TestResultStatus
from HABAppTests.utils import get_file_path_of_obj
from types import TracebackType


class TmpLogLevel:
def __init__(self, name: str):
def __init__(self, name: str) -> None:
self.log = logging.getLogger(name)
self.old = self.log.level

def __enter__(self):
def __enter__(self) -> None:
self.old = self.log.level
self.log.setLevel(logging.INFO)

def __exit__(self, exc_type, exc_val, exc_tb):
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> bool:
self.log.setLevel(self.old)
return False

Expand Down Expand Up @@ -53,7 +55,7 @@ async def __aenter__(self):

return self

async def __aexit__(self, exc_type, exc_val, exc_tb):
async def __aexit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> bool:
if (ebl := self._listener) is not None:
self._listener = None
with TmpLogLevel('HABApp'):
Expand Down
14 changes: 7 additions & 7 deletions run/conf_testing/lib/HABAppTests/test_rule/test_rule.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from collections.abc import Callable, Coroutine
from enum import Enum, auto
from typing import Any, overload, Self
from typing import Any, Self, overload

import HABApp
from HABAppTests.test_rule.test_case import TestCase, TestResult, TestResultStatus
Expand Down Expand Up @@ -33,21 +33,21 @@ def __init__(self) -> None:
self._test_cases: dict[str, TestCase] = {}

@overload
def set_up(self): ...
def set_up(self) -> None: ...

@overload
async def set_up(self): ...
async def set_up(self) -> None: ...

def set_up(self):
def set_up(self) -> None:
pass

@overload
def tear_down(self): ...
def tear_down(self) -> None: ...

@overload
async def tear_down(self): ...
async def tear_down(self) -> None: ...

def tear_down(self):
def tear_down(self) -> None:
pass

def add_test(self, name: str, func: Callable | Callable[[...], Coroutine], *args: Any,
Expand Down
2 changes: 0 additions & 2 deletions run/conf_testing/lib/HABAppTests/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import asyncio
import random
import string
import typing
from binascii import b2a_hex
from pathlib import Path

import HABApp
Expand Down
1 change: 0 additions & 1 deletion run/conf_testing/logging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,3 @@ loggers:
handlers:
- HABApp_com_file
propagate: False

0 comments on commit 256a1a2

Please sign in to comment.