summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_threading.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-02-09 05:37:30 (GMT)
committerGuido van Rossum <guido@python.org>2007-02-09 05:37:30 (GMT)
commitbe19ed77ddb047e02fe94d142181062af6d99dcc (patch)
tree70f214e06554046fcccbadeb78665f25e07ce965 /Lib/test/test_threading.py
parent452bf519a70c3db0e7f0d2540b1bfb07d9085583 (diff)
downloadcpython-be19ed77ddb047e02fe94d142181062af6d99dcc.zip
cpython-be19ed77ddb047e02fe94d142181062af6d99dcc.tar.gz
cpython-be19ed77ddb047e02fe94d142181062af6d99dcc.tar.bz2
Fix most trivially-findable print statements.
There's one major and one minor category still unfixed: doctests are the major category (and I hope to be able to augment the refactoring tool to refactor bona fide doctests soon); other code generating print statements in strings is the minor category. (Oh, and I don't know if the compiler package works.)
Diffstat (limited to 'Lib/test/test_threading.py')
-rw-r--r--Lib/test/test_threading.py38
1 files changed, 19 insertions, 19 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index 8614ecb..95557c0 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -30,27 +30,27 @@ class TestThread(threading.Thread):
def run(self):
delay = random.random() * 2
if verbose:
- print 'task', self.getName(), 'will run for', delay, 'sec'
+ print('task', self.getName(), 'will run for', delay, 'sec')
self.sema.acquire()
self.mutex.acquire()
self.nrunning.inc()
if verbose:
- print self.nrunning.get(), 'tasks are running'
+ print(self.nrunning.get(), 'tasks are running')
self.testcase.assert_(self.nrunning.get() <= 3)
self.mutex.release()
time.sleep(delay)
if verbose:
- print 'task', self.getName(), 'done'
+ print('task', self.getName(), 'done')
self.mutex.acquire()
self.nrunning.dec()
self.testcase.assert_(self.nrunning.get() >= 0)
if verbose:
- print self.getName(), 'is finished.', self.nrunning.get(), \
- 'tasks are running'
+ print(self.getName(), 'is finished.', self.nrunning.get(), \
+ 'tasks are running')
self.mutex.release()
self.sema.release()
@@ -77,23 +77,23 @@ class ThreadTests(unittest.TestCase):
t.start()
if verbose:
- print 'waiting for all tasks to complete'
+ print('waiting for all tasks to complete')
for t in threads:
t.join(NUMTASKS)
self.assert_(not t.isAlive())
if verbose:
- print 'all tasks done'
+ print('all tasks done')
self.assertEqual(numrunning.get(), 0)
# run with a small(ish) thread stack size (256kB)
def test_various_ops_small_stack(self):
if verbose:
- print 'with 256kB thread stack size...'
+ print('with 256kB thread stack size...')
try:
threading.stack_size(262144)
except thread.error:
if verbose:
- print 'platform does not support changing thread stack size'
+ print('platform does not support changing thread stack size')
return
self.test_various_ops()
threading.stack_size(0)
@@ -101,12 +101,12 @@ class ThreadTests(unittest.TestCase):
# run with a large thread stack size (1MB)
def test_various_ops_large_stack(self):
if verbose:
- print 'with 1MB thread stack size...'
+ print('with 1MB thread stack size...')
try:
threading.stack_size(0x100000)
except thread.error:
if verbose:
- print 'platform does not support changing thread stack size'
+ print('platform does not support changing thread stack size')
return
self.test_various_ops()
threading.stack_size(0)
@@ -138,7 +138,7 @@ class ThreadTests(unittest.TestCase):
import ctypes
except ImportError:
if verbose:
- print "test_PyThreadState_SetAsyncExc can't import ctypes"
+ print("test_PyThreadState_SetAsyncExc can't import ctypes")
return # can't do anything
set_async_exc = ctypes.pythonapi.PyThreadState_SetAsyncExc
@@ -172,31 +172,31 @@ class ThreadTests(unittest.TestCase):
t.setDaemon(True) # so if this fails, we don't hang Python at shutdown
t.start()
if verbose:
- print " started worker thread"
+ print(" started worker thread")
# Try a thread id that doesn't make sense.
if verbose:
- print " trying nonsensical thread id"
+ print(" trying nonsensical thread id")
result = set_async_exc(ctypes.c_long(-1), exception)
self.assertEqual(result, 0) # no thread states modified
# Now raise an exception in the worker thread.
if verbose:
- print " waiting for worker thread to get started"
+ print(" waiting for worker thread to get started")
worker_started.wait()
if verbose:
- print " verifying worker hasn't exited"
+ print(" verifying worker hasn't exited")
self.assert_(not t.finished)
if verbose:
- print " attempting to raise asynch exception in worker"
+ print(" attempting to raise asynch exception in worker")
result = set_async_exc(ctypes.c_long(t.id), exception)
self.assertEqual(result, 1) # one thread state modified
if verbose:
- print " waiting for worker to say it caught the exception"
+ print(" waiting for worker to say it caught the exception")
worker_saw_exception.wait(timeout=10)
self.assert_(t.finished)
if verbose:
- print " all OK -- joining worker"
+ print(" all OK -- joining worker")
if t.finished:
t.join()
# else the thread is still running, and we have no way to kill it