summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-06-11 17:27:50 +0000
committerBenjamin Peterson <benjamin@python.org>2008-06-11 17:27:50 +0000
commit0fbcf6945584b1b2a7564680de50c062fc4dce1c (patch)
tree44d27858990999b69379b50abc5ad163789db6fc /Lib/test
parent32c2e41c82c2d0f967a0f435f88168583218f262 (diff)
downloadcpython-git-0fbcf6945584b1b2a7564680de50c062fc4dce1c.tar.gz
give the threading API PEP 8 names
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_dummy_threading.py6
-rw-r--r--Lib/test/test_multiprocessing.py6
-rw-r--r--Lib/test/test_queue.py8
-rw-r--r--Lib/test/test_smtplib.py4
-rw-r--r--Lib/test/test_socket.py2
-rw-r--r--Lib/test/test_socketserver.py2
-rw-r--r--Lib/test/test_threading.py24
-rw-r--r--Lib/test/threaded_import_hangers.py2
8 files changed, 27 insertions, 27 deletions
diff --git a/Lib/test/test_dummy_threading.py b/Lib/test/test_dummy_threading.py
index df7df3cd79..ce248a2390 100644
--- a/Lib/test/test_dummy_threading.py
+++ b/Lib/test/test_dummy_threading.py
@@ -16,7 +16,7 @@ class DummyThreadingTestCase(unittest.TestCase):
#delay = random.random() * 2
delay = 0
if test_support.verbose:
- print 'task', self.getName(), 'will run for', delay, 'sec'
+ print 'task', self.get_name(), 'will run for', delay, 'sec'
sema.acquire()
mutex.acquire()
running += 1
@@ -25,11 +25,11 @@ class DummyThreadingTestCase(unittest.TestCase):
mutex.release()
time.sleep(delay)
if test_support.verbose:
- print 'task', self.getName(), 'done'
+ print 'task', self.get_name(), 'done'
mutex.acquire()
running -= 1
if test_support.verbose:
- print self.getName(), 'is finished.', running, 'tasks are running'
+ print self.get_name(), 'is finished.', running, 'tasks are running'
mutex.release()
sema.release()
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index a67c2960e4..d75fd20fdd 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -632,7 +632,7 @@ class _TestCondition(BaseTestCase):
p.start()
p = threading.Thread(target=self.f, args=(cond, sleeping, woken))
- p.setDaemon(True)
+ p.set_daemon(True)
p.start()
# wait for both children to start sleeping
@@ -679,7 +679,7 @@ class _TestCondition(BaseTestCase):
t = threading.Thread(target=self.f,
args=(cond, sleeping, woken, TIMEOUT1))
- t.setDaemon(True)
+ t.set_daemon(True)
t.start()
# wait for them all to sleep
@@ -701,7 +701,7 @@ class _TestCondition(BaseTestCase):
p.start()
t = threading.Thread(target=self.f, args=(cond, sleeping, woken))
- t.setDaemon(True)
+ t.set_daemon(True)
t.start()
# wait for them to all sleep
diff --git a/Lib/test/test_queue.py b/Lib/test/test_queue.py
index 660e1773de..e0eb8f40cb 100644
--- a/Lib/test/test_queue.py
+++ b/Lib/test/test_queue.py
@@ -49,11 +49,11 @@ class BlockingTestMixin:
self.t.start()
self.result = block_func(*block_args)
# If block_func returned before our thread made the call, we failed!
- if not self.t.startedEvent.isSet():
+ if not self.t.startedEvent.is_set():
self.fail("blocking function '%r' appeared not to block" %
block_func)
self.t.join(10) # make sure the thread terminates
- if self.t.isAlive():
+ if self.t.is_alive():
self.fail("trigger function '%r' appeared to not return" %
trigger_func)
return self.result
@@ -73,10 +73,10 @@ class BlockingTestMixin:
expected_exception_class)
finally:
self.t.join(10) # make sure the thread terminates
- if self.t.isAlive():
+ if self.t.is_alive():
self.fail("trigger function '%r' appeared to not return" %
trigger_func)
- if not self.t.startedEvent.isSet():
+ if not self.t.startedEvent.is_set():
self.fail("trigger thread ended but event never set")
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index be28de7019..7caa8a7aac 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -109,7 +109,7 @@ def debugging_server(serv, serv_evt, client_evt):
# when the client conversation is finished, it will
# set client_evt, and it's then ok to kill the server
- if client_evt.isSet():
+ if client_evt.is_set():
serv.close()
break
@@ -118,7 +118,7 @@ def debugging_server(serv, serv_evt, client_evt):
except socket.timeout:
pass
finally:
- if not client_evt.isSet():
+ if not client_evt.is_set():
# allow some time for the client to read the result
time.sleep(0.5)
serv.close()
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index ba5eea98b3..1287dd102c 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -107,7 +107,7 @@ class ThreadableTest:
self.clientRun, (test_method,))
self.__setUp()
- if not self.server_ready.isSet():
+ if not self.server_ready.is_set():
self.server_ready.set()
self.client_ready.wait()
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py
index 8595e5a245..f6de8fac3f 100644
--- a/Lib/test/test_socketserver.py
+++ b/Lib/test/test_socketserver.py
@@ -139,7 +139,7 @@ class SocketServerTest(unittest.TestCase):
# Time between requests is short enough that we won't wake
# up spuriously too many times.
kwargs={'poll_interval':0.01})
- t.setDaemon(True) # In case this function raises.
+ t.set_daemon(True) # In case this function raises.
t.start()
if verbose: print "server running"
for i in range(3):
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index b9747151b0..db6b0d7504 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -34,7 +34,7 @@ class TestThread(threading.Thread):
delay = random.random() / 10000.0
if verbose:
print 'task %s will run for %.1f usec' % (
- self.getName(), delay * 1e6)
+ self.get_name(), delay * 1e6)
with self.sema:
with self.mutex:
@@ -45,14 +45,14 @@ class TestThread(threading.Thread):
time.sleep(delay)
if verbose:
- print 'task', self.getName(), 'done'
+ print 'task', self.get_name(), 'done'
with self.mutex:
self.nrunning.dec()
self.testcase.assert_(self.nrunning.get() >= 0)
if verbose:
print '%s is finished. %d tasks are running' % (
- self.getName(), self.nrunning.get())
+ self.get_name(), self.nrunning.get())
class ThreadTests(unittest.TestCase):
@@ -73,7 +73,7 @@ class ThreadTests(unittest.TestCase):
for i in range(NUMTASKS):
t = TestThread("<thread %d>"%i, self, sema, mutex, numrunning)
threads.append(t)
- self.failUnlessEqual(t.getIdent(), None)
+ self.failUnlessEqual(t.get_ident(), None)
self.assert_(re.match('<TestThread\(.*, initial\)>', repr(t)))
t.start()
@@ -81,8 +81,8 @@ class ThreadTests(unittest.TestCase):
print 'waiting for all tasks to complete'
for t in threads:
t.join(NUMTASKS)
- self.assert_(not t.isAlive())
- self.failIfEqual(t.getIdent(), 0)
+ self.assert_(not t.is_alive())
+ self.failIfEqual(t.get_ident(), 0)
self.assert_(re.match('<TestThread\(.*, \w+ -?\d+\)>', repr(t)))
if verbose:
print 'all tasks done'
@@ -172,7 +172,7 @@ class ThreadTests(unittest.TestCase):
worker_saw_exception.set()
t = Worker()
- t.setDaemon(True) # so if this fails, we don't hang Python at shutdown
+ t.set_daemon(True) # so if this fails, we don't hang Python at shutdown
t.start()
if verbose:
print " started worker thread"
@@ -258,12 +258,12 @@ class ThreadTests(unittest.TestCase):
print 'program blocked; aborting'
os._exit(2)
t = threading.Thread(target=killer)
- t.setDaemon(True)
+ t.set_daemon(True)
t.start()
# This is the trace function
def func(frame, event, arg):
- threading.currentThread()
+ threading.current_thread()
return func
sys.settrace(func)
@@ -348,8 +348,8 @@ class ThreadingExceptionTests(unittest.TestCase):
self.assertRaises(ValueError, threading.Semaphore, value = -sys.maxint)
def test_joining_current_thread(self):
- currentThread = threading.currentThread()
- self.assertRaises(RuntimeError, currentThread.join);
+ current_thread = threading.current_thread()
+ self.assertRaises(RuntimeError, current_thread.join);
def test_joining_inactive_thread(self):
thread = threading.Thread()
@@ -358,7 +358,7 @@ class ThreadingExceptionTests(unittest.TestCase):
def test_daemonize_active_thread(self):
thread = threading.Thread()
thread.start()
- self.assertRaises(RuntimeError, thread.setDaemon, True)
+ self.assertRaises(RuntimeError, thread.set_daemon, True)
def test_main():
diff --git a/Lib/test/threaded_import_hangers.py b/Lib/test/threaded_import_hangers.py
index b21c52f3cf..d7508741d3 100644
--- a/Lib/test/threaded_import_hangers.py
+++ b/Lib/test/threaded_import_hangers.py
@@ -38,5 +38,5 @@ for name, func, args in [
t = Worker(func, args)
t.start()
t.join(TIMEOUT)
- if t.isAlive():
+ if t.is_alive():
errors.append("%s appeared to hang" % name)