diff options
author | Georg Brandl <georg@python.org> | 2009-08-13 08:51:18 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2009-08-13 08:51:18 (GMT) |
commit | ab91fdef1f1e556203a2eee98ba7d379e4790de9 (patch) | |
tree | 6f8f00dc18cc5f2801a675df277c2c595eb85ec8 /Lib/test/test_threading.py | |
parent | ef82be368abdea8e8032500e7ecc3a22f5f07851 (diff) | |
download | cpython-ab91fdef1f1e556203a2eee98ba7d379e4790de9.zip cpython-ab91fdef1f1e556203a2eee98ba7d379e4790de9.tar.gz cpython-ab91fdef1f1e556203a2eee98ba7d379e4790de9.tar.bz2 |
Merged revisions 73715 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
........
r73715 | benjamin.peterson | 2009-07-01 01:06:06 +0200 (Mi, 01 Jul 2009) | 1 line
convert old fail* assertions to assert*
........
Diffstat (limited to 'Lib/test/test_threading.py')
-rw-r--r-- | Lib/test/test_threading.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index eabd7f4..c7a2213 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -41,7 +41,7 @@ class TestThread(threading.Thread): self.nrunning.inc() if verbose: print(self.nrunning.get(), 'tasks are running') - self.testcase.assert_(self.nrunning.get() <= 3) + self.testcase.assertTrue(self.nrunning.get() <= 3) time.sleep(delay) if verbose: @@ -49,7 +49,7 @@ class TestThread(threading.Thread): with self.mutex: self.nrunning.dec() - self.testcase.assert_(self.nrunning.get() >= 0) + self.testcase.assertTrue(self.nrunning.get() >= 0) if verbose: print('%s is finished. %d tasks are running' % (self.name, self.nrunning.get())) @@ -74,18 +74,18 @@ class ThreadTests(unittest.TestCase): for i in range(NUMTASKS): t = TestThread("<thread %d>"%i, self, sema, mutex, numrunning) threads.append(t) - self.failUnlessEqual(t.ident, None) - self.assert_(re.match('<TestThread\(.*, initial\)>', repr(t))) + self.assertEqual(t.ident, None) + self.assertTrue(re.match('<TestThread\(.*, initial\)>', repr(t))) t.start() if verbose: print('waiting for all tasks to complete') for t in threads: t.join(NUMTASKS) - self.assert_(not t.is_alive()) - self.failIfEqual(t.ident, 0) + self.assertTrue(not t.is_alive()) + self.assertNotEqual(t.ident, 0) self.assertFalse(t.ident is None) - self.assert_(re.match('<TestThread\(.*, \w+ -?\d+\)>', repr(t))) + self.assertTrue(re.match('<TestThread\(.*, \w+ -?\d+\)>', repr(t))) if verbose: print('all tasks done') self.assertEqual(numrunning.get(), 0) @@ -143,8 +143,8 @@ class ThreadTests(unittest.TestCase): tid = _thread.start_new_thread(f, (mutex,)) # Wait for the thread to finish. mutex.acquire() - self.assert_(tid in threading._active) - self.assert_(isinstance(threading._active[tid], + self.assertTrue(tid in threading._active) + self.assertTrue(isinstance(threading._active[tid], threading._DummyThread)) del threading._active[tid] @@ -204,7 +204,7 @@ class ThreadTests(unittest.TestCase): self.assertTrue(ret) if verbose: print(" verifying worker hasn't exited") - self.assert_(not t.finished) + self.assertTrue(not t.finished) if verbose: print(" attempting to raise asynch exception in worker") result = set_async_exc(ctypes.c_long(t.id), exception) @@ -212,7 +212,7 @@ class ThreadTests(unittest.TestCase): if verbose: print(" waiting for worker to say it caught the exception") worker_saw_exception.wait(timeout=10) - self.assert_(t.finished) + self.assertTrue(t.finished) if verbose: print(" all OK -- joining worker") if t.finished: @@ -283,8 +283,8 @@ class ThreadTests(unittest.TestCase): sys.settrace(func) """]) - self.failIf(rc == 2, "interpreted was blocked") - self.failUnless(rc == 0, "Unexpected error") + self.assertFalse(rc == 2, "interpreted was blocked") + self.assertTrue(rc == 0, "Unexpected error") def test_enumerate_after_join(self): @@ -371,8 +371,8 @@ class ThreadJoinOnShutdown(unittest.TestCase): rc = p.wait() data = p.stdout.read().decode().replace('\r', '') self.assertEqual(data, "end of main\nend of thread\n") - self.failIf(rc == 2, "interpreter was blocked") - self.failUnless(rc == 0, "Unexpected error") + self.assertFalse(rc == 2, "interpreter was blocked") + self.assertTrue(rc == 0, "Unexpected error") def test_1_join_on_shutdown(self): # The usual case: on exit, wait for a non-daemon thread |