File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
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 ():
@@ -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
101112def test_task_log_without_thread ():
102113
You can’t perform that action at this time.
0 commit comments