diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-06-11 19:14:14 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-06-11 19:14:14 (GMT) |
commit | 672b8031a803fa420cac91cdaab02130c1f8bed0 (patch) | |
tree | cff73aa339853806887dd85bf1df34f088532efe /Lib/test | |
parent | 559e5d7f4d1155e95fb6f925c927a263f9196935 (diff) | |
download | cpython-672b8031a803fa420cac91cdaab02130c1f8bed0.zip cpython-672b8031a803fa420cac91cdaab02130c1f8bed0.tar.gz cpython-672b8031a803fa420cac91cdaab02130c1f8bed0.tar.bz2 |
Merged revisions 64125 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r64125 | benjamin.peterson | 2008-06-11 12:27:50 -0500 (Wed, 11 Jun 2008) | 2 lines
give the threading API PEP 8 names
........
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_dummy_threading.py | 6 | ||||
-rw-r--r-- | Lib/test/test_multiprocessing.py | 6 | ||||
-rw-r--r-- | Lib/test/test_queue.py | 8 | ||||
-rw-r--r-- | Lib/test/test_smtplib.py | 4 | ||||
-rw-r--r-- | Lib/test/test_socket.py | 2 | ||||
-rw-r--r-- | Lib/test/test_socketserver.py | 2 | ||||
-rw-r--r-- | Lib/test/test_threading.py | 26 | ||||
-rw-r--r-- | Lib/test/threaded_import_hangers.py | 2 |
8 files changed, 29 insertions, 27 deletions
diff --git a/Lib/test/test_dummy_threading.py b/Lib/test/test_dummy_threading.py index 4e983ce..86b3f35 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 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 support.verbose: - print('task', self.getName(), 'done') + print('task', self.get_name(), 'done') mutex.acquire() running -= 1 if 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 b9a360a..dd40c6e 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 6303117..22cdcad 100644 --- a/Lib/test/test_queue.py +++ b/Lib/test/test_queue.py @@ -52,11 +52,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 @@ -76,10 +76,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 8130252..3f3ba6b 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 e62788e..222c42c 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -108,7 +108,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 5b733ae..2427b8f 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 15edb1b..4c8af7f 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,13 +45,15 @@ 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): @@ -72,7 +74,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() @@ -80,8 +82,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') @@ -171,7 +173,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") @@ -257,12 +259,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) @@ -347,8 +349,8 @@ class ThreadingExceptionTests(unittest.TestCase): self.assertRaises(ValueError, threading.Semaphore, value = -sys.maxsize) 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() @@ -357,7 +359,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 b21c52f..d750874 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) |