File tree Expand file tree Collapse file tree 2 files changed +8
-17
lines changed
Expand file tree Collapse file tree 2 files changed +8
-17
lines changed Original file line number Diff line number Diff line change 33
44import gevent
55from gevent .thread import get_ident
6+ import time
67
78
89def 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
103110def test_task_log_without_thread ():
104111
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments