Skip to content

Commit

Permalink
tst
Browse files Browse the repository at this point in the history
  • Loading branch information
chamini2 committed Dec 10, 2024
1 parent fde3d59 commit 01f0539
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from isolate.backends.remote import IsolateServer
from isolate.backends.settings import IsolateSettings
from isolate.backends.virtualenv import VirtualPythonEnvironment
from isolate.logs import LogLevel, LogSource


class GenericEnvironmentTests:
Expand Down Expand Up @@ -660,6 +661,46 @@ def test_isolate_server_logs(isolate_server):
assert "hello!!!" in [log.message for log in collected_logs]


def test_isolate_server_logs_level_inference(isolate_server):
collected_logs = []
environment = IsolateServer(
host=isolate_server,
target_environments=[
{
"kind": "virtualenv",
"configuration": {"requirements": ["pyjokes==0.5.0"]},
}
],
)

environment.apply_settings(IsolateSettings(log_hook=collected_logs.append))

with environment.connect() as connection:
connection.run(
partial(
eval,
"print('[debug] hello!!!') or "
"print('[error] bad!!!') or "
"print('[trace] hide!!!') or "
"print('[warning] warn1!!!') or "
"print('warn2!!! [warn]') or "
"print('default') or "
"__import__('time').sleep(0.5)",
)
)

user_logs = [log for log in collected_logs if log.source == LogSource.USER]
assert len(user_logs) == 6
assert [log.level for log in user_logs] == [
LogLevel.DEBUG,
LogLevel.ERROR,
LogLevel.TRACE,
LogLevel.WARNING,
LogLevel.WARNING,
LogLevel.INFO,
]


def test_isolate_server_demo(isolate_server):
from functools import partial

Expand Down

0 comments on commit 01f0539

Please sign in to comment.