File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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 ():
@@ -87,18 +88,26 @@ def test_task_log_list():
8788 import logging
8889 import os
8990
91+ logging .getLogger ().setLevel ("INFO" )
92+
9093 def task_func ():
9194 logging .warning ("Task warning" )
95+ for i in range (10 ):
96+ time .sleep (0.001 )
97+ logging .info (f"Counted to { i } " )
9298
9399 task_obj = thread .TaskThread (target = task_func )
94100 task_obj .start ()
95101 task_obj .started_event .wait ()
96102
97- assert len (task_obj .log ) = = 1
103+ assert len (task_obj .log ) > = 1
98104 assert task_obj .log [0 ]["message" ] == "Task warning"
99105 assert task_obj .log [0 ]["levelname" ] == "WARNING"
100106 assert task_obj .log [0 ]["filename" ] == os .path .basename (__file__ )
101107
108+ task_obj .join ()
109+ assert len (task_obj .log ) == 11 , "Didn't get the right number of log entries - are INFO entries being logged?"
110+
102111
103112def test_task_log_without_thread ():
104113
You can’t perform that action at this time.
0 commit comments