@@ -59,15 +59,15 @@ def run(self):
5959 self .nrunning .inc ()
6060 if verbose :
6161 print (self .nrunning .get (), 'tasks are running' )
62- self .testcase .assertTrue (self .nrunning .get () <= 3 )
62+ self .testcase .assertLessEqual (self .nrunning .get (), 3 )
6363
6464 time .sleep (delay )
6565 if verbose :
6666 print ('task' , self .name , 'done' )
6767
6868 with self .mutex :
6969 self .nrunning .dec ()
70- self .testcase .assertTrue (self .nrunning .get () >= 0 )
70+ self .testcase .assertGreaterEqual (self .nrunning .get (), 0 )
7171 if verbose :
7272 print ('%s is finished. %d tasks are running' %
7373 (self .name , self .nrunning .get ()))
@@ -101,34 +101,33 @@ def test_various_ops(self):
101101 for i in range (NUMTASKS ):
102102 t = TestThread ("<thread %d>" % i , self , sema , mutex , numrunning )
103103 threads .append (t )
104- self .assertEqual (t .ident , None )
105- self .assertTrue ( re . match ( ' <TestThread\(.*, initial\)>' , repr ( t )) )
104+ self .assertIsNone (t .ident )
105+ self .assertRegex ( repr ( t ), r'^ <TestThread\(.*, initial\)>$' )
106106 t .start ()
107107
108108 if verbose :
109109 print ('waiting for all tasks to complete' )
110110 for t in threads :
111111 t .join ()
112- self .assertTrue ( not t .is_alive ())
112+ self .assertFalse ( t .is_alive ())
113113 self .assertNotEqual (t .ident , 0 )
114- self .assertFalse (t .ident is None )
115- self .assertTrue (re .match ('<TestThread\(.*, stopped -?\d+\)>' ,
116- repr (t )))
114+ self .assertIsNotNone (t .ident )
115+ self .assertRegex (repr (t ), r'^<TestThread\(.*, stopped -?\d+\)>$' )
117116 if verbose :
118117 print ('all tasks done' )
119118 self .assertEqual (numrunning .get (), 0 )
120119
121120 def test_ident_of_no_threading_threads (self ):
122121 # The ident still must work for the main thread and dummy threads.
123- self .assertFalse (threading .currentThread ().ident is None )
122+ self .assertIsNotNone (threading .currentThread ().ident )
124123 def f ():
125124 ident .append (threading .currentThread ().ident )
126125 done .set ()
127126 done = threading .Event ()
128127 ident = []
129128 _thread .start_new_thread (f , ())
130129 done .wait ()
131- self .assertFalse (ident [0 ] is None )
130+ self .assertIsNotNone (ident [0 ])
132131 # Kill the "immortal" _DummyThread
133132 del threading ._active [ident [0 ]]
134133
@@ -245,7 +244,7 @@ def run(self):
245244 self .assertTrue (ret )
246245 if verbose :
247246 print (" verifying worker hasn't exited" )
248- self .assertTrue ( not t .finished )
247+ self .assertFalse ( t .finished )
249248 if verbose :
250249 print (" attempting to raise asynch exception in worker" )
251250 result = set_async_exc (ctypes .c_long (t .id ), exception )
@@ -416,9 +415,9 @@ def test_old_threading_api(self):
416415
417416 def test_repr_daemon (self ):
418417 t = threading .Thread ()
419- self .assertFalse ('daemon' in repr (t ))
418+ self .assertNotIn ('daemon' , repr (t ))
420419 t .daemon = True
421- self .assertTrue ('daemon' in repr (t ))
420+ self .assertIn ('daemon' , repr (t ))
422421
423422 def test_deamon_param (self ):
424423 t = threading .Thread ()
@@ -570,7 +569,7 @@ def f():
570569 tstate_lock .release ()
571570 self .assertFalse (t .is_alive ())
572571 # And verify the thread disposed of _tstate_lock.
573- self .assertTrue (t ._tstate_lock is None )
572+ self .assertIsNone (t ._tstate_lock )
574573
575574 def test_repr_stopped (self ):
576575 # Verify that "stopped" shows up in repr(Thread) appropriately.
0 commit comments