Skip to content

Commit 8467966

Browse files
committed
first-try
1 parent a1dc4d3 commit 8467966

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

hello/hello_change_log_level.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def filter(self, record: logging.LogRecord) -> bool:
3737
class GreetingWorkflow:
3838
@workflow.run
3939
async def run(self):
40-
raise RuntimeError("This is a test error")
40+
raise RuntimeError("This error is an experiment to check the log level")
4141

4242

4343
async def main():
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import uuid
2+
import asyncio
3+
import logging
4+
5+
from temporalio.client import Client
6+
from temporalio.worker import Worker
7+
8+
from hello.hello_change_log_level import GreetingWorkflow
9+
10+
11+
async def test_workflow_with_changed_log_level(client: Client, caplog):
12+
13+
task_queue = f"tq-{uuid.uuid4()}"
14+
15+
async with Worker(
16+
client,
17+
task_queue=task_queue,
18+
workflows=[GreetingWorkflow],
19+
):
20+
with caplog.at_level(logging.ERROR):
21+
handle = await client.start_workflow(
22+
GreetingWorkflow.run,
23+
id=f"wf-{uuid.uuid4()}",
24+
task_queue=task_queue,
25+
)
26+
await asyncio.sleep(.1)
27+
handle.terminate()
28+
29+
assert any("log level" in m for m in caplog.messages)
30+
assert True

0 commit comments

Comments
 (0)