Skip to content

Commit 24df9b5

Browse files
committed
test logging better
1 parent 4369ceb commit 24df9b5

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

tests/test_core_tasks_thread.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import gevent
55
from gevent.thread import get_ident
6+
import time
67

78

89
def test_task_with_args():
@@ -89,16 +90,22 @@ def test_task_log_list():
8990

9091
def task_func():
9192
logging.warning("Task warning")
93+
for i in range(10):
94+
time.sleep(0.001)
95+
logging.info(f"Counted to {i}")
9296

9397
task_obj = thread.TaskThread(target=task_func)
9498
task_obj.start()
9599
task_obj.started_event.wait()
96100

97-
assert len(task_obj.log) == 1
101+
assert len(task_obj.log) >= 1
98102
assert task_obj.log[0]["message"] == "Task warning"
99103
assert task_obj.log[0]["levelname"] == "WARNING"
100104
assert task_obj.log[0]["filename"] == os.path.basename(__file__)
101105

106+
task_obj.join()
107+
assert len(task_obj.log) == 11, "Didn't get the right number of log entries - are INFO entries being logged?"
108+
102109

103110
def test_task_log_without_thread():
104111

tests/test_tasks.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)