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/test_threading.py | |
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/test_threading.py')
-rw-r--r-- | Lib/test/test_threading.py | 26 |
1 files changed, 14 insertions, 12 deletions
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(): |