Skip to content

Commit f9fa3b6

Browse files
author
Joel Collins
committed
Merge remote-tracking branch 'origin/master' into gevent-pool
2 parents de13ab8 + d315730 commit f9fa3b6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/test_core_tasks_thread.py

Lines changed: 12 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():
@@ -85,18 +86,28 @@ def test_task_log_list():
8586
import logging
8687
import os
8788

89+
logging.getLogger().setLevel("INFO")
90+
8891
def task_func():
8992
logging.warning("Task warning")
93+
for i in range(10):
94+
time.sleep(0.001)
95+
logging.info(f"Counted to {i}")
9096

9197
task_obj = thread.TaskThread(target=task_func)
9298
task_obj.start()
9399
task_obj.started_event.wait()
94100

95-
assert len(task_obj.log) == 1
101+
assert len(task_obj.log) >= 1
96102
assert task_obj.log[0]["message"] == "Task warning"
97103
assert task_obj.log[0]["levelname"] == "WARNING"
98104
assert task_obj.log[0]["filename"] == os.path.basename(__file__)
99105

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

101112
def test_task_log_without_thread():
102113

0 commit comments

Comments
 (0)