fixed session scope

This commit is contained in:
John Lancaster
2024-08-12 20:12:06 -05:00
parent ac3a7d7d37
commit d6adaef619
5 changed files with 71 additions and 71 deletions

View File

@@ -8,26 +8,25 @@ import pytest
from appdaemon.appdaemon import AppDaemon
from git import Repo
from .fixtures import ad, base_config
from .utils import get_load_order
def reset_file(changed: Path):
for p in Path(__file__).parents:
if p.with_name(".git").exists():
if p.with_name('.git').exists():
root = p.parent
break
repo = Repo(root)
if not changed.is_absolute():
changed = root / changed
repo.git.checkout("HEAD", "--", changed)
repo.git.checkout('HEAD', '--', changed)
def modify_file(path: Path):
file_content = path.read_text()
modified_content = re.sub(r"Ham", r"Spam", file_content, flags=re.MULTILINE)
modified_content = re.sub(r"ham", r"spam", modified_content, flags=re.MULTILINE)
modified_content = re.sub(r'Ham', r'Spam', file_content, flags=re.MULTILINE)
modified_content = re.sub(r'ham', r'spam', modified_content, flags=re.MULTILINE)
path.write_text(modified_content)
@@ -40,12 +39,12 @@ def test_file(ad: AppDaemon, caplog: pytest.LogCaptureFixture):
reset_file(module_file)
modify_file(module_file)
logging.getLogger("AppDaemon").propagate = True
with caplog.at_level(logging.DEBUG, logger="AppDaemon._app_management"):
logging.getLogger('AppDaemon').propagate = True
with caplog.at_level(logging.DEBUG, logger='AppDaemon._app_management'):
# running_ad.loop.run_until_complete(delayed_stop(running_ad, 2.0))
print("waiting in test")
print('waiting in test')
ad.loop.run_until_complete(asyncio.sleep(2.0))
module_load_order = get_load_order(caplog)
assert module_load_order == ["food.meal", "restaurant"]
print("done")
assert module_load_order == ['food.meal', 'restaurant']
print('done')