Python-checkins
Threads by month
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
June 2009
- 14 participants
- 814 discussions
Author: raymond.hettinger
Date: Fri Jun 12 00:04:00 2009
New Revision: 73367
Log:
Add example of how to do key lookups with bisect().
Modified:
python/trunk/Doc/library/bisect.rst
Modified: python/trunk/Doc/library/bisect.rst
==============================================================================
--- python/trunk/Doc/library/bisect.rst (original)
+++ python/trunk/Doc/library/bisect.rst Fri Jun 12 00:04:00 2009
@@ -85,4 +85,22 @@
>>> map(grade, [33, 99, 77, 44, 12, 88])
['E', 'A', 'B', 'D', 'F', 'A']
+Unlike the :func:`sorted` function, it does not make sense for the :func:`bisect`
+functions to have *key* or *reversed* arguments because that would lead to an
+inefficent design (successive calls to bisect functions would not "remember"
+all of the previous key lookups).
+Instead, it is better to search a list of precomputed keys to find the index
+of the record in question::
+
+ >>> data = [('red', 5), ('blue', 1), ('yellow', 8), ('black', 0)]
+ >>> data.sort(key=lambda r: r[1]) # precomputed list of keys
+ >>> keys = [r[1] for r in data]
+ >>> data[bisect_left(keys, 0)]
+ ('black', 0)
+ >>> data[bisect_left(keys, 1)]
+ ('blue', 1)
+ >>> data[bisect_left(keys, 5)]
+ ('red', 5)
+ >>> data[bisect_left(keys, 8)]
+ ('yellow', 8)
3
2
r72371 - in python/branches/py3k/Modules: socketmodule.c socketmodule.h
by benjamin.peterson 11 Aug '09
by benjamin.peterson 11 Aug '09
11 Aug '09
Author: benjamin.peterson
Date: Wed May 6 04:43:58 2009
New Revision: 72371
Log:
turn this into a macro
Modified:
python/branches/py3k/Modules/socketmodule.c
python/branches/py3k/Modules/socketmodule.h
Modified: python/branches/py3k/Modules/socketmodule.c
==============================================================================
--- python/branches/py3k/Modules/socketmodule.c (original)
+++ python/branches/py3k/Modules/socketmodule.c Wed May 6 04:43:58 2009
@@ -4146,14 +4146,6 @@
NULL
};
-PySocketModule_APIObject *
-PySocketModule_ImportModuleAndAPI(void)
-{
- void *api;
- api = PyCapsule_Import(PySocket_CAPSULE_NAME, 1);;
- return (PySocketModule_APIObject *)api;
-}
-
/* Initialize the _socket module.
Modified: python/branches/py3k/Modules/socketmodule.h
==============================================================================
--- python/branches/py3k/Modules/socketmodule.h (original)
+++ python/branches/py3k/Modules/socketmodule.h Wed May 6 04:43:58 2009
@@ -190,38 +190,9 @@
PyObject *error;
} PySocketModule_APIObject;
-/* XXX The net effect of the following appears to be to define a function
- XXX named PySocketModule_APIObject in _ssl.c. It's unclear why it isn't
- XXX defined there directly.
+#define PySocketModule_ImportModuleAndAPI() PyCapsule_Import(PySocket_CAPSULE_NAME, 1)
- >>> It's defined here because other modules might also want to use
- >>> the C API.
-
-*/
-#ifndef PySocket_BUILDING_SOCKET
-
-/* --- C API ----------------------------------------------------*/
-
-/* Interfacestructure to C API for other modules.
- Call PySocketModule_ImportModuleAndAPI() to initialize this
- structure. After that usage is simple:
-
- if (!PyArg_ParseTuple(args, "O!|zz:ssl",
- &PySocketModule.Sock_Type, (PyObject*)&Sock,
- &key_file, &cert_file))
- return NULL;
- ...
-*/
-
-/* You *must* call this before using any of the functions in
- PySocketModule and check its outcome; otherwise all accesses will
- result in a segfault. Returns 0 on success. */
-
-PyAPI_FUNC(PySocketModule_APIObject *) PySocketModule_ImportModuleAndAPI(void);
-
-#endif /* !PySocket_BUILDING_SOCKET */
-
-#ifdef __cplusplus
+#ifdef __cpluplus
}
#endif
#endif /* !Py__SOCKET_H */
2
1
Author: benjamin.peterson
Date: Wed Jul 1 01:45:41 2009
New Revision: 73719
Log:
test that depreacted methods give warnings
Modified:
python/branches/py3k/Lib/test/test_unittest.py
Modified: python/branches/py3k/Lib/test/test_unittest.py
==============================================================================
--- python/branches/py3k/Lib/test/test_unittest.py (original)
+++ python/branches/py3k/Lib/test/test_unittest.py Wed Jul 1 01:45:41 2009
@@ -9,6 +9,7 @@
import os
import re
import sys
+import warnings
from test import support
import unittest
from unittest import TestCase, TestProgram
@@ -2810,13 +2811,20 @@
Do not use these methods. They will go away in 3.3.
"""
- self.failIfEqual(3, 5)
- self.failUnlessEqual(3, 3)
- self.failUnlessAlmostEqual(2.0, 2.0)
- self.failIfAlmostEqual(3.0, 5.0)
- self.failUnless(True)
- self.failUnlessRaises(TypeError, lambda _: 3.14 + 'spam')
- self.failIf(False)
+ old = (
+ (self.failIfEqual, (3, 5)),
+ (self.failUnlessEqual, (3, 3)),
+ (self.failUnlessAlmostEqual, (2.0, 2.0)),
+ (self.failIfAlmostEqual, (3.0, 5.0)),
+ (self.failUnless, (True,)),
+ (self.failUnlessRaises, (TypeError, lambda _: 3.14 + 'spam')),
+ (self.failIf, (False,))
+ )
+ for meth, args in old:
+ with warnings.catch_warnings(record=True) as w:
+ meth(*args)
+ self.assertEqual(len(w), 1)
+ self.assertIs(w[0].category, DeprecationWarning)
def testDeepcopy(self):
# Issue: 5660
1
0
30 Jun '09
Author: benjamin.peterson
Date: Wed Jul 1 01:35:19 2009
New Revision: 73718
Log:
Merged revisions 73717 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r73717 | benjamin.peterson | 2009-06-30 18:30:12 -0500 (Tue, 30 Jun 2009) | 1 line
use assert* methods in test_unittest
........
Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Lib/test/test_unittest.py
Modified: python/branches/py3k/Lib/test/test_unittest.py
==============================================================================
--- python/branches/py3k/Lib/test/test_unittest.py (original)
+++ python/branches/py3k/Lib/test/test_unittest.py Wed Jul 1 01:35:19 2009
@@ -77,8 +77,8 @@
# Check for a valid __ne__ implementation
def test_ne(self):
for obj_1, obj_2 in self.ne_pairs:
- self.failIfEqual(obj_1, obj_2)
- self.failIfEqual(obj_2, obj_1)
+ self.assertNotEqual(obj_1, obj_2)
+ self.assertNotEqual(obj_2, obj_1)
class TestHashing(object):
"""Used as a mixin for TestCase"""
@@ -180,10 +180,10 @@
loader = unittest.TestLoader()
# This has to be false for the test to succeed
- self.failIf('runTest'.startswith(loader.testMethodPrefix))
+ self.assertFalse('runTest'.startswith(loader.testMethodPrefix))
suite = loader.loadTestsFromTestCase(Foo)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [Foo('runTest')])
################################################################
@@ -202,7 +202,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromModule(m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
expected = [loader.suiteClass([MyTestCase('test')])]
self.assertEqual(list(suite), expected)
@@ -215,7 +215,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromModule(m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [])
# "This method searches `module` for classes derived from TestCase"
@@ -229,7 +229,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromModule(m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [loader.suiteClass()])
@@ -465,7 +465,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromName('testcase_1', m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [MyTestCase('test')])
# "The specifier name is a ``dotted name'' that may resolve either to
@@ -481,7 +481,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromName('testsuite', m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [MyTestCase('test')])
@@ -496,7 +496,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromName('testcase_1.test', m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [MyTestCase('test')])
@@ -535,7 +535,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromName('return_TestSuite', m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [testcase_1, testcase_2])
# "The specifier name is a ``dotted name'' that may resolve ... to
@@ -549,7 +549,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromName('return_TestCase', m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [testcase_1])
# "The specifier name is a ``dotted name'' that may resolve ... to
@@ -588,11 +588,11 @@
try:
suite = loader.loadTestsFromName(module_name)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [])
# audioop should now be loaded, thanks to loadTestsFromName()
- self.failUnless(module_name in sys.modules)
+ self.assertTrue(module_name in sys.modules)
finally:
if module_name in sys.modules:
del sys.modules[module_name]
@@ -611,7 +611,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames([])
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [])
# "Similar to loadTestsFromName(), but takes a sequence of names rather
@@ -626,7 +626,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames([], unittest)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [])
# "The specifier name is a ``dotted name'' that may resolve either to
@@ -827,7 +827,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames(['testcase_1'], m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
expected = loader.suiteClass([MyTestCase('test')])
self.assertEqual(list(suite), [expected])
@@ -843,7 +843,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames(['testsuite'], m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [m.testsuite])
@@ -858,7 +858,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames(['testcase_1.test'], m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
ref_suite = unittest.TestSuite([MyTestCase('test')])
self.assertEqual(list(suite), [ref_suite])
@@ -895,7 +895,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames(['return_TestSuite'], m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
expected = unittest.TestSuite([testcase_1, testcase_2])
self.assertEqual(list(suite), [expected])
@@ -911,7 +911,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames(['return_TestCase'], m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
ref_suite = unittest.TestSuite([testcase_1])
self.assertEqual(list(suite), [ref_suite])
@@ -935,7 +935,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames(['Foo.foo'], m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
ref_suite = unittest.TestSuite([testcase_1])
self.assertEqual(list(suite), [ref_suite])
@@ -976,11 +976,11 @@
try:
suite = loader.loadTestsFromNames([module_name])
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [unittest.TestSuite()])
# audioop should now be loaded, thanks to loadTestsFromName()
- self.failUnless(module_name in sys.modules)
+ self.assertTrue(module_name in sys.modules)
finally:
if module_name in sys.modules:
del sys.modules[module_name]
@@ -1351,7 +1351,7 @@
# "The default value is the TestSuite class"
def test_suiteClass__default_value(self):
loader = unittest.TestLoader()
- self.failUnless(loader.suiteClass is unittest.TestSuite)
+ self.assertTrue(loader.suiteClass is unittest.TestSuite)
################################################################
### /Tests for TestLoader.suiteClass
@@ -1764,7 +1764,7 @@
def test_id(self):
test = unittest.FunctionTestCase(lambda: None)
- self.failUnless(isinstance(test.id(), str))
+ self.assertTrue(isinstance(test.id(), str))
# "Returns a one-line description of the test, or None if no description
# has been provided. The default implementation of this method returns
@@ -1796,7 +1796,7 @@
def test_init(self):
result = unittest.TestResult()
- self.failUnless(result.wasSuccessful())
+ self.assertTrue(result.wasSuccessful())
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 0)
self.assertEqual(result.testsRun, 0)
@@ -1825,7 +1825,7 @@
result.startTest(test)
- self.failUnless(result.wasSuccessful())
+ self.assertTrue(result.wasSuccessful())
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 0)
self.assertEqual(result.testsRun, 1)
@@ -1846,7 +1846,7 @@
result.startTest(test)
- self.failUnless(result.wasSuccessful())
+ self.assertTrue(result.wasSuccessful())
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 0)
self.assertEqual(result.testsRun, 1)
@@ -1855,7 +1855,7 @@
result.stopTest(test)
# Same tests as above; make sure nothing has changed
- self.failUnless(result.wasSuccessful())
+ self.assertTrue(result.wasSuccessful())
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 0)
self.assertEqual(result.testsRun, 1)
@@ -1899,7 +1899,7 @@
result.addSuccess(test)
result.stopTest(test)
- self.failUnless(result.wasSuccessful())
+ self.assertTrue(result.wasSuccessful())
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 0)
self.assertEqual(result.testsRun, 1)
@@ -1944,15 +1944,15 @@
result.addFailure(test, exc_info_tuple)
result.stopTest(test)
- self.failIf(result.wasSuccessful())
+ self.assertFalse(result.wasSuccessful())
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 1)
self.assertEqual(result.testsRun, 1)
self.assertEqual(result.shouldStop, False)
test_case, formatted_exc = result.failures[0]
- self.failUnless(test_case is test)
- self.failUnless(isinstance(formatted_exc, str))
+ self.assertTrue(test_case is test)
+ self.assertTrue(isinstance(formatted_exc, str))
# "addError(test, err)"
# ...
@@ -1994,15 +1994,15 @@
result.addError(test, exc_info_tuple)
result.stopTest(test)
- self.failIf(result.wasSuccessful())
+ self.assertFalse(result.wasSuccessful())
self.assertEqual(len(result.errors), 1)
self.assertEqual(len(result.failures), 0)
self.assertEqual(result.testsRun, 1)
self.assertEqual(result.shouldStop, False)
test_case, formatted_exc = result.errors[0]
- self.failUnless(test_case is test)
- self.failUnless(isinstance(formatted_exc, str))
+ self.assertTrue(test_case is test)
+ self.assertTrue(isinstance(formatted_exc, str))
### Support code for Test_TestCase
################################################################
@@ -2316,7 +2316,7 @@
def test(self):
pass
- self.failUnless(Foo('test').failureException is AssertionError)
+ self.assertTrue(Foo('test').failureException is AssertionError)
# "This class attribute gives the exception raised by the test() method.
# If a test framework needs to use a specialized exception, possibly to
@@ -2334,7 +2334,7 @@
failureException = RuntimeError
- self.failUnless(Foo('test').failureException is RuntimeError)
+ self.assertTrue(Foo('test').failureException is RuntimeError)
Foo('test').run(result)
@@ -2357,7 +2357,7 @@
failureException = RuntimeError
- self.failUnless(Foo('test').failureException is RuntimeError)
+ self.assertTrue(Foo('test').failureException is RuntimeError)
Foo('test').run(result)
@@ -2393,7 +2393,7 @@
def runTest(self):
pass
- self.failUnless(isinstance(Foo().id(), str))
+ self.assertTrue(isinstance(Foo().id(), str))
# "If result is omitted or None, a temporary result object is created
# and used, but is not made available to the caller. As TestCase owns the
@@ -2926,23 +2926,23 @@
class Test_Assertions(TestCase):
def test_AlmostEqual(self):
- self.failUnlessAlmostEqual(1.00000001, 1.0)
- self.failIfAlmostEqual(1.0000001, 1.0)
+ self.assertAlmostEqual(1.00000001, 1.0)
+ self.assertNotAlmostEqual(1.0000001, 1.0)
self.assertRaises(self.failureException,
- self.failUnlessAlmostEqual, 1.0000001, 1.0)
+ self.assertAlmostEqual, 1.0000001, 1.0)
self.assertRaises(self.failureException,
- self.failIfAlmostEqual, 1.00000001, 1.0)
+ self.assertNotAlmostEqual, 1.00000001, 1.0)
- self.failUnlessAlmostEqual(1.1, 1.0, places=0)
+ self.assertAlmostEqual(1.1, 1.0, places=0)
self.assertRaises(self.failureException,
- self.failUnlessAlmostEqual, 1.1, 1.0, places=1)
+ self.assertAlmostEqual, 1.1, 1.0, places=1)
- self.failUnlessAlmostEqual(0, .1+.1j, places=0)
- self.failIfAlmostEqual(0, .1+.1j, places=1)
+ self.assertAlmostEqual(0, .1+.1j, places=0)
+ self.assertNotAlmostEqual(0, .1+.1j, places=1)
self.assertRaises(self.failureException,
- self.failUnlessAlmostEqual, 0, .1+.1j, places=1)
+ self.assertAlmostEqual, 0, .1+.1j, places=1)
self.assertRaises(self.failureException,
- self.failIfAlmostEqual, 0, .1+.1j, places=0)
+ self.assertNotAlmostEqual, 0, .1+.1j, places=0)
def test_assertRaises(self):
def _raise(e):
1
0
Author: benjamin.peterson
Date: Wed Jul 1 01:30:12 2009
New Revision: 73717
Log:
use assert* methods in test_unittest
Modified:
python/trunk/Lib/test/test_unittest.py
Modified: python/trunk/Lib/test/test_unittest.py
==============================================================================
--- python/trunk/Lib/test/test_unittest.py (original)
+++ python/trunk/Lib/test/test_unittest.py Wed Jul 1 01:30:12 2009
@@ -78,8 +78,8 @@
# Check for a valid __ne__ implementation
def test_ne(self):
for obj_1, obj_2 in self.ne_pairs:
- self.failIfEqual(obj_1, obj_2)
- self.failIfEqual(obj_2, obj_1)
+ self.assertNotEqual(obj_1, obj_2)
+ self.assertNotEqual(obj_2, obj_1)
class TestHashing(object):
"""Used as a mixin for TestCase"""
@@ -181,10 +181,10 @@
loader = unittest.TestLoader()
# This has to be false for the test to succeed
- self.failIf('runTest'.startswith(loader.testMethodPrefix))
+ self.assertFalse('runTest'.startswith(loader.testMethodPrefix))
suite = loader.loadTestsFromTestCase(Foo)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [Foo('runTest')])
################################################################
@@ -203,7 +203,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromModule(m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
expected = [loader.suiteClass([MyTestCase('test')])]
self.assertEqual(list(suite), expected)
@@ -216,7 +216,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromModule(m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [])
# "This method searches `module` for classes derived from TestCase"
@@ -230,7 +230,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromModule(m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [loader.suiteClass()])
@@ -466,7 +466,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromName('testcase_1', m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [MyTestCase('test')])
# "The specifier name is a ``dotted name'' that may resolve either to
@@ -482,7 +482,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromName('testsuite', m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [MyTestCase('test')])
@@ -497,7 +497,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromName('testcase_1.test', m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [MyTestCase('test')])
@@ -536,7 +536,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromName('return_TestSuite', m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [testcase_1, testcase_2])
# "The specifier name is a ``dotted name'' that may resolve ... to
@@ -550,7 +550,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromName('return_TestCase', m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [testcase_1])
# "The specifier name is a ``dotted name'' that may resolve ... to
@@ -589,11 +589,11 @@
try:
suite = loader.loadTestsFromName(module_name)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [])
# audioop should now be loaded, thanks to loadTestsFromName()
- self.failUnless(module_name in sys.modules)
+ self.assertTrue(module_name in sys.modules)
finally:
if module_name in sys.modules:
del sys.modules[module_name]
@@ -612,7 +612,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames([])
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [])
# "Similar to loadTestsFromName(), but takes a sequence of names rather
@@ -627,7 +627,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames([], unittest)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [])
# "The specifier name is a ``dotted name'' that may resolve either to
@@ -828,7 +828,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames(['testcase_1'], m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
expected = loader.suiteClass([MyTestCase('test')])
self.assertEqual(list(suite), [expected])
@@ -844,7 +844,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames(['testsuite'], m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [m.testsuite])
@@ -859,7 +859,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames(['testcase_1.test'], m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
ref_suite = unittest.TestSuite([MyTestCase('test')])
self.assertEqual(list(suite), [ref_suite])
@@ -896,7 +896,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames(['return_TestSuite'], m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
expected = unittest.TestSuite([testcase_1, testcase_2])
self.assertEqual(list(suite), [expected])
@@ -912,7 +912,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames(['return_TestCase'], m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
ref_suite = unittest.TestSuite([testcase_1])
self.assertEqual(list(suite), [ref_suite])
@@ -936,7 +936,7 @@
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames(['Foo.foo'], m)
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
ref_suite = unittest.TestSuite([testcase_1])
self.assertEqual(list(suite), [ref_suite])
@@ -977,11 +977,11 @@
try:
suite = loader.loadTestsFromNames([module_name])
- self.failUnless(isinstance(suite, loader.suiteClass))
+ self.assertTrue(isinstance(suite, loader.suiteClass))
self.assertEqual(list(suite), [unittest.TestSuite()])
# audioop should now be loaded, thanks to loadTestsFromName()
- self.failUnless(module_name in sys.modules)
+ self.assertTrue(module_name in sys.modules)
finally:
if module_name in sys.modules:
del sys.modules[module_name]
@@ -1156,7 +1156,7 @@
# "The default value is 'test'"
def test_testMethodPrefix__default_value(self):
loader = unittest.TestLoader()
- self.failUnless(loader.testMethodPrefix == 'test')
+ self.assertTrue(loader.testMethodPrefix == 'test')
################################################################
### /Tests for TestLoader.testMethodPrefix
@@ -1255,7 +1255,7 @@
# "The default value is the built-in cmp() function"
def test_sortTestMethodsUsing__default_value(self):
loader = unittest.TestLoader()
- self.failUnless(loader.sortTestMethodsUsing is cmp)
+ self.assertTrue(loader.sortTestMethodsUsing is cmp)
# "it can be set to None to disable the sort."
#
@@ -1342,7 +1342,7 @@
# "The default value is the TestSuite class"
def test_suiteClass__default_value(self):
loader = unittest.TestLoader()
- self.failUnless(loader.suiteClass is unittest.TestSuite)
+ self.assertTrue(loader.suiteClass is unittest.TestSuite)
################################################################
### /Tests for TestLoader.suiteClass
@@ -1755,7 +1755,7 @@
def test_id(self):
test = unittest.FunctionTestCase(lambda: None)
- self.failUnless(isinstance(test.id(), basestring))
+ self.assertTrue(isinstance(test.id(), basestring))
# "Returns a one-line description of the test, or None if no description
# has been provided. The default implementation of this method returns
@@ -1787,7 +1787,7 @@
def test_init(self):
result = unittest.TestResult()
- self.failUnless(result.wasSuccessful())
+ self.assertTrue(result.wasSuccessful())
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 0)
self.assertEqual(result.testsRun, 0)
@@ -1816,7 +1816,7 @@
result.startTest(test)
- self.failUnless(result.wasSuccessful())
+ self.assertTrue(result.wasSuccessful())
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 0)
self.assertEqual(result.testsRun, 1)
@@ -1837,7 +1837,7 @@
result.startTest(test)
- self.failUnless(result.wasSuccessful())
+ self.assertTrue(result.wasSuccessful())
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 0)
self.assertEqual(result.testsRun, 1)
@@ -1846,7 +1846,7 @@
result.stopTest(test)
# Same tests as above; make sure nothing has changed
- self.failUnless(result.wasSuccessful())
+ self.assertTrue(result.wasSuccessful())
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 0)
self.assertEqual(result.testsRun, 1)
@@ -1890,7 +1890,7 @@
result.addSuccess(test)
result.stopTest(test)
- self.failUnless(result.wasSuccessful())
+ self.assertTrue(result.wasSuccessful())
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 0)
self.assertEqual(result.testsRun, 1)
@@ -1935,15 +1935,15 @@
result.addFailure(test, exc_info_tuple)
result.stopTest(test)
- self.failIf(result.wasSuccessful())
+ self.assertFalse(result.wasSuccessful())
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 1)
self.assertEqual(result.testsRun, 1)
self.assertEqual(result.shouldStop, False)
test_case, formatted_exc = result.failures[0]
- self.failUnless(test_case is test)
- self.failUnless(isinstance(formatted_exc, str))
+ self.assertTrue(test_case is test)
+ self.assertTrue(isinstance(formatted_exc, str))
# "addError(test, err)"
# ...
@@ -1985,15 +1985,15 @@
result.addError(test, exc_info_tuple)
result.stopTest(test)
- self.failIf(result.wasSuccessful())
+ self.assertFalse(result.wasSuccessful())
self.assertEqual(len(result.errors), 1)
self.assertEqual(len(result.failures), 0)
self.assertEqual(result.testsRun, 1)
self.assertEqual(result.shouldStop, False)
test_case, formatted_exc = result.errors[0]
- self.failUnless(test_case is test)
- self.failUnless(isinstance(formatted_exc, str))
+ self.assertTrue(test_case is test)
+ self.assertTrue(isinstance(formatted_exc, str))
### Support code for Test_TestCase
################################################################
@@ -2307,7 +2307,7 @@
def test(self):
pass
- self.failUnless(Foo('test').failureException is AssertionError)
+ self.assertTrue(Foo('test').failureException is AssertionError)
# "This class attribute gives the exception raised by the test() method.
# If a test framework needs to use a specialized exception, possibly to
@@ -2325,7 +2325,7 @@
failureException = RuntimeError
- self.failUnless(Foo('test').failureException is RuntimeError)
+ self.assertTrue(Foo('test').failureException is RuntimeError)
Foo('test').run(result)
@@ -2348,7 +2348,7 @@
failureException = RuntimeError
- self.failUnless(Foo('test').failureException is RuntimeError)
+ self.assertTrue(Foo('test').failureException is RuntimeError)
Foo('test').run(result)
@@ -2384,7 +2384,7 @@
def runTest(self):
pass
- self.failUnless(isinstance(Foo().id(), basestring))
+ self.assertTrue(isinstance(Foo().id(), basestring))
# "If result is omitted or None, a temporary result object is created
# and used, but is not made available to the caller. As TestCase owns the
@@ -2955,23 +2955,23 @@
class Test_Assertions(TestCase):
def test_AlmostEqual(self):
- self.failUnlessAlmostEqual(1.00000001, 1.0)
- self.failIfAlmostEqual(1.0000001, 1.0)
+ self.assertAlmostEqual(1.00000001, 1.0)
+ self.assertNotAlmostEqual(1.0000001, 1.0)
self.assertRaises(self.failureException,
- self.failUnlessAlmostEqual, 1.0000001, 1.0)
+ self.assertAlmostEqual, 1.0000001, 1.0)
self.assertRaises(self.failureException,
- self.failIfAlmostEqual, 1.00000001, 1.0)
+ self.assertNotAlmostEqual, 1.00000001, 1.0)
- self.failUnlessAlmostEqual(1.1, 1.0, places=0)
+ self.assertAlmostEqual(1.1, 1.0, places=0)
self.assertRaises(self.failureException,
- self.failUnlessAlmostEqual, 1.1, 1.0, places=1)
+ self.assertAlmostEqual, 1.1, 1.0, places=1)
- self.failUnlessAlmostEqual(0, .1+.1j, places=0)
- self.failIfAlmostEqual(0, .1+.1j, places=1)
+ self.assertAlmostEqual(0, .1+.1j, places=0)
+ self.assertNotAlmostEqual(0, .1+.1j, places=1)
self.assertRaises(self.failureException,
- self.failUnlessAlmostEqual, 0, .1+.1j, places=1)
+ self.assertAlmostEqual, 0, .1+.1j, places=1)
self.assertRaises(self.failureException,
- self.failIfAlmostEqual, 0, .1+.1j, places=0)
+ self.assertNotAlmostEqual, 0, .1+.1j, places=0)
def test_assertRaises(self):
def _raise(e):
1
0
Author: benjamin.peterson
Date: Wed Jul 1 01:09:03 2009
New Revision: 73716
Log:
Blocked revisions 73714 via svnmerge
........
r73714 | benjamin.peterson | 2009-06-30 17:57:08 -0500 (Tue, 30 Jun 2009) | 1 line
convert usage of fail* to assert*
........
Modified:
python/branches/py3k/ (props changed)
1
0
Author: benjamin.peterson
Date: Wed Jul 1 01:06:06 2009
New Revision: 73715
Log:
convert old fail* assertions to assert*
Modified:
python/branches/py3k/Lib/ctypes/test/test_anon.py
python/branches/py3k/Lib/ctypes/test/test_array_in_pointer.py
python/branches/py3k/Lib/ctypes/test/test_arrays.py
python/branches/py3k/Lib/ctypes/test/test_as_parameter.py
python/branches/py3k/Lib/ctypes/test/test_bitfields.py
python/branches/py3k/Lib/ctypes/test/test_buffers.py
python/branches/py3k/Lib/ctypes/test/test_byteswap.py
python/branches/py3k/Lib/ctypes/test/test_callbacks.py
python/branches/py3k/Lib/ctypes/test/test_cast.py
python/branches/py3k/Lib/ctypes/test/test_cfuncs.py
python/branches/py3k/Lib/ctypes/test/test_checkretval.py
python/branches/py3k/Lib/ctypes/test/test_errno.py
python/branches/py3k/Lib/ctypes/test/test_find.py
python/branches/py3k/Lib/ctypes/test/test_frombuffer.py
python/branches/py3k/Lib/ctypes/test/test_funcptr.py
python/branches/py3k/Lib/ctypes/test/test_functions.py
python/branches/py3k/Lib/ctypes/test/test_incomplete.py
python/branches/py3k/Lib/ctypes/test/test_init.py
python/branches/py3k/Lib/ctypes/test/test_internals.py
python/branches/py3k/Lib/ctypes/test/test_keeprefs.py
python/branches/py3k/Lib/ctypes/test/test_libc.py
python/branches/py3k/Lib/ctypes/test/test_loading.py
python/branches/py3k/Lib/ctypes/test/test_macholib.py
python/branches/py3k/Lib/ctypes/test/test_memfunctions.py
python/branches/py3k/Lib/ctypes/test/test_numbers.py
python/branches/py3k/Lib/ctypes/test/test_parameters.py
python/branches/py3k/Lib/ctypes/test/test_pep3118.py
python/branches/py3k/Lib/ctypes/test/test_pickling.py
python/branches/py3k/Lib/ctypes/test/test_pointers.py
python/branches/py3k/Lib/ctypes/test/test_prototypes.py
python/branches/py3k/Lib/ctypes/test/test_python_api.py
python/branches/py3k/Lib/ctypes/test/test_random_things.py
python/branches/py3k/Lib/ctypes/test/test_refcounts.py
python/branches/py3k/Lib/ctypes/test/test_repr.py
python/branches/py3k/Lib/ctypes/test/test_returnfuncptrs.py
python/branches/py3k/Lib/ctypes/test/test_simplesubclasses.py
python/branches/py3k/Lib/ctypes/test/test_sizes.py
python/branches/py3k/Lib/ctypes/test/test_slicing.py
python/branches/py3k/Lib/ctypes/test/test_stringptr.py
python/branches/py3k/Lib/ctypes/test/test_strings.py
python/branches/py3k/Lib/ctypes/test/test_struct_fields.py
python/branches/py3k/Lib/ctypes/test/test_structures.py
python/branches/py3k/Lib/ctypes/test/test_unaligned_structures.py
python/branches/py3k/Lib/ctypes/test/test_unicode.py
python/branches/py3k/Lib/ctypes/test/test_values.py
python/branches/py3k/Lib/ctypes/test/test_varsize_struct.py
python/branches/py3k/Lib/ctypes/test/test_win32.py
python/branches/py3k/Lib/distutils/tests/test_archive_util.py
python/branches/py3k/Lib/distutils/tests/test_bdist_rpm.py
python/branches/py3k/Lib/distutils/tests/test_bdist_wininst.py
python/branches/py3k/Lib/distutils/tests/test_build_clib.py
python/branches/py3k/Lib/distutils/tests/test_build_ext.py
python/branches/py3k/Lib/distutils/tests/test_build_py.py
python/branches/py3k/Lib/distutils/tests/test_build_scripts.py
python/branches/py3k/Lib/distutils/tests/test_clean.py
python/branches/py3k/Lib/distutils/tests/test_cmd.py
python/branches/py3k/Lib/distutils/tests/test_config.py
python/branches/py3k/Lib/distutils/tests/test_config_cmd.py
python/branches/py3k/Lib/distutils/tests/test_dist.py
python/branches/py3k/Lib/distutils/tests/test_install.py
python/branches/py3k/Lib/distutils/tests/test_install_data.py
python/branches/py3k/Lib/distutils/tests/test_install_lib.py
python/branches/py3k/Lib/distutils/tests/test_install_scripts.py
python/branches/py3k/Lib/distutils/tests/test_msvc9compiler.py
python/branches/py3k/Lib/distutils/tests/test_register.py
python/branches/py3k/Lib/distutils/tests/test_sysconfig.py
python/branches/py3k/Lib/distutils/tests/test_upload.py
python/branches/py3k/Lib/distutils/tests/test_util.py
python/branches/py3k/Lib/email/test/test_email.py
python/branches/py3k/Lib/importlib/test/builtin/test_finder.py
python/branches/py3k/Lib/importlib/test/builtin/test_loader.py
python/branches/py3k/Lib/importlib/test/extension/test_finder.py
python/branches/py3k/Lib/importlib/test/extension/test_loader.py
python/branches/py3k/Lib/importlib/test/extension/test_path_hook.py
python/branches/py3k/Lib/importlib/test/frozen/test_finder.py
python/branches/py3k/Lib/importlib/test/frozen/test_loader.py
python/branches/py3k/Lib/importlib/test/import_/test_caching.py
python/branches/py3k/Lib/importlib/test/import_/test_fromlist.py
python/branches/py3k/Lib/importlib/test/import_/test_meta_path.py
python/branches/py3k/Lib/importlib/test/import_/test_packages.py
python/branches/py3k/Lib/importlib/test/import_/test_path.py
python/branches/py3k/Lib/importlib/test/import_/test_relative_imports.py
python/branches/py3k/Lib/importlib/test/source/test_abc_loader.py
python/branches/py3k/Lib/importlib/test/source/test_file_loader.py
python/branches/py3k/Lib/importlib/test/source/test_finder.py
python/branches/py3k/Lib/importlib/test/source/test_path_hook.py
python/branches/py3k/Lib/importlib/test/test_abc.py
python/branches/py3k/Lib/importlib/test/test_util.py
python/branches/py3k/Lib/json/tests/test_decode.py
python/branches/py3k/Lib/json/tests/test_speedups.py
python/branches/py3k/Lib/test/mapping_tests.py
python/branches/py3k/Lib/test/pickletester.py
python/branches/py3k/Lib/test/test___all__.py
python/branches/py3k/Lib/test/test___future__.py
python/branches/py3k/Lib/test/test_abc.py
python/branches/py3k/Lib/test/test_abstract_numbers.py
python/branches/py3k/Lib/test/test_array.py
python/branches/py3k/Lib/test/test_ast.py
python/branches/py3k/Lib/test/test_augassign.py
python/branches/py3k/Lib/test/test_base64.py
python/branches/py3k/Lib/test/test_bigmem.py
python/branches/py3k/Lib/test/test_binascii.py
python/branches/py3k/Lib/test/test_binop.py
python/branches/py3k/Lib/test/test_bisect.py
python/branches/py3k/Lib/test/test_bool.py
python/branches/py3k/Lib/test/test_bufio.py
python/branches/py3k/Lib/test/test_builtin.py
python/branches/py3k/Lib/test/test_bytes.py
python/branches/py3k/Lib/test/test_capi.py
python/branches/py3k/Lib/test/test_cfgparser.py
python/branches/py3k/Lib/test/test_cgi.py
python/branches/py3k/Lib/test/test_cmath.py
python/branches/py3k/Lib/test/test_cmd_line.py
python/branches/py3k/Lib/test/test_cmd_line_script.py
python/branches/py3k/Lib/test/test_codecs.py
python/branches/py3k/Lib/test/test_codeop.py
python/branches/py3k/Lib/test/test_collections.py
python/branches/py3k/Lib/test/test_compile.py
python/branches/py3k/Lib/test/test_complex.py
python/branches/py3k/Lib/test/test_contains.py
python/branches/py3k/Lib/test/test_contextlib.py
python/branches/py3k/Lib/test/test_copy.py
python/branches/py3k/Lib/test/test_copyreg.py
python/branches/py3k/Lib/test/test_csv.py
python/branches/py3k/Lib/test/test_datetime.py
python/branches/py3k/Lib/test/test_dbm.py
python/branches/py3k/Lib/test/test_dbm_dumb.py
python/branches/py3k/Lib/test/test_dbm_gnu.py
python/branches/py3k/Lib/test/test_dbm_ndbm.py
python/branches/py3k/Lib/test/test_decimal.py
python/branches/py3k/Lib/test/test_defaultdict.py
python/branches/py3k/Lib/test/test_deque.py
python/branches/py3k/Lib/test/test_descr.py
python/branches/py3k/Lib/test/test_dict.py
python/branches/py3k/Lib/test/test_dictviews.py
python/branches/py3k/Lib/test/test_docxmlrpc.py
python/branches/py3k/Lib/test/test_dummy_thread.py
python/branches/py3k/Lib/test/test_epoll.py
python/branches/py3k/Lib/test/test_errno.py
python/branches/py3k/Lib/test/test_exceptions.py
python/branches/py3k/Lib/test/test_file.py
python/branches/py3k/Lib/test/test_filecmp.py
python/branches/py3k/Lib/test/test_fileinput.py
python/branches/py3k/Lib/test/test_fileio.py
python/branches/py3k/Lib/test/test_float.py
python/branches/py3k/Lib/test/test_fnmatch.py
python/branches/py3k/Lib/test/test_ftplib.py
python/branches/py3k/Lib/test/test_funcattrs.py
python/branches/py3k/Lib/test/test_functools.py
python/branches/py3k/Lib/test/test_genericpath.py
python/branches/py3k/Lib/test/test_getargs2.py
python/branches/py3k/Lib/test/test_getopt.py
python/branches/py3k/Lib/test/test_gettext.py
python/branches/py3k/Lib/test/test_grammar.py
python/branches/py3k/Lib/test/test_grp.py
python/branches/py3k/Lib/test/test_gzip.py
python/branches/py3k/Lib/test/test_hash.py
python/branches/py3k/Lib/test/test_hashlib.py
python/branches/py3k/Lib/test/test_heapq.py
python/branches/py3k/Lib/test/test_hmac.py
python/branches/py3k/Lib/test/test_http_cookiejar.py
python/branches/py3k/Lib/test/test_httplib.py
python/branches/py3k/Lib/test/test_httpservers.py
python/branches/py3k/Lib/test/test_imp.py
python/branches/py3k/Lib/test/test_import.py
python/branches/py3k/Lib/test/test_importhooks.py
python/branches/py3k/Lib/test/test_index.py
python/branches/py3k/Lib/test/test_inspect.py
python/branches/py3k/Lib/test/test_int.py
python/branches/py3k/Lib/test/test_io.py
python/branches/py3k/Lib/test/test_ioctl.py
python/branches/py3k/Lib/test/test_iter.py
python/branches/py3k/Lib/test/test_itertools.py
python/branches/py3k/Lib/test/test_kqueue.py
python/branches/py3k/Lib/test/test_largefile.py
python/branches/py3k/Lib/test/test_list.py
python/branches/py3k/Lib/test/test_logging.py
python/branches/py3k/Lib/test/test_long.py
python/branches/py3k/Lib/test/test_macpath.py
python/branches/py3k/Lib/test/test_mailbox.py
python/branches/py3k/Lib/test/test_math.py
python/branches/py3k/Lib/test/test_memoryio.py
python/branches/py3k/Lib/test/test_memoryview.py
python/branches/py3k/Lib/test/test_mimetypes.py
python/branches/py3k/Lib/test/test_minidom.py
python/branches/py3k/Lib/test/test_mmap.py
python/branches/py3k/Lib/test/test_module.py
python/branches/py3k/Lib/test/test_modulefinder.py
python/branches/py3k/Lib/test/test_multibytecodec.py
python/branches/py3k/Lib/test/test_multibytecodec_support.py
python/branches/py3k/Lib/test/test_netrc.py
python/branches/py3k/Lib/test/test_normalization.py
python/branches/py3k/Lib/test/test_opcodes.py
python/branches/py3k/Lib/test/test_operator.py
python/branches/py3k/Lib/test/test_optparse.py
python/branches/py3k/Lib/test/test_os.py
python/branches/py3k/Lib/test/test_ossaudiodev.py
python/branches/py3k/Lib/test/test_parser.py
python/branches/py3k/Lib/test/test_peepholer.py
python/branches/py3k/Lib/test/test_pep247.py
python/branches/py3k/Lib/test/test_pep277.py
python/branches/py3k/Lib/test/test_pep3120.py
python/branches/py3k/Lib/test/test_pep352.py
python/branches/py3k/Lib/test/test_pkg.py
python/branches/py3k/Lib/test/test_pkgimport.py
python/branches/py3k/Lib/test/test_platform.py
python/branches/py3k/Lib/test/test_poplib.py
python/branches/py3k/Lib/test/test_posix.py
python/branches/py3k/Lib/test/test_posixpath.py
python/branches/py3k/Lib/test/test_pprint.py
python/branches/py3k/Lib/test/test_property.py
python/branches/py3k/Lib/test/test_pwd.py
python/branches/py3k/Lib/test/test_pyclbr.py
python/branches/py3k/Lib/test/test_pydoc.py
python/branches/py3k/Lib/test/test_queue.py
python/branches/py3k/Lib/test/test_raise.py
python/branches/py3k/Lib/test/test_random.py
python/branches/py3k/Lib/test/test_range.py
python/branches/py3k/Lib/test/test_re.py
python/branches/py3k/Lib/test/test_reprlib.py
python/branches/py3k/Lib/test/test_richcmp.py
python/branches/py3k/Lib/test/test_robotparser.py
python/branches/py3k/Lib/test/test_runpy.py
python/branches/py3k/Lib/test/test_scope.py
python/branches/py3k/Lib/test/test_set.py
python/branches/py3k/Lib/test/test_shutil.py
python/branches/py3k/Lib/test/test_signal.py
python/branches/py3k/Lib/test/test_site.py
python/branches/py3k/Lib/test/test_slice.py
python/branches/py3k/Lib/test/test_socket.py
python/branches/py3k/Lib/test/test_stringprep.py
python/branches/py3k/Lib/test/test_strptime.py
python/branches/py3k/Lib/test/test_struct.py
python/branches/py3k/Lib/test/test_structseq.py
python/branches/py3k/Lib/test/test_subprocess.py
python/branches/py3k/Lib/test/test_symtable.py
python/branches/py3k/Lib/test/test_sys.py
python/branches/py3k/Lib/test/test_tarfile.py
python/branches/py3k/Lib/test/test_tempfile.py
python/branches/py3k/Lib/test/test_threading.py
python/branches/py3k/Lib/test/test_threading_local.py
python/branches/py3k/Lib/test/test_time.py
python/branches/py3k/Lib/test/test_timeout.py
python/branches/py3k/Lib/test/test_tokenize.py
python/branches/py3k/Lib/test/test_traceback.py
python/branches/py3k/Lib/test/test_tuple.py
python/branches/py3k/Lib/test/test_types.py
python/branches/py3k/Lib/test/test_unary.py
python/branches/py3k/Lib/test/test_unicode.py
python/branches/py3k/Lib/test/test_unicode_file.py
python/branches/py3k/Lib/test/test_unicodedata.py
python/branches/py3k/Lib/test/test_urllib.py
python/branches/py3k/Lib/test/test_urllib2.py
python/branches/py3k/Lib/test/test_urllib2_localnet.py
python/branches/py3k/Lib/test/test_urllib2net.py
python/branches/py3k/Lib/test/test_urllibnet.py
python/branches/py3k/Lib/test/test_userdict.py
python/branches/py3k/Lib/test/test_uuid.py
python/branches/py3k/Lib/test/test_warnings.py
python/branches/py3k/Lib/test/test_weakref.py
python/branches/py3k/Lib/test/test_weakset.py
python/branches/py3k/Lib/test/test_winreg.py
python/branches/py3k/Lib/test/test_wsgiref.py
python/branches/py3k/Lib/test/test_xdrlib.py
python/branches/py3k/Lib/test/test_xmlrpc.py
python/branches/py3k/Lib/test/test_xmlrpc_net.py
python/branches/py3k/Lib/test/test_zipfile.py
python/branches/py3k/Lib/test/test_zipimport.py
python/branches/py3k/Lib/test/test_zipimport_support.py
python/branches/py3k/Lib/test/test_zlib.py
python/branches/py3k/Lib/tkinter/test/test_tkinter/test_text.py
python/branches/py3k/Lib/tkinter/test/test_ttk/test_extensions.py
python/branches/py3k/Lib/tkinter/test/test_ttk/test_functions.py
python/branches/py3k/Lib/tkinter/test/test_ttk/test_style.py
python/branches/py3k/Lib/tkinter/test/test_ttk/test_widgets.py
Modified: python/branches/py3k/Lib/ctypes/test/test_anon.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_anon.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_anon.py Wed Jul 1 01:06:06 2009
@@ -14,22 +14,22 @@
("y", c_int)]
_anonymous_ = ["_"]
- self.failUnlessEqual(Y.a.offset, sizeof(c_int))
- self.failUnlessEqual(Y.b.offset, sizeof(c_int))
+ self.assertEqual(Y.a.offset, sizeof(c_int))
+ self.assertEqual(Y.b.offset, sizeof(c_int))
- self.failUnlessEqual(ANON.a.offset, 0)
- self.failUnlessEqual(ANON.b.offset, 0)
+ self.assertEqual(ANON.a.offset, 0)
+ self.assertEqual(ANON.b.offset, 0)
def test_anon_nonseq(self):
# TypeError: _anonymous_ must be a sequence
- self.failUnlessRaises(TypeError,
+ self.assertRaises(TypeError,
lambda: type(Structure)("Name",
(Structure,),
{"_fields_": [], "_anonymous_": 42}))
def test_anon_nonmember(self):
# AttributeError: type object 'Name' has no attribute 'x'
- self.failUnlessRaises(AttributeError,
+ self.assertRaises(AttributeError,
lambda: type(Structure)("Name",
(Structure,),
{"_fields_": [],
@@ -50,11 +50,11 @@
("y", c_int)]
_anonymous_ = ["_"]
- self.failUnlessEqual(Y.x.offset, 0)
- self.failUnlessEqual(Y.a.offset, sizeof(c_int))
- self.failUnlessEqual(Y.b.offset, sizeof(c_int))
- self.failUnlessEqual(Y._.offset, sizeof(c_int))
- self.failUnlessEqual(Y.y.offset, sizeof(c_int) * 2)
+ self.assertEqual(Y.x.offset, 0)
+ self.assertEqual(Y.a.offset, sizeof(c_int))
+ self.assertEqual(Y.b.offset, sizeof(c_int))
+ self.assertEqual(Y._.offset, sizeof(c_int))
+ self.assertEqual(Y.y.offset, sizeof(c_int) * 2)
if __name__ == "__main__":
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_array_in_pointer.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_array_in_pointer.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_array_in_pointer.py Wed Jul 1 01:06:06 2009
@@ -26,7 +26,7 @@
c.pvalues = val_array
# memory contains 4 NUL bytes now, that's correct
- self.failUnlessEqual("00-00-00-00", dump(val_array))
+ self.assertEqual("00-00-00-00", dump(val_array))
# set the values of the array through the pointer:
for i in range(4):
@@ -35,7 +35,7 @@
values = [c.pvalues[i].val for i in range(4)]
# These are the expected results: here s the bug!
- self.failUnlessEqual(
+ self.assertEqual(
(values, dump(val_array)),
([1, 2, 3, 4], "01-02-03-04")
)
@@ -45,7 +45,7 @@
val_array = (Value * 4)()
# memory contains 4 NUL bytes now, that's correct
- self.failUnlessEqual("00-00-00-00", dump(val_array))
+ self.assertEqual("00-00-00-00", dump(val_array))
ptr = cast(val_array, POINTER(Value))
# set the values of the array through the pointer:
@@ -55,7 +55,7 @@
values = [ptr[i].val for i in range(4)]
# These are the expected results: here s the bug!
- self.failUnlessEqual(
+ self.assertEqual(
(values, dump(val_array)),
([1, 2, 3, 4], "01-02-03-04")
)
Modified: python/branches/py3k/Lib/ctypes/test/test_arrays.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_arrays.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_arrays.py Wed Jul 1 01:06:06 2009
@@ -19,23 +19,23 @@
ia = int_array(*init)
# length of instance ok?
- self.failUnlessEqual(len(ia), alen)
+ self.assertEqual(len(ia), alen)
# slot values ok?
values = [ia[i] for i in range(len(init))]
- self.failUnlessEqual(values, init)
+ self.assertEqual(values, init)
# change the items
from operator import setitem
new_values = list(range(42, 42+alen))
[setitem(ia, n, new_values[n]) for n in range(alen)]
values = [ia[i] for i in range(len(init))]
- self.failUnlessEqual(values, new_values)
+ self.assertEqual(values, new_values)
# are the items initialized to 0?
ia = int_array()
values = [ia[i] for i in range(len(init))]
- self.failUnlessEqual(values, [0] * len(init))
+ self.assertEqual(values, [0] * len(init))
# Too many in itializers should be caught
self.assertRaises(IndexError, int_array, *range(alen*2))
@@ -48,14 +48,14 @@
# CharArray("abc")
self.assertRaises(TypeError, CharArray, "abc")
- self.failUnlessEqual(ca[0], b"a")
- self.failUnlessEqual(ca[1], b"b")
- self.failUnlessEqual(ca[2], b"c")
- self.failUnlessEqual(ca[-3], b"a")
- self.failUnlessEqual(ca[-2], b"b")
- self.failUnlessEqual(ca[-1], b"c")
+ self.assertEqual(ca[0], b"a")
+ self.assertEqual(ca[1], b"b")
+ self.assertEqual(ca[2], b"c")
+ self.assertEqual(ca[-3], b"a")
+ self.assertEqual(ca[-2], b"b")
+ self.assertEqual(ca[-1], b"c")
- self.failUnlessEqual(len(ca), 3)
+ self.assertEqual(len(ca), 3)
# cannot delete items
from operator import delitem
@@ -69,34 +69,34 @@
na = numarray()
values = [na[i] for i in range(alen)]
- self.failUnlessEqual(values, [0] * alen)
+ self.assertEqual(values, [0] * alen)
na = numarray(*[c_int()] * alen)
values = [na[i] for i in range(alen)]
- self.failUnlessEqual(values, [0]*alen)
+ self.assertEqual(values, [0]*alen)
na = numarray(1, 2, 3, 4, 5)
values = [i for i in na]
- self.failUnlessEqual(values, [1, 2, 3, 4, 5])
+ self.assertEqual(values, [1, 2, 3, 4, 5])
na = numarray(*map(c_int, (1, 2, 3, 4, 5)))
values = [i for i in na]
- self.failUnlessEqual(values, [1, 2, 3, 4, 5])
+ self.assertEqual(values, [1, 2, 3, 4, 5])
def test_classcache(self):
- self.failUnless(not ARRAY(c_int, 3) is ARRAY(c_int, 4))
- self.failUnless(ARRAY(c_int, 3) is ARRAY(c_int, 3))
+ self.assertTrue(not ARRAY(c_int, 3) is ARRAY(c_int, 4))
+ self.assertTrue(ARRAY(c_int, 3) is ARRAY(c_int, 3))
def test_from_address(self):
# Failed with 0.9.8, reported by JUrner
p = create_string_buffer("foo")
sz = (c_char * 3).from_address(addressof(p))
- self.failUnlessEqual(sz[:], b"foo")
- self.failUnlessEqual(sz[::], b"foo")
- self.failUnlessEqual(sz[::-1], b"oof")
- self.failUnlessEqual(sz[::3], b"f")
- self.failUnlessEqual(sz[1:4:2], b"o")
- self.failUnlessEqual(sz.value, b"foo")
+ self.assertEqual(sz[:], b"foo")
+ self.assertEqual(sz[::], b"foo")
+ self.assertEqual(sz[::-1], b"oof")
+ self.assertEqual(sz[::3], b"f")
+ self.assertEqual(sz[1:4:2], b"o")
+ self.assertEqual(sz.value, b"foo")
try:
create_unicode_buffer
@@ -106,12 +106,12 @@
def test_from_addressW(self):
p = create_unicode_buffer("foo")
sz = (c_wchar * 3).from_address(addressof(p))
- self.failUnlessEqual(sz[:], "foo")
- self.failUnlessEqual(sz[::], "foo")
- self.failUnlessEqual(sz[::-1], "oof")
- self.failUnlessEqual(sz[::3], "f")
- self.failUnlessEqual(sz[1:4:2], "o")
- self.failUnlessEqual(sz.value, "foo")
+ self.assertEqual(sz[:], "foo")
+ self.assertEqual(sz[::], "foo")
+ self.assertEqual(sz[::-1], "oof")
+ self.assertEqual(sz[::3], "f")
+ self.assertEqual(sz[1:4:2], "o")
+ self.assertEqual(sz.value, "foo")
def test_cache(self):
# Array types are cached internally in the _ctypes extension,
@@ -125,7 +125,7 @@
# Create a new array type based on it:
t1 = my_int * 1
t2 = my_int * 1
- self.failUnless(t1 is t2)
+ self.assertTrue(t1 is t2)
if __name__ == '__main__':
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_as_parameter.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_as_parameter.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_as_parameter.py Wed Jul 1 01:06:06 2009
@@ -25,8 +25,8 @@
f = dll._testfunc_i_bhilfd
f.argtypes = [c_byte, c_wchar, c_int, c_long, c_float, c_double]
result = f(self.wrap(1), self.wrap("x"), self.wrap(3), self.wrap(4), self.wrap(5.0), self.wrap(6.0))
- self.failUnlessEqual(result, 139)
- self.failUnless(type(result), int)
+ self.assertEqual(result, 139)
+ self.assertTrue(type(result), int)
def test_pointers(self):
f = dll._testfunc_p_p
@@ -39,18 +39,18 @@
v = c_int(42)
- self.failUnlessEqual(pointer(v).contents.value, 42)
+ self.assertEqual(pointer(v).contents.value, 42)
result = f(self.wrap(pointer(v)))
- self.failUnlessEqual(type(result), POINTER(c_int))
- self.failUnlessEqual(result.contents.value, 42)
+ self.assertEqual(type(result), POINTER(c_int))
+ self.assertEqual(result.contents.value, 42)
# This on works...
result = f(self.wrap(pointer(v)))
- self.failUnlessEqual(result.contents.value, v.value)
+ self.assertEqual(result.contents.value, v.value)
p = pointer(c_int(99))
result = f(self.wrap(p))
- self.failUnlessEqual(result.contents.value, 99)
+ self.assertEqual(result.contents.value, 99)
def test_shorts(self):
f = dll._testfunc_callback_i_if
@@ -67,7 +67,7 @@
cb = CallBack(callback)
f(self.wrap(2**18), self.wrap(cb))
- self.failUnlessEqual(args, expected)
+ self.assertEqual(args, expected)
################################################################
@@ -84,17 +84,17 @@
cb = MyCallback(callback)
result = f(self.wrap(-10), self.wrap(cb))
- self.failUnlessEqual(result, -18)
+ self.assertEqual(result, -18)
# test with prototype
f.argtypes = [c_int, MyCallback]
cb = MyCallback(callback)
result = f(self.wrap(-10), self.wrap(cb))
- self.failUnlessEqual(result, -18)
+ self.assertEqual(result, -18)
result = f(self.wrap(-10), self.wrap(cb))
- self.failUnlessEqual(result, -18)
+ self.assertEqual(result, -18)
AnotherCallback = CALLBACK_FUNCTYPE(c_int, c_int, c_int, c_int, c_int)
@@ -116,12 +116,12 @@
def callback(value):
#print "called back with", value
- self.failUnlessEqual(type(value), int)
+ self.assertEqual(type(value), int)
return value
cb = MyCallback(callback)
result = f(self.wrap(-10), self.wrap(cb))
- self.failUnlessEqual(result, -18)
+ self.assertEqual(result, -18)
def test_longlong_callbacks(self):
@@ -133,12 +133,12 @@
f.argtypes = [c_longlong, MyCallback]
def callback(value):
- self.failUnless(isinstance(value, int))
+ self.assertTrue(isinstance(value, int))
return value & 0x7FFFFFFF
cb = MyCallback(callback)
- self.failUnlessEqual(13577625587, int(f(self.wrap(1000000000000), self.wrap(cb))))
+ self.assertEqual(13577625587, int(f(self.wrap(1000000000000), self.wrap(cb))))
def test_byval(self):
# without prototype
@@ -148,7 +148,7 @@
result = dll._testfunc_byval(ptin, byref(ptout))
got = result, ptout.x, ptout.y
expected = 3, 1, 2
- self.failUnlessEqual(got, expected)
+ self.assertEqual(got, expected)
# with prototype
ptin = POINT(101, 102)
@@ -158,7 +158,7 @@
result = dll._testfunc_byval(self.wrap(ptin), byref(ptout))
got = result, ptout.x, ptout.y
expected = 203, 101, 102
- self.failUnlessEqual(got, expected)
+ self.assertEqual(got, expected)
def test_struct_return_2H(self):
class S2H(Structure):
@@ -168,7 +168,7 @@
dll.ret_2h_func.argtypes = [S2H]
inp = S2H(99, 88)
s2h = dll.ret_2h_func(self.wrap(inp))
- self.failUnlessEqual((s2h.x, s2h.y), (99*2, 88*3))
+ self.assertEqual((s2h.x, s2h.y), (99*2, 88*3))
def test_struct_return_8H(self):
class S8I(Structure):
@@ -184,7 +184,7 @@
dll.ret_8i_func.argtypes = [S8I]
inp = S8I(9, 8, 7, 6, 5, 4, 3, 2)
s8i = dll.ret_8i_func(self.wrap(inp))
- self.failUnlessEqual((s8i.a, s8i.b, s8i.c, s8i.d, s8i.e, s8i.f, s8i.g, s8i.h),
+ self.assertEqual((s8i.a, s8i.b, s8i.c, s8i.d, s8i.e, s8i.f, s8i.g, s8i.h),
(9*2, 8*3, 7*4, 6*5, 5*6, 4*7, 3*8, 2*9))
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Modified: python/branches/py3k/Lib/ctypes/test/test_bitfields.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_bitfields.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_bitfields.py Wed Jul 1 01:06:06 2009
@@ -37,14 +37,14 @@
for name in "ABCDEFGHI":
b = BITS()
setattr(b, name, i)
- self.failUnlessEqual((name, i, getattr(b, name)), (name, i, func(byref(b), name)))
+ self.assertEqual((name, i, getattr(b, name)), (name, i, func(byref(b), name)))
def test_shorts(self):
for i in range(256):
for name in "MNOPQRS":
b = BITS()
setattr(b, name, i)
- self.failUnlessEqual((name, i, getattr(b, name)), (name, i, func(byref(b), name)))
+ self.assertEqual((name, i, getattr(b, name)), (name, i, func(byref(b), name)))
signed_int_types = (c_byte, c_short, c_int, c_long, c_longlong)
unsigned_int_types = (c_ubyte, c_ushort, c_uint, c_ulong, c_ulonglong)
@@ -58,10 +58,10 @@
("b", c_longlong, 62),
("c", c_longlong, 1)]
- self.failUnlessEqual(sizeof(X), sizeof(c_longlong))
+ self.assertEqual(sizeof(X), sizeof(c_longlong))
x = X()
x.a, x.b, x.c = -1, 7, -1
- self.failUnlessEqual((x.a, x.b, x.c), (-1, 7, -1))
+ self.assertEqual((x.a, x.b, x.c), (-1, 7, -1))
def test_ulonglong(self):
class X(Structure):
@@ -69,11 +69,11 @@
("b", c_ulonglong, 62),
("c", c_ulonglong, 1)]
- self.failUnlessEqual(sizeof(X), sizeof(c_longlong))
+ self.assertEqual(sizeof(X), sizeof(c_longlong))
x = X()
- self.failUnlessEqual((x.a, x.b, x.c), (0, 0, 0))
+ self.assertEqual((x.a, x.b, x.c), (0, 0, 0))
x.a, x.b, x.c = 7, 7, 7
- self.failUnlessEqual((x.a, x.b, x.c), (1, 7, 1))
+ self.assertEqual((x.a, x.b, x.c), (1, 7, 1))
def test_signed(self):
for c_typ in signed_int_types:
@@ -82,14 +82,14 @@
("a", c_typ, 3),
("b", c_typ, 3),
("c", c_typ, 1)]
- self.failUnlessEqual(sizeof(X), sizeof(c_typ)*2)
+ self.assertEqual(sizeof(X), sizeof(c_typ)*2)
x = X()
- self.failUnlessEqual((c_typ, x.a, x.b, x.c), (c_typ, 0, 0, 0))
+ self.assertEqual((c_typ, x.a, x.b, x.c), (c_typ, 0, 0, 0))
x.a = -1
- self.failUnlessEqual((c_typ, x.a, x.b, x.c), (c_typ, -1, 0, 0))
+ self.assertEqual((c_typ, x.a, x.b, x.c), (c_typ, -1, 0, 0))
x.a, x.b = 0, -1
- self.failUnlessEqual((c_typ, x.a, x.b, x.c), (c_typ, 0, -1, 0))
+ self.assertEqual((c_typ, x.a, x.b, x.c), (c_typ, 0, -1, 0))
def test_unsigned(self):
@@ -98,14 +98,14 @@
_fields_ = [("a", c_typ, 3),
("b", c_typ, 3),
("c", c_typ, 1)]
- self.failUnlessEqual(sizeof(X), sizeof(c_typ))
+ self.assertEqual(sizeof(X), sizeof(c_typ))
x = X()
- self.failUnlessEqual((c_typ, x.a, x.b, x.c), (c_typ, 0, 0, 0))
+ self.assertEqual((c_typ, x.a, x.b, x.c), (c_typ, 0, 0, 0))
x.a = -1
- self.failUnlessEqual((c_typ, x.a, x.b, x.c), (c_typ, 7, 0, 0))
+ self.assertEqual((c_typ, x.a, x.b, x.c), (c_typ, 7, 0, 0))
x.a, x.b = 0, -1
- self.failUnlessEqual((c_typ, x.a, x.b, x.c), (c_typ, 0, 7, 0))
+ self.assertEqual((c_typ, x.a, x.b, x.c), (c_typ, 0, 7, 0))
def fail_fields(self, *fields):
@@ -115,17 +115,17 @@
def test_nonint_types(self):
# bit fields are not allowed on non-integer types.
result = self.fail_fields(("a", c_char_p, 1))
- self.failUnlessEqual(result, (TypeError, 'bit fields not allowed for type c_char_p'))
+ self.assertEqual(result, (TypeError, 'bit fields not allowed for type c_char_p'))
result = self.fail_fields(("a", c_void_p, 1))
- self.failUnlessEqual(result, (TypeError, 'bit fields not allowed for type c_void_p'))
+ self.assertEqual(result, (TypeError, 'bit fields not allowed for type c_void_p'))
if c_int != c_long:
result = self.fail_fields(("a", POINTER(c_int), 1))
- self.failUnlessEqual(result, (TypeError, 'bit fields not allowed for type LP_c_int'))
+ self.assertEqual(result, (TypeError, 'bit fields not allowed for type LP_c_int'))
result = self.fail_fields(("a", c_char, 1))
- self.failUnlessEqual(result, (TypeError, 'bit fields not allowed for type c_char'))
+ self.assertEqual(result, (TypeError, 'bit fields not allowed for type c_char'))
try:
c_wchar
@@ -133,59 +133,59 @@
pass
else:
result = self.fail_fields(("a", c_wchar, 1))
- self.failUnlessEqual(result, (TypeError, 'bit fields not allowed for type c_wchar'))
+ self.assertEqual(result, (TypeError, 'bit fields not allowed for type c_wchar'))
class Dummy(Structure):
_fields_ = []
result = self.fail_fields(("a", Dummy, 1))
- self.failUnlessEqual(result, (TypeError, 'bit fields not allowed for type Dummy'))
+ self.assertEqual(result, (TypeError, 'bit fields not allowed for type Dummy'))
def test_single_bitfield_size(self):
for c_typ in int_types:
result = self.fail_fields(("a", c_typ, -1))
- self.failUnlessEqual(result, (ValueError, 'number of bits invalid for bit field'))
+ self.assertEqual(result, (ValueError, 'number of bits invalid for bit field'))
result = self.fail_fields(("a", c_typ, 0))
- self.failUnlessEqual(result, (ValueError, 'number of bits invalid for bit field'))
+ self.assertEqual(result, (ValueError, 'number of bits invalid for bit field'))
class X(Structure):
_fields_ = [("a", c_typ, 1)]
- self.failUnlessEqual(sizeof(X), sizeof(c_typ))
+ self.assertEqual(sizeof(X), sizeof(c_typ))
class X(Structure):
_fields_ = [("a", c_typ, sizeof(c_typ)*8)]
- self.failUnlessEqual(sizeof(X), sizeof(c_typ))
+ self.assertEqual(sizeof(X), sizeof(c_typ))
result = self.fail_fields(("a", c_typ, sizeof(c_typ)*8 + 1))
- self.failUnlessEqual(result, (ValueError, 'number of bits invalid for bit field'))
+ self.assertEqual(result, (ValueError, 'number of bits invalid for bit field'))
def test_multi_bitfields_size(self):
class X(Structure):
_fields_ = [("a", c_short, 1),
("b", c_short, 14),
("c", c_short, 1)]
- self.failUnlessEqual(sizeof(X), sizeof(c_short))
+ self.assertEqual(sizeof(X), sizeof(c_short))
class X(Structure):
_fields_ = [("a", c_short, 1),
("a1", c_short),
("b", c_short, 14),
("c", c_short, 1)]
- self.failUnlessEqual(sizeof(X), sizeof(c_short)*3)
- self.failUnlessEqual(X.a.offset, 0)
- self.failUnlessEqual(X.a1.offset, sizeof(c_short))
- self.failUnlessEqual(X.b.offset, sizeof(c_short)*2)
- self.failUnlessEqual(X.c.offset, sizeof(c_short)*2)
+ self.assertEqual(sizeof(X), sizeof(c_short)*3)
+ self.assertEqual(X.a.offset, 0)
+ self.assertEqual(X.a1.offset, sizeof(c_short))
+ self.assertEqual(X.b.offset, sizeof(c_short)*2)
+ self.assertEqual(X.c.offset, sizeof(c_short)*2)
class X(Structure):
_fields_ = [("a", c_short, 3),
("b", c_short, 14),
("c", c_short, 14)]
- self.failUnlessEqual(sizeof(X), sizeof(c_short)*3)
- self.failUnlessEqual(X.a.offset, sizeof(c_short)*0)
- self.failUnlessEqual(X.b.offset, sizeof(c_short)*1)
- self.failUnlessEqual(X.c.offset, sizeof(c_short)*2)
+ self.assertEqual(sizeof(X), sizeof(c_short)*3)
+ self.assertEqual(X.a.offset, sizeof(c_short)*0)
+ self.assertEqual(X.b.offset, sizeof(c_short)*1)
+ self.assertEqual(X.c.offset, sizeof(c_short)*2)
def get_except(self, func, *args, **kw):
@@ -199,21 +199,21 @@
_fields_ = [("a", c_byte, 4),
("b", c_int, 4)]
if os.name in ("nt", "ce"):
- self.failUnlessEqual(sizeof(X), sizeof(c_int)*2)
+ self.assertEqual(sizeof(X), sizeof(c_int)*2)
else:
- self.failUnlessEqual(sizeof(X), sizeof(c_int))
+ self.assertEqual(sizeof(X), sizeof(c_int))
def test_mixed_2(self):
class X(Structure):
_fields_ = [("a", c_byte, 4),
("b", c_int, 32)]
- self.failUnlessEqual(sizeof(X), sizeof(c_int)*2)
+ self.assertEqual(sizeof(X), sizeof(c_int)*2)
def test_mixed_3(self):
class X(Structure):
_fields_ = [("a", c_byte, 4),
("b", c_ubyte, 4)]
- self.failUnlessEqual(sizeof(X), sizeof(c_byte))
+ self.assertEqual(sizeof(X), sizeof(c_byte))
def test_mixed_4(self):
class X(Structure):
@@ -227,9 +227,9 @@
# does (unless GCC is run with '-mms-bitfields' which
# produces code compatible with MSVC).
if os.name in ("nt", "ce"):
- self.failUnlessEqual(sizeof(X), sizeof(c_int) * 4)
+ self.assertEqual(sizeof(X), sizeof(c_int) * 4)
else:
- self.failUnlessEqual(sizeof(X), sizeof(c_int) * 2)
+ self.assertEqual(sizeof(X), sizeof(c_int) * 2)
def test_anon_bitfields(self):
# anonymous bit-fields gave a strange error message
Modified: python/branches/py3k/Lib/ctypes/test/test_buffers.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_buffers.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_buffers.py Wed Jul 1 01:06:06 2009
@@ -5,32 +5,32 @@
def test_buffer(self):
b = create_string_buffer(32)
- self.failUnlessEqual(len(b), 32)
- self.failUnlessEqual(sizeof(b), 32 * sizeof(c_char))
- self.failUnless(type(b[0]) is bytes)
+ self.assertEqual(len(b), 32)
+ self.assertEqual(sizeof(b), 32 * sizeof(c_char))
+ self.assertTrue(type(b[0]) is bytes)
b = create_string_buffer("abc")
- self.failUnlessEqual(len(b), 4) # trailing nul char
- self.failUnlessEqual(sizeof(b), 4 * sizeof(c_char))
- self.failUnless(type(b[0]) is bytes)
- self.failUnlessEqual(b[0], b"a")
- self.failUnlessEqual(b[:], b"abc\0")
- self.failUnlessEqual(b[::], b"abc\0")
- self.failUnlessEqual(b[::-1], b"\0cba")
- self.failUnlessEqual(b[::2], b"ac")
- self.failUnlessEqual(b[::5], b"a")
+ self.assertEqual(len(b), 4) # trailing nul char
+ self.assertEqual(sizeof(b), 4 * sizeof(c_char))
+ self.assertTrue(type(b[0]) is bytes)
+ self.assertEqual(b[0], b"a")
+ self.assertEqual(b[:], b"abc\0")
+ self.assertEqual(b[::], b"abc\0")
+ self.assertEqual(b[::-1], b"\0cba")
+ self.assertEqual(b[::2], b"ac")
+ self.assertEqual(b[::5], b"a")
def test_string_conversion(self):
b = create_string_buffer("abc")
- self.failUnlessEqual(len(b), 4) # trailing nul char
- self.failUnlessEqual(sizeof(b), 4 * sizeof(c_char))
- self.failUnless(type(b[0]) is bytes)
- self.failUnlessEqual(b[0], b"a")
- self.failUnlessEqual(b[:], b"abc\0")
- self.failUnlessEqual(b[::], b"abc\0")
- self.failUnlessEqual(b[::-1], b"\0cba")
- self.failUnlessEqual(b[::2], b"ac")
- self.failUnlessEqual(b[::5], b"a")
+ self.assertEqual(len(b), 4) # trailing nul char
+ self.assertEqual(sizeof(b), 4 * sizeof(c_char))
+ self.assertTrue(type(b[0]) is bytes)
+ self.assertEqual(b[0], b"a")
+ self.assertEqual(b[:], b"abc\0")
+ self.assertEqual(b[::], b"abc\0")
+ self.assertEqual(b[::-1], b"\0cba")
+ self.assertEqual(b[::2], b"ac")
+ self.assertEqual(b[::5], b"a")
try:
c_wchar
@@ -39,32 +39,32 @@
else:
def test_unicode_buffer(self):
b = create_unicode_buffer(32)
- self.failUnlessEqual(len(b), 32)
- self.failUnlessEqual(sizeof(b), 32 * sizeof(c_wchar))
- self.failUnless(type(b[0]) is str)
+ self.assertEqual(len(b), 32)
+ self.assertEqual(sizeof(b), 32 * sizeof(c_wchar))
+ self.assertTrue(type(b[0]) is str)
b = create_unicode_buffer("abc")
- self.failUnlessEqual(len(b), 4) # trailing nul char
- self.failUnlessEqual(sizeof(b), 4 * sizeof(c_wchar))
- self.failUnless(type(b[0]) is str)
- self.failUnlessEqual(b[0], "a")
- self.failUnlessEqual(b[:], "abc\0")
- self.failUnlessEqual(b[::], "abc\0")
- self.failUnlessEqual(b[::-1], "\0cba")
- self.failUnlessEqual(b[::2], "ac")
- self.failUnlessEqual(b[::5], "a")
+ self.assertEqual(len(b), 4) # trailing nul char
+ self.assertEqual(sizeof(b), 4 * sizeof(c_wchar))
+ self.assertTrue(type(b[0]) is str)
+ self.assertEqual(b[0], "a")
+ self.assertEqual(b[:], "abc\0")
+ self.assertEqual(b[::], "abc\0")
+ self.assertEqual(b[::-1], "\0cba")
+ self.assertEqual(b[::2], "ac")
+ self.assertEqual(b[::5], "a")
def test_unicode_conversion(self):
b = create_unicode_buffer("abc")
- self.failUnlessEqual(len(b), 4) # trailing nul char
- self.failUnlessEqual(sizeof(b), 4 * sizeof(c_wchar))
- self.failUnless(type(b[0]) is str)
- self.failUnlessEqual(b[0], "a")
- self.failUnlessEqual(b[:], "abc\0")
- self.failUnlessEqual(b[::], "abc\0")
- self.failUnlessEqual(b[::-1], "\0cba")
- self.failUnlessEqual(b[::2], "ac")
- self.failUnlessEqual(b[::5], "a")
+ self.assertEqual(len(b), 4) # trailing nul char
+ self.assertEqual(sizeof(b), 4 * sizeof(c_wchar))
+ self.assertTrue(type(b[0]) is str)
+ self.assertEqual(b[0], "a")
+ self.assertEqual(b[:], "abc\0")
+ self.assertEqual(b[::], "abc\0")
+ self.assertEqual(b[::-1], "\0cba")
+ self.assertEqual(b[::2], "ac")
+ self.assertEqual(b[::5], "a")
if __name__ == "__main__":
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_byteswap.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_byteswap.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_byteswap.py Wed Jul 1 01:06:06 2009
@@ -23,131 +23,131 @@
def test_endian_short(self):
if sys.byteorder == "little":
- self.failUnless(c_short.__ctype_le__ is c_short)
- self.failUnless(c_short.__ctype_be__.__ctype_le__ is c_short)
+ self.assertTrue(c_short.__ctype_le__ is c_short)
+ self.assertTrue(c_short.__ctype_be__.__ctype_le__ is c_short)
else:
- self.failUnless(c_short.__ctype_be__ is c_short)
- self.failUnless(c_short.__ctype_le__.__ctype_be__ is c_short)
+ self.assertTrue(c_short.__ctype_be__ is c_short)
+ self.assertTrue(c_short.__ctype_le__.__ctype_be__ is c_short)
s = c_short.__ctype_be__(0x1234)
- self.failUnlessEqual(bin(struct.pack(">h", 0x1234)), "1234")
- self.failUnlessEqual(bin(s), "1234")
- self.failUnlessEqual(s.value, 0x1234)
+ self.assertEqual(bin(struct.pack(">h", 0x1234)), "1234")
+ self.assertEqual(bin(s), "1234")
+ self.assertEqual(s.value, 0x1234)
s = c_short.__ctype_le__(0x1234)
- self.failUnlessEqual(bin(struct.pack("<h", 0x1234)), "3412")
- self.failUnlessEqual(bin(s), "3412")
- self.failUnlessEqual(s.value, 0x1234)
+ self.assertEqual(bin(struct.pack("<h", 0x1234)), "3412")
+ self.assertEqual(bin(s), "3412")
+ self.assertEqual(s.value, 0x1234)
s = c_ushort.__ctype_be__(0x1234)
- self.failUnlessEqual(bin(struct.pack(">h", 0x1234)), "1234")
- self.failUnlessEqual(bin(s), "1234")
- self.failUnlessEqual(s.value, 0x1234)
+ self.assertEqual(bin(struct.pack(">h", 0x1234)), "1234")
+ self.assertEqual(bin(s), "1234")
+ self.assertEqual(s.value, 0x1234)
s = c_ushort.__ctype_le__(0x1234)
- self.failUnlessEqual(bin(struct.pack("<h", 0x1234)), "3412")
- self.failUnlessEqual(bin(s), "3412")
- self.failUnlessEqual(s.value, 0x1234)
+ self.assertEqual(bin(struct.pack("<h", 0x1234)), "3412")
+ self.assertEqual(bin(s), "3412")
+ self.assertEqual(s.value, 0x1234)
def test_endian_int(self):
if sys.byteorder == "little":
- self.failUnless(c_int.__ctype_le__ is c_int)
- self.failUnless(c_int.__ctype_be__.__ctype_le__ is c_int)
+ self.assertTrue(c_int.__ctype_le__ is c_int)
+ self.assertTrue(c_int.__ctype_be__.__ctype_le__ is c_int)
else:
- self.failUnless(c_int.__ctype_be__ is c_int)
- self.failUnless(c_int.__ctype_le__.__ctype_be__ is c_int)
+ self.assertTrue(c_int.__ctype_be__ is c_int)
+ self.assertTrue(c_int.__ctype_le__.__ctype_be__ is c_int)
s = c_int.__ctype_be__(0x12345678)
- self.failUnlessEqual(bin(struct.pack(">i", 0x12345678)), "12345678")
- self.failUnlessEqual(bin(s), "12345678")
- self.failUnlessEqual(s.value, 0x12345678)
+ self.assertEqual(bin(struct.pack(">i", 0x12345678)), "12345678")
+ self.assertEqual(bin(s), "12345678")
+ self.assertEqual(s.value, 0x12345678)
s = c_int.__ctype_le__(0x12345678)
- self.failUnlessEqual(bin(struct.pack("<i", 0x12345678)), "78563412")
- self.failUnlessEqual(bin(s), "78563412")
- self.failUnlessEqual(s.value, 0x12345678)
+ self.assertEqual(bin(struct.pack("<i", 0x12345678)), "78563412")
+ self.assertEqual(bin(s), "78563412")
+ self.assertEqual(s.value, 0x12345678)
s = c_uint.__ctype_be__(0x12345678)
- self.failUnlessEqual(bin(struct.pack(">I", 0x12345678)), "12345678")
- self.failUnlessEqual(bin(s), "12345678")
- self.failUnlessEqual(s.value, 0x12345678)
+ self.assertEqual(bin(struct.pack(">I", 0x12345678)), "12345678")
+ self.assertEqual(bin(s), "12345678")
+ self.assertEqual(s.value, 0x12345678)
s = c_uint.__ctype_le__(0x12345678)
- self.failUnlessEqual(bin(struct.pack("<I", 0x12345678)), "78563412")
- self.failUnlessEqual(bin(s), "78563412")
- self.failUnlessEqual(s.value, 0x12345678)
+ self.assertEqual(bin(struct.pack("<I", 0x12345678)), "78563412")
+ self.assertEqual(bin(s), "78563412")
+ self.assertEqual(s.value, 0x12345678)
def test_endian_longlong(self):
if sys.byteorder == "little":
- self.failUnless(c_longlong.__ctype_le__ is c_longlong)
- self.failUnless(c_longlong.__ctype_be__.__ctype_le__ is c_longlong)
+ self.assertTrue(c_longlong.__ctype_le__ is c_longlong)
+ self.assertTrue(c_longlong.__ctype_be__.__ctype_le__ is c_longlong)
else:
- self.failUnless(c_longlong.__ctype_be__ is c_longlong)
- self.failUnless(c_longlong.__ctype_le__.__ctype_be__ is c_longlong)
+ self.assertTrue(c_longlong.__ctype_be__ is c_longlong)
+ self.assertTrue(c_longlong.__ctype_le__.__ctype_be__ is c_longlong)
s = c_longlong.__ctype_be__(0x1234567890ABCDEF)
- self.failUnlessEqual(bin(struct.pack(">q", 0x1234567890ABCDEF)), "1234567890ABCDEF")
- self.failUnlessEqual(bin(s), "1234567890ABCDEF")
- self.failUnlessEqual(s.value, 0x1234567890ABCDEF)
+ self.assertEqual(bin(struct.pack(">q", 0x1234567890ABCDEF)), "1234567890ABCDEF")
+ self.assertEqual(bin(s), "1234567890ABCDEF")
+ self.assertEqual(s.value, 0x1234567890ABCDEF)
s = c_longlong.__ctype_le__(0x1234567890ABCDEF)
- self.failUnlessEqual(bin(struct.pack("<q", 0x1234567890ABCDEF)), "EFCDAB9078563412")
- self.failUnlessEqual(bin(s), "EFCDAB9078563412")
- self.failUnlessEqual(s.value, 0x1234567890ABCDEF)
+ self.assertEqual(bin(struct.pack("<q", 0x1234567890ABCDEF)), "EFCDAB9078563412")
+ self.assertEqual(bin(s), "EFCDAB9078563412")
+ self.assertEqual(s.value, 0x1234567890ABCDEF)
s = c_ulonglong.__ctype_be__(0x1234567890ABCDEF)
- self.failUnlessEqual(bin(struct.pack(">Q", 0x1234567890ABCDEF)), "1234567890ABCDEF")
- self.failUnlessEqual(bin(s), "1234567890ABCDEF")
- self.failUnlessEqual(s.value, 0x1234567890ABCDEF)
+ self.assertEqual(bin(struct.pack(">Q", 0x1234567890ABCDEF)), "1234567890ABCDEF")
+ self.assertEqual(bin(s), "1234567890ABCDEF")
+ self.assertEqual(s.value, 0x1234567890ABCDEF)
s = c_ulonglong.__ctype_le__(0x1234567890ABCDEF)
- self.failUnlessEqual(bin(struct.pack("<Q", 0x1234567890ABCDEF)), "EFCDAB9078563412")
- self.failUnlessEqual(bin(s), "EFCDAB9078563412")
- self.failUnlessEqual(s.value, 0x1234567890ABCDEF)
+ self.assertEqual(bin(struct.pack("<Q", 0x1234567890ABCDEF)), "EFCDAB9078563412")
+ self.assertEqual(bin(s), "EFCDAB9078563412")
+ self.assertEqual(s.value, 0x1234567890ABCDEF)
def test_endian_float(self):
if sys.byteorder == "little":
- self.failUnless(c_float.__ctype_le__ is c_float)
- self.failUnless(c_float.__ctype_be__.__ctype_le__ is c_float)
+ self.assertTrue(c_float.__ctype_le__ is c_float)
+ self.assertTrue(c_float.__ctype_be__.__ctype_le__ is c_float)
else:
- self.failUnless(c_float.__ctype_be__ is c_float)
- self.failUnless(c_float.__ctype_le__.__ctype_be__ is c_float)
+ self.assertTrue(c_float.__ctype_be__ is c_float)
+ self.assertTrue(c_float.__ctype_le__.__ctype_be__ is c_float)
s = c_float(math.pi)
- self.failUnlessEqual(bin(struct.pack("f", math.pi)), bin(s))
+ self.assertEqual(bin(struct.pack("f", math.pi)), bin(s))
# Hm, what's the precision of a float compared to a double?
- self.failUnlessAlmostEqual(s.value, math.pi, places=6)
+ self.assertAlmostEqual(s.value, math.pi, places=6)
s = c_float.__ctype_le__(math.pi)
- self.failUnlessAlmostEqual(s.value, math.pi, places=6)
- self.failUnlessEqual(bin(struct.pack("<f", math.pi)), bin(s))
+ self.assertAlmostEqual(s.value, math.pi, places=6)
+ self.assertEqual(bin(struct.pack("<f", math.pi)), bin(s))
s = c_float.__ctype_be__(math.pi)
- self.failUnlessAlmostEqual(s.value, math.pi, places=6)
- self.failUnlessEqual(bin(struct.pack(">f", math.pi)), bin(s))
+ self.assertAlmostEqual(s.value, math.pi, places=6)
+ self.assertEqual(bin(struct.pack(">f", math.pi)), bin(s))
def test_endian_double(self):
if sys.byteorder == "little":
- self.failUnless(c_double.__ctype_le__ is c_double)
- self.failUnless(c_double.__ctype_be__.__ctype_le__ is c_double)
+ self.assertTrue(c_double.__ctype_le__ is c_double)
+ self.assertTrue(c_double.__ctype_be__.__ctype_le__ is c_double)
else:
- self.failUnless(c_double.__ctype_be__ is c_double)
- self.failUnless(c_double.__ctype_le__.__ctype_be__ is c_double)
+ self.assertTrue(c_double.__ctype_be__ is c_double)
+ self.assertTrue(c_double.__ctype_le__.__ctype_be__ is c_double)
s = c_double(math.pi)
- self.failUnlessEqual(s.value, math.pi)
- self.failUnlessEqual(bin(struct.pack("d", math.pi)), bin(s))
+ self.assertEqual(s.value, math.pi)
+ self.assertEqual(bin(struct.pack("d", math.pi)), bin(s))
s = c_double.__ctype_le__(math.pi)
- self.failUnlessEqual(s.value, math.pi)
- self.failUnlessEqual(bin(struct.pack("<d", math.pi)), bin(s))
+ self.assertEqual(s.value, math.pi)
+ self.assertEqual(bin(struct.pack("<d", math.pi)), bin(s))
s = c_double.__ctype_be__(math.pi)
- self.failUnlessEqual(s.value, math.pi)
- self.failUnlessEqual(bin(struct.pack(">d", math.pi)), bin(s))
+ self.assertEqual(s.value, math.pi)
+ self.assertEqual(bin(struct.pack(">d", math.pi)), bin(s))
def test_endian_other(self):
- self.failUnless(c_byte.__ctype_le__ is c_byte)
- self.failUnless(c_byte.__ctype_be__ is c_byte)
+ self.assertTrue(c_byte.__ctype_le__ is c_byte)
+ self.assertTrue(c_byte.__ctype_be__ is c_byte)
- self.failUnless(c_ubyte.__ctype_le__ is c_ubyte)
- self.failUnless(c_ubyte.__ctype_be__ is c_ubyte)
+ self.assertTrue(c_ubyte.__ctype_le__ is c_ubyte)
+ self.assertTrue(c_ubyte.__ctype_be__ is c_ubyte)
- self.failUnless(c_char.__ctype_le__ is c_char)
- self.failUnless(c_char.__ctype_be__ is c_char)
+ self.assertTrue(c_char.__ctype_le__ is c_char)
+ self.assertTrue(c_char.__ctype_be__ is c_char)
def test_struct_fields_1(self):
if sys.byteorder == "little":
@@ -219,7 +219,7 @@
s1 = S(0x12, 0x1234, 0x12345678, 3.14)
s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14)
- self.failUnlessEqual(bin(s1), bin(s2))
+ self.assertEqual(bin(s1), bin(s2))
def test_unaligned_nonnative_struct_fields(self):
if sys.byteorder == "little":
@@ -247,7 +247,7 @@
s1.i = 0x12345678
s1.d = 3.14
s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14)
- self.failUnlessEqual(bin(s1), bin(s2))
+ self.assertEqual(bin(s1), bin(s2))
def test_unaligned_native_struct_fields(self):
if sys.byteorder == "little":
@@ -274,7 +274,7 @@
s1.i = 0x12345678
s1.d = 3.14
s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14)
- self.failUnlessEqual(bin(s1), bin(s2))
+ self.assertEqual(bin(s1), bin(s2))
if __name__ == "__main__":
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_callbacks.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_callbacks.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_callbacks.py Wed Jul 1 01:06:06 2009
@@ -17,18 +17,18 @@
PROTO = self.functype.__func__(typ, typ)
result = PROTO(self.callback)(arg)
if typ == c_float:
- self.failUnlessAlmostEqual(result, arg, places=5)
+ self.assertAlmostEqual(result, arg, places=5)
else:
- self.failUnlessEqual(self.got_args, (arg,))
- self.failUnlessEqual(result, arg)
+ self.assertEqual(self.got_args, (arg,))
+ self.assertEqual(result, arg)
PROTO = self.functype.__func__(typ, c_byte, typ)
result = PROTO(self.callback)(-3, arg)
if typ == c_float:
- self.failUnlessAlmostEqual(result, arg, places=5)
+ self.assertAlmostEqual(result, arg, places=5)
else:
- self.failUnlessEqual(self.got_args, (-3, arg))
- self.failUnlessEqual(result, arg)
+ self.assertEqual(self.got_args, (-3, arg))
+ self.assertEqual(result, arg)
################
@@ -103,7 +103,7 @@
# ...but this call doesn't leak any more. Where is the refcount?
self.check_type(py_object, o)
after = grc(o)
- self.failUnlessEqual((after, o), (before, o))
+ self.assertEqual((after, o), (before, o))
def test_unsupported_restype_1(self):
# Only "fundamental" result types are supported for callback
@@ -148,7 +148,7 @@
result = integrate(0.0, 1.0, CALLBACK(func), 10)
diff = abs(result - 1./3.)
- self.failUnless(diff < 0.01, "%s not less than 0.01" % diff)
+ self.assertTrue(diff < 0.01, "%s not less than 0.01" % diff)
################################################################
Modified: python/branches/py3k/Lib/ctypes/test/test_cast.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_cast.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_cast.py Wed Jul 1 01:06:06 2009
@@ -9,15 +9,15 @@
# casting an array to a pointer works.
ptr = cast(array, POINTER(c_int))
- self.failUnlessEqual([ptr[i] for i in range(3)], [42, 17, 2])
+ self.assertEqual([ptr[i] for i in range(3)], [42, 17, 2])
if 2*sizeof(c_short) == sizeof(c_int):
ptr = cast(array, POINTER(c_short))
if sys.byteorder == "little":
- self.failUnlessEqual([ptr[i] for i in range(6)],
+ self.assertEqual([ptr[i] for i in range(6)],
[42, 0, 17, 0, 2, 0])
else:
- self.failUnlessEqual([ptr[i] for i in range(6)],
+ self.assertEqual([ptr[i] for i in range(6)],
[0, 42, 0, 17, 0, 2])
def test_address2pointer(self):
@@ -25,54 +25,54 @@
address = addressof(array)
ptr = cast(c_void_p(address), POINTER(c_int))
- self.failUnlessEqual([ptr[i] for i in range(3)], [42, 17, 2])
+ self.assertEqual([ptr[i] for i in range(3)], [42, 17, 2])
ptr = cast(address, POINTER(c_int))
- self.failUnlessEqual([ptr[i] for i in range(3)], [42, 17, 2])
+ self.assertEqual([ptr[i] for i in range(3)], [42, 17, 2])
def test_p2a_objects(self):
array = (c_char_p * 5)()
- self.failUnlessEqual(array._objects, None)
+ self.assertEqual(array._objects, None)
array[0] = "foo bar"
- self.failUnlessEqual(array._objects, {'0': b"foo bar"})
+ self.assertEqual(array._objects, {'0': b"foo bar"})
p = cast(array, POINTER(c_char_p))
# array and p share a common _objects attribute
- self.failUnless(p._objects is array._objects)
- self.failUnlessEqual(array._objects, {'0': b"foo bar", id(array): array})
+ self.assertTrue(p._objects is array._objects)
+ self.assertEqual(array._objects, {'0': b"foo bar", id(array): array})
p[0] = "spam spam"
- self.failUnlessEqual(p._objects, {'0': b"spam spam", id(array): array})
- self.failUnless(array._objects is p._objects)
+ self.assertEqual(p._objects, {'0': b"spam spam", id(array): array})
+ self.assertTrue(array._objects is p._objects)
p[1] = "foo bar"
- self.failUnlessEqual(p._objects, {'1': b'foo bar', '0': b"spam spam", id(array): array})
- self.failUnless(array._objects is p._objects)
+ self.assertEqual(p._objects, {'1': b'foo bar', '0': b"spam spam", id(array): array})
+ self.assertTrue(array._objects is p._objects)
def test_other(self):
p = cast((c_int * 4)(1, 2, 3, 4), POINTER(c_int))
- self.failUnlessEqual(p[:4], [1,2, 3, 4])
- self.failUnlessEqual(p[:4:], [1, 2, 3, 4])
- self.failUnlessEqual(p[3:-1:-1], [4, 3, 2, 1])
- self.failUnlessEqual(p[:4:3], [1, 4])
+ self.assertEqual(p[:4], [1,2, 3, 4])
+ self.assertEqual(p[:4:], [1, 2, 3, 4])
+ self.assertEqual(p[3:-1:-1], [4, 3, 2, 1])
+ self.assertEqual(p[:4:3], [1, 4])
c_int()
- self.failUnlessEqual(p[:4], [1, 2, 3, 4])
- self.failUnlessEqual(p[:4:], [1, 2, 3, 4])
- self.failUnlessEqual(p[3:-1:-1], [4, 3, 2, 1])
- self.failUnlessEqual(p[:4:3], [1, 4])
+ self.assertEqual(p[:4], [1, 2, 3, 4])
+ self.assertEqual(p[:4:], [1, 2, 3, 4])
+ self.assertEqual(p[3:-1:-1], [4, 3, 2, 1])
+ self.assertEqual(p[:4:3], [1, 4])
p[2] = 96
- self.failUnlessEqual(p[:4], [1, 2, 96, 4])
- self.failUnlessEqual(p[:4:], [1, 2, 96, 4])
- self.failUnlessEqual(p[3:-1:-1], [4, 96, 2, 1])
- self.failUnlessEqual(p[:4:3], [1, 4])
+ self.assertEqual(p[:4], [1, 2, 96, 4])
+ self.assertEqual(p[:4:], [1, 2, 96, 4])
+ self.assertEqual(p[3:-1:-1], [4, 96, 2, 1])
+ self.assertEqual(p[:4:3], [1, 4])
c_int()
- self.failUnlessEqual(p[:4], [1, 2, 96, 4])
- self.failUnlessEqual(p[:4:], [1, 2, 96, 4])
- self.failUnlessEqual(p[3:-1:-1], [4, 96, 2, 1])
- self.failUnlessEqual(p[:4:3], [1, 4])
+ self.assertEqual(p[:4], [1, 2, 96, 4])
+ self.assertEqual(p[:4:], [1, 2, 96, 4])
+ self.assertEqual(p[3:-1:-1], [4, 96, 2, 1])
+ self.assertEqual(p[:4:3], [1, 4])
def test_char_p(self):
# This didn't work: bad argument to internal function
s = c_char_p("hiho")
- self.failUnlessEqual(cast(cast(s, c_void_p), c_char_p).value,
+ self.assertEqual(cast(cast(s, c_void_p), c_char_p).value,
"hiho")
try:
@@ -82,7 +82,7 @@
else:
def test_wchar_p(self):
s = c_wchar_p("hiho")
- self.failUnlessEqual(cast(cast(s, c_void_p), c_wchar_p).value,
+ self.assertEqual(cast(cast(s, c_void_p), c_wchar_p).value,
"hiho")
if __name__ == "__main__":
Modified: python/branches/py3k/Lib/ctypes/test/test_cfuncs.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_cfuncs.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_cfuncs.py Wed Jul 1 01:06:06 2009
@@ -17,176 +17,176 @@
def test_byte(self):
self._dll.tf_b.restype = c_byte
self._dll.tf_b.argtypes = (c_byte,)
- self.failUnlessEqual(self._dll.tf_b(-126), -42)
- self.failUnlessEqual(self.S(), -126)
+ self.assertEqual(self._dll.tf_b(-126), -42)
+ self.assertEqual(self.S(), -126)
def test_byte_plus(self):
self._dll.tf_bb.restype = c_byte
self._dll.tf_bb.argtypes = (c_byte, c_byte)
- self.failUnlessEqual(self._dll.tf_bb(0, -126), -42)
- self.failUnlessEqual(self.S(), -126)
+ self.assertEqual(self._dll.tf_bb(0, -126), -42)
+ self.assertEqual(self.S(), -126)
def test_ubyte(self):
self._dll.tf_B.restype = c_ubyte
self._dll.tf_B.argtypes = (c_ubyte,)
- self.failUnlessEqual(self._dll.tf_B(255), 85)
- self.failUnlessEqual(self.U(), 255)
+ self.assertEqual(self._dll.tf_B(255), 85)
+ self.assertEqual(self.U(), 255)
def test_ubyte_plus(self):
self._dll.tf_bB.restype = c_ubyte
self._dll.tf_bB.argtypes = (c_byte, c_ubyte)
- self.failUnlessEqual(self._dll.tf_bB(0, 255), 85)
- self.failUnlessEqual(self.U(), 255)
+ self.assertEqual(self._dll.tf_bB(0, 255), 85)
+ self.assertEqual(self.U(), 255)
def test_short(self):
self._dll.tf_h.restype = c_short
self._dll.tf_h.argtypes = (c_short,)
- self.failUnlessEqual(self._dll.tf_h(-32766), -10922)
- self.failUnlessEqual(self.S(), -32766)
+ self.assertEqual(self._dll.tf_h(-32766), -10922)
+ self.assertEqual(self.S(), -32766)
def test_short_plus(self):
self._dll.tf_bh.restype = c_short
self._dll.tf_bh.argtypes = (c_byte, c_short)
- self.failUnlessEqual(self._dll.tf_bh(0, -32766), -10922)
- self.failUnlessEqual(self.S(), -32766)
+ self.assertEqual(self._dll.tf_bh(0, -32766), -10922)
+ self.assertEqual(self.S(), -32766)
def test_ushort(self):
self._dll.tf_H.restype = c_ushort
self._dll.tf_H.argtypes = (c_ushort,)
- self.failUnlessEqual(self._dll.tf_H(65535), 21845)
- self.failUnlessEqual(self.U(), 65535)
+ self.assertEqual(self._dll.tf_H(65535), 21845)
+ self.assertEqual(self.U(), 65535)
def test_ushort_plus(self):
self._dll.tf_bH.restype = c_ushort
self._dll.tf_bH.argtypes = (c_byte, c_ushort)
- self.failUnlessEqual(self._dll.tf_bH(0, 65535), 21845)
- self.failUnlessEqual(self.U(), 65535)
+ self.assertEqual(self._dll.tf_bH(0, 65535), 21845)
+ self.assertEqual(self.U(), 65535)
def test_int(self):
self._dll.tf_i.restype = c_int
self._dll.tf_i.argtypes = (c_int,)
- self.failUnlessEqual(self._dll.tf_i(-2147483646), -715827882)
- self.failUnlessEqual(self.S(), -2147483646)
+ self.assertEqual(self._dll.tf_i(-2147483646), -715827882)
+ self.assertEqual(self.S(), -2147483646)
def test_int_plus(self):
self._dll.tf_bi.restype = c_int
self._dll.tf_bi.argtypes = (c_byte, c_int)
- self.failUnlessEqual(self._dll.tf_bi(0, -2147483646), -715827882)
- self.failUnlessEqual(self.S(), -2147483646)
+ self.assertEqual(self._dll.tf_bi(0, -2147483646), -715827882)
+ self.assertEqual(self.S(), -2147483646)
def test_uint(self):
self._dll.tf_I.restype = c_uint
self._dll.tf_I.argtypes = (c_uint,)
- self.failUnlessEqual(self._dll.tf_I(4294967295), 1431655765)
- self.failUnlessEqual(self.U(), 4294967295)
+ self.assertEqual(self._dll.tf_I(4294967295), 1431655765)
+ self.assertEqual(self.U(), 4294967295)
def test_uint_plus(self):
self._dll.tf_bI.restype = c_uint
self._dll.tf_bI.argtypes = (c_byte, c_uint)
- self.failUnlessEqual(self._dll.tf_bI(0, 4294967295), 1431655765)
- self.failUnlessEqual(self.U(), 4294967295)
+ self.assertEqual(self._dll.tf_bI(0, 4294967295), 1431655765)
+ self.assertEqual(self.U(), 4294967295)
def test_long(self):
self._dll.tf_l.restype = c_long
self._dll.tf_l.argtypes = (c_long,)
- self.failUnlessEqual(self._dll.tf_l(-2147483646), -715827882)
- self.failUnlessEqual(self.S(), -2147483646)
+ self.assertEqual(self._dll.tf_l(-2147483646), -715827882)
+ self.assertEqual(self.S(), -2147483646)
def test_long_plus(self):
self._dll.tf_bl.restype = c_long
self._dll.tf_bl.argtypes = (c_byte, c_long)
- self.failUnlessEqual(self._dll.tf_bl(0, -2147483646), -715827882)
- self.failUnlessEqual(self.S(), -2147483646)
+ self.assertEqual(self._dll.tf_bl(0, -2147483646), -715827882)
+ self.assertEqual(self.S(), -2147483646)
def test_ulong(self):
self._dll.tf_L.restype = c_ulong
self._dll.tf_L.argtypes = (c_ulong,)
- self.failUnlessEqual(self._dll.tf_L(4294967295), 1431655765)
- self.failUnlessEqual(self.U(), 4294967295)
+ self.assertEqual(self._dll.tf_L(4294967295), 1431655765)
+ self.assertEqual(self.U(), 4294967295)
def test_ulong_plus(self):
self._dll.tf_bL.restype = c_ulong
self._dll.tf_bL.argtypes = (c_char, c_ulong)
- self.failUnlessEqual(self._dll.tf_bL(' ', 4294967295), 1431655765)
- self.failUnlessEqual(self.U(), 4294967295)
+ self.assertEqual(self._dll.tf_bL(' ', 4294967295), 1431655765)
+ self.assertEqual(self.U(), 4294967295)
def test_longlong(self):
self._dll.tf_q.restype = c_longlong
self._dll.tf_q.argtypes = (c_longlong, )
- self.failUnlessEqual(self._dll.tf_q(-9223372036854775806), -3074457345618258602)
- self.failUnlessEqual(self.S(), -9223372036854775806)
+ self.assertEqual(self._dll.tf_q(-9223372036854775806), -3074457345618258602)
+ self.assertEqual(self.S(), -9223372036854775806)
def test_longlong_plus(self):
self._dll.tf_bq.restype = c_longlong
self._dll.tf_bq.argtypes = (c_byte, c_longlong)
- self.failUnlessEqual(self._dll.tf_bq(0, -9223372036854775806), -3074457345618258602)
- self.failUnlessEqual(self.S(), -9223372036854775806)
+ self.assertEqual(self._dll.tf_bq(0, -9223372036854775806), -3074457345618258602)
+ self.assertEqual(self.S(), -9223372036854775806)
def test_ulonglong(self):
self._dll.tf_Q.restype = c_ulonglong
self._dll.tf_Q.argtypes = (c_ulonglong, )
- self.failUnlessEqual(self._dll.tf_Q(18446744073709551615), 6148914691236517205)
- self.failUnlessEqual(self.U(), 18446744073709551615)
+ self.assertEqual(self._dll.tf_Q(18446744073709551615), 6148914691236517205)
+ self.assertEqual(self.U(), 18446744073709551615)
def test_ulonglong_plus(self):
self._dll.tf_bQ.restype = c_ulonglong
self._dll.tf_bQ.argtypes = (c_byte, c_ulonglong)
- self.failUnlessEqual(self._dll.tf_bQ(0, 18446744073709551615), 6148914691236517205)
- self.failUnlessEqual(self.U(), 18446744073709551615)
+ self.assertEqual(self._dll.tf_bQ(0, 18446744073709551615), 6148914691236517205)
+ self.assertEqual(self.U(), 18446744073709551615)
def test_float(self):
self._dll.tf_f.restype = c_float
self._dll.tf_f.argtypes = (c_float,)
- self.failUnlessEqual(self._dll.tf_f(-42.), -14.)
- self.failUnlessEqual(self.S(), -42)
+ self.assertEqual(self._dll.tf_f(-42.), -14.)
+ self.assertEqual(self.S(), -42)
def test_float_plus(self):
self._dll.tf_bf.restype = c_float
self._dll.tf_bf.argtypes = (c_byte, c_float)
- self.failUnlessEqual(self._dll.tf_bf(0, -42.), -14.)
- self.failUnlessEqual(self.S(), -42)
+ self.assertEqual(self._dll.tf_bf(0, -42.), -14.)
+ self.assertEqual(self.S(), -42)
def test_double(self):
self._dll.tf_d.restype = c_double
self._dll.tf_d.argtypes = (c_double,)
- self.failUnlessEqual(self._dll.tf_d(42.), 14.)
- self.failUnlessEqual(self.S(), 42)
+ self.assertEqual(self._dll.tf_d(42.), 14.)
+ self.assertEqual(self.S(), 42)
def test_double_plus(self):
self._dll.tf_bd.restype = c_double
self._dll.tf_bd.argtypes = (c_byte, c_double)
- self.failUnlessEqual(self._dll.tf_bd(0, 42.), 14.)
- self.failUnlessEqual(self.S(), 42)
+ self.assertEqual(self._dll.tf_bd(0, 42.), 14.)
+ self.assertEqual(self.S(), 42)
def test_longdouble(self):
self._dll.tf_D.restype = c_longdouble
self._dll.tf_D.argtypes = (c_longdouble,)
- self.failUnlessEqual(self._dll.tf_D(42.), 14.)
- self.failUnlessEqual(self.S(), 42)
+ self.assertEqual(self._dll.tf_D(42.), 14.)
+ self.assertEqual(self.S(), 42)
def test_longdouble_plus(self):
self._dll.tf_bD.restype = c_longdouble
self._dll.tf_bD.argtypes = (c_byte, c_longdouble)
- self.failUnlessEqual(self._dll.tf_bD(0, 42.), 14.)
- self.failUnlessEqual(self.S(), 42)
+ self.assertEqual(self._dll.tf_bD(0, 42.), 14.)
+ self.assertEqual(self.S(), 42)
def test_callwithresult(self):
def process_result(result):
return result * 2
self._dll.tf_i.restype = process_result
self._dll.tf_i.argtypes = (c_int,)
- self.failUnlessEqual(self._dll.tf_i(42), 28)
- self.failUnlessEqual(self.S(), 42)
- self.failUnlessEqual(self._dll.tf_i(-42), -28)
- self.failUnlessEqual(self.S(), -42)
+ self.assertEqual(self._dll.tf_i(42), 28)
+ self.assertEqual(self.S(), 42)
+ self.assertEqual(self._dll.tf_i(-42), -28)
+ self.assertEqual(self.S(), -42)
def test_void(self):
self._dll.tv_i.restype = None
self._dll.tv_i.argtypes = (c_int,)
- self.failUnlessEqual(self._dll.tv_i(42), None)
- self.failUnlessEqual(self.S(), 42)
- self.failUnlessEqual(self._dll.tv_i(-42), None)
- self.failUnlessEqual(self.S(), -42)
+ self.assertEqual(self._dll.tv_i(42), None)
+ self.assertEqual(self.S(), 42)
+ self.assertEqual(self._dll.tv_i(-42), None)
+ self.assertEqual(self.S(), -42)
# The following repeates the above tests with stdcall functions (where
# they are available)
Modified: python/branches/py3k/Lib/ctypes/test/test_checkretval.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_checkretval.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_checkretval.py Wed Jul 1 01:06:06 2009
@@ -14,16 +14,16 @@
import _ctypes_test
dll = CDLL(_ctypes_test.__file__)
- self.failUnlessEqual(42, dll._testfunc_p_p(42))
+ self.assertEqual(42, dll._testfunc_p_p(42))
dll._testfunc_p_p.restype = CHECKED
- self.failUnlessEqual("42", dll._testfunc_p_p(42))
+ self.assertEqual("42", dll._testfunc_p_p(42))
dll._testfunc_p_p.restype = None
- self.failUnlessEqual(None, dll._testfunc_p_p(42))
+ self.assertEqual(None, dll._testfunc_p_p(42))
del dll._testfunc_p_p.restype
- self.failUnlessEqual(42, dll._testfunc_p_p(42))
+ self.assertEqual(42, dll._testfunc_p_p(42))
try:
oledll
@@ -31,7 +31,7 @@
pass
else:
def test_oledll(self):
- self.failUnlessRaises(WindowsError,
+ self.assertRaises(WindowsError,
oledll.oleaut32.CreateTypeLib2,
0, None, None)
Modified: python/branches/py3k/Lib/ctypes/test/test_errno.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_errno.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_errno.py Wed Jul 1 01:06:06 2009
@@ -15,11 +15,11 @@
libc_open.argtypes = c_char_p, c_int
- self.failUnlessEqual(libc_open("", 0), -1)
- self.failUnlessEqual(get_errno(), errno.ENOENT)
+ self.assertEqual(libc_open("", 0), -1)
+ self.assertEqual(get_errno(), errno.ENOENT)
- self.failUnlessEqual(set_errno(32), errno.ENOENT)
- self.failUnlessEqual(get_errno(), 32)
+ self.assertEqual(set_errno(32), errno.ENOENT)
+ self.assertEqual(get_errno(), 32)
def _worker():
@@ -31,14 +31,14 @@
else:
libc_open = libc.open
libc_open.argtypes = c_char_p, c_int
- self.failUnlessEqual(libc_open("", 0), -1)
- self.failUnlessEqual(get_errno(), 0)
+ self.assertEqual(libc_open("", 0), -1)
+ self.assertEqual(get_errno(), 0)
t = threading.Thread(target=_worker)
t.start()
t.join()
- self.failUnlessEqual(get_errno(), 32)
+ self.assertEqual(get_errno(), 32)
set_errno(0)
if os.name == "nt":
@@ -48,11 +48,11 @@
GetModuleHandle = dll.GetModuleHandleA
GetModuleHandle.argtypes = [c_wchar_p]
- self.failUnlessEqual(0, GetModuleHandle("foo"))
- self.failUnlessEqual(get_last_error(), 126)
+ self.assertEqual(0, GetModuleHandle("foo"))
+ self.assertEqual(get_last_error(), 126)
- self.failUnlessEqual(set_last_error(32), 126)
- self.failUnlessEqual(get_last_error(), 32)
+ self.assertEqual(set_last_error(32), 126)
+ self.assertEqual(get_last_error(), 32)
def _worker():
set_last_error(0)
@@ -62,13 +62,13 @@
GetModuleHandle.argtypes = [c_wchar_p]
GetModuleHandle("bar")
- self.failUnlessEqual(get_last_error(), 0)
+ self.assertEqual(get_last_error(), 0)
t = threading.Thread(target=_worker)
t.start()
t.join()
- self.failUnlessEqual(get_last_error(), 32)
+ self.assertEqual(get_last_error(), 32)
set_last_error(0)
Modified: python/branches/py3k/Lib/ctypes/test/test_find.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_find.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_find.py Wed Jul 1 01:06:06 2009
@@ -76,7 +76,7 @@
## sqrt = libm.sqrt
## sqrt.argtypes = (c_double,)
## sqrt.restype = c_double
-## self.failUnlessEqual(sqrt(2), math.sqrt(2))
+## self.assertEqual(sqrt(2), math.sqrt(2))
if __name__ == "__main__":
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_frombuffer.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_frombuffer.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_frombuffer.py Wed Jul 1 01:06:06 2009
@@ -16,14 +16,14 @@
y = X.from_buffer(a)
self.assertEqual(y.c_int, a[0])
- self.failIf(y.init_called)
+ self.assertFalse(y.init_called)
self.assertEqual(x[:], a.tolist())
a[0], a[-1] = 200, -200
self.assertEqual(x[:], a.tolist())
- self.assert_(a in x._objects.values())
+ self.assertTrue(a in x._objects.values())
self.assertRaises(ValueError,
c_int.from_buffer, a, -1)
@@ -49,7 +49,7 @@
y = X.from_buffer_copy(a)
self.assertEqual(y.c_int, a[0])
- self.failIf(y.init_called)
+ self.assertFalse(y.init_called)
self.assertEqual(x[:], list(range(16)))
Modified: python/branches/py3k/Lib/ctypes/test/test_funcptr.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_funcptr.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_funcptr.py Wed Jul 1 01:06:06 2009
@@ -18,10 +18,10 @@
return len(args)
x = X(func)
- self.failUnlessEqual(x.restype, c_int)
- self.failUnlessEqual(x.argtypes, (c_int, c_int))
- self.failUnlessEqual(sizeof(x), sizeof(c_voidp))
- self.failUnlessEqual(sizeof(X), sizeof(c_voidp))
+ self.assertEqual(x.restype, c_int)
+ self.assertEqual(x.argtypes, (c_int, c_int))
+ self.assertEqual(sizeof(x), sizeof(c_voidp))
+ self.assertEqual(sizeof(X), sizeof(c_voidp))
def test_first(self):
StdCallback = WINFUNCTYPE(c_int, c_int, c_int)
@@ -33,12 +33,12 @@
s = StdCallback(func)
c = CdeclCallback(func)
- self.failUnlessEqual(s(1, 2), 3)
- self.failUnlessEqual(c(1, 2), 3)
+ self.assertEqual(s(1, 2), 3)
+ self.assertEqual(c(1, 2), 3)
# The following no longer raises a TypeError - it is now
# possible, as in C, to call cdecl functions with more parameters.
#self.assertRaises(TypeError, c, 1, 2, 3)
- self.failUnlessEqual(c(1, 2, 3, 4, 5, 6), 3)
+ self.assertEqual(c(1, 2, 3, 4, 5, 6), 3)
if not WINFUNCTYPE is CFUNCTYPE and os.name != "ce":
self.assertRaises(TypeError, s, 1, 2, 3)
@@ -75,9 +75,9 @@
## "lpfnWndProc", WNDPROC_2(wndproc))
# instead:
- self.failUnless(WNDPROC is WNDPROC_2)
+ self.assertTrue(WNDPROC is WNDPROC_2)
# 'wndclass.lpfnWndProc' leaks 94 references. Why?
- self.failUnlessEqual(wndclass.lpfnWndProc(1, 2, 3, 4), 10)
+ self.assertEqual(wndclass.lpfnWndProc(1, 2, 3, 4), 10)
f = wndclass.lpfnWndProc
@@ -85,7 +85,7 @@
del wndclass
del wndproc
- self.failUnlessEqual(f(10, 11, 12, 13), 46)
+ self.assertEqual(f(10, 11, 12, 13), 46)
def test_dllfunctions(self):
@@ -97,8 +97,8 @@
strchr = lib.my_strchr
strchr.restype = c_char_p
strchr.argtypes = (c_char_p, c_char)
- self.failUnlessEqual(strchr("abcdefghi", "b"), "bcdefghi")
- self.failUnlessEqual(strchr("abcdefghi", "x"), None)
+ self.assertEqual(strchr("abcdefghi", "b"), "bcdefghi")
+ self.assertEqual(strchr("abcdefghi", "x"), None)
strtok = lib.my_strtok
@@ -118,10 +118,10 @@
## b.value = s
## b = c_string(s)
- self.failUnlessEqual(strtok(b, b"\n"), "a")
- self.failUnlessEqual(strtok(None, b"\n"), "b")
- self.failUnlessEqual(strtok(None, b"\n"), "c")
- self.failUnlessEqual(strtok(None, b"\n"), None)
+ self.assertEqual(strtok(b, b"\n"), "a")
+ self.assertEqual(strtok(None, b"\n"), "b")
+ self.assertEqual(strtok(None, b"\n"), "c")
+ self.assertEqual(strtok(None, b"\n"), None)
if __name__ == '__main__':
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_functions.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_functions.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_functions.py Wed Jul 1 01:06:06 2009
@@ -71,8 +71,8 @@
f = dll._testfunc_i_bhilfd
f.argtypes = [c_byte, c_wchar, c_int, c_long, c_float, c_double]
result = f(1, "x", 3, 4, 5.0, 6.0)
- self.failUnlessEqual(result, 139)
- self.failUnlessEqual(type(result), int)
+ self.assertEqual(result, 139)
+ self.assertEqual(type(result), int)
def test_wchar_result(self):
try:
@@ -83,38 +83,38 @@
f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double]
f.restype = c_wchar
result = f(0, 0, 0, 0, 0, 0)
- self.failUnlessEqual(result, '\x00')
+ self.assertEqual(result, '\x00')
def test_voidresult(self):
f = dll._testfunc_v
f.restype = None
f.argtypes = [c_int, c_int, POINTER(c_int)]
result = c_int()
- self.failUnlessEqual(None, f(1, 2, byref(result)))
- self.failUnlessEqual(result.value, 3)
+ self.assertEqual(None, f(1, 2, byref(result)))
+ self.assertEqual(result.value, 3)
def test_intresult(self):
f = dll._testfunc_i_bhilfd
f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double]
f.restype = c_int
result = f(1, 2, 3, 4, 5.0, 6.0)
- self.failUnlessEqual(result, 21)
- self.failUnlessEqual(type(result), int)
+ self.assertEqual(result, 21)
+ self.assertEqual(type(result), int)
result = f(-1, -2, -3, -4, -5.0, -6.0)
- self.failUnlessEqual(result, -21)
- self.failUnlessEqual(type(result), int)
+ self.assertEqual(result, -21)
+ self.assertEqual(type(result), int)
# If we declare the function to return a short,
# is the high part split off?
f.restype = c_short
result = f(1, 2, 3, 4, 5.0, 6.0)
- self.failUnlessEqual(result, 21)
- self.failUnlessEqual(type(result), int)
+ self.assertEqual(result, 21)
+ self.assertEqual(type(result), int)
result = f(1, 2, 3, 0x10004, 5.0, 6.0)
- self.failUnlessEqual(result, 21)
- self.failUnlessEqual(type(result), int)
+ self.assertEqual(result, 21)
+ self.assertEqual(type(result), int)
# You cannot assing character format codes as restype any longer
self.assertRaises(TypeError, setattr, f, "restype", "i")
@@ -124,36 +124,36 @@
f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double]
f.restype = c_float
result = f(1, 2, 3, 4, 5.0, 6.0)
- self.failUnlessEqual(result, 21)
- self.failUnlessEqual(type(result), float)
+ self.assertEqual(result, 21)
+ self.assertEqual(type(result), float)
result = f(-1, -2, -3, -4, -5.0, -6.0)
- self.failUnlessEqual(result, -21)
- self.failUnlessEqual(type(result), float)
+ self.assertEqual(result, -21)
+ self.assertEqual(type(result), float)
def test_doubleresult(self):
f = dll._testfunc_d_bhilfd
f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double]
f.restype = c_double
result = f(1, 2, 3, 4, 5.0, 6.0)
- self.failUnlessEqual(result, 21)
- self.failUnlessEqual(type(result), float)
+ self.assertEqual(result, 21)
+ self.assertEqual(type(result), float)
result = f(-1, -2, -3, -4, -5.0, -6.0)
- self.failUnlessEqual(result, -21)
- self.failUnlessEqual(type(result), float)
+ self.assertEqual(result, -21)
+ self.assertEqual(type(result), float)
def test_longdoubleresult(self):
f = dll._testfunc_D_bhilfD
f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_longdouble]
f.restype = c_longdouble
result = f(1, 2, 3, 4, 5.0, 6.0)
- self.failUnlessEqual(result, 21)
- self.failUnlessEqual(type(result), float)
+ self.assertEqual(result, 21)
+ self.assertEqual(type(result), float)
result = f(-1, -2, -3, -4, -5.0, -6.0)
- self.failUnlessEqual(result, -21)
- self.failUnlessEqual(type(result), float)
+ self.assertEqual(result, -21)
+ self.assertEqual(type(result), float)
def test_longlongresult(self):
try:
@@ -164,23 +164,23 @@
f.restype = c_longlong
f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double]
result = f(1, 2, 3, 4, 5.0, 6.0)
- self.failUnlessEqual(result, 21)
+ self.assertEqual(result, 21)
f = dll._testfunc_q_bhilfdq
f.restype = c_longlong
f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double, c_longlong]
result = f(1, 2, 3, 4, 5.0, 6.0, 21)
- self.failUnlessEqual(result, 42)
+ self.assertEqual(result, 42)
def test_stringresult(self):
f = dll._testfunc_p_p
f.argtypes = None
f.restype = c_char_p
result = f(b"123")
- self.failUnlessEqual(result, "123")
+ self.assertEqual(result, "123")
result = f(None)
- self.failUnlessEqual(result, None)
+ self.assertEqual(result, None)
def test_pointers(self):
f = dll._testfunc_p_p
@@ -193,29 +193,29 @@
v = c_int(42)
- self.failUnlessEqual(pointer(v).contents.value, 42)
+ self.assertEqual(pointer(v).contents.value, 42)
result = f(pointer(v))
- self.failUnlessEqual(type(result), POINTER(c_int))
- self.failUnlessEqual(result.contents.value, 42)
+ self.assertEqual(type(result), POINTER(c_int))
+ self.assertEqual(result.contents.value, 42)
# This on works...
result = f(pointer(v))
- self.failUnlessEqual(result.contents.value, v.value)
+ self.assertEqual(result.contents.value, v.value)
p = pointer(c_int(99))
result = f(p)
- self.failUnlessEqual(result.contents.value, 99)
+ self.assertEqual(result.contents.value, 99)
arg = byref(v)
result = f(arg)
- self.failIfEqual(result.contents, v.value)
+ self.assertNotEqual(result.contents, v.value)
self.assertRaises(ArgumentError, f, byref(c_short(22)))
# It is dangerous, however, because you don't control the lifetime
# of the pointer:
result = f(byref(c_int(99)))
- self.failIfEqual(result.contents, 99)
+ self.assertNotEqual(result.contents, 99)
def test_errors(self):
f = dll._testfunc_p_p
@@ -242,7 +242,7 @@
cb = CallBack(callback)
f(2**18, cb)
- self.failUnlessEqual(args, expected)
+ self.assertEqual(args, expected)
################################################################
@@ -259,13 +259,13 @@
cb = MyCallback(callback)
result = f(-10, cb)
- self.failUnlessEqual(result, -18)
+ self.assertEqual(result, -18)
# test with prototype
f.argtypes = [c_int, MyCallback]
cb = MyCallback(callback)
result = f(-10, cb)
- self.failUnlessEqual(result, -18)
+ self.assertEqual(result, -18)
AnotherCallback = WINFUNCTYPE(c_int, c_int, c_int, c_int, c_int)
@@ -288,12 +288,12 @@
def callback(value):
#print "called back with", value
- self.failUnlessEqual(type(value), int)
+ self.assertEqual(type(value), int)
return value
cb = MyCallback(callback)
result = f(-10, cb)
- self.failUnlessEqual(result, -18)
+ self.assertEqual(result, -18)
def test_longlong_callbacks(self):
@@ -305,12 +305,12 @@
f.argtypes = [c_longlong, MyCallback]
def callback(value):
- self.failUnless(isinstance(value, int))
+ self.assertTrue(isinstance(value, int))
return value & 0x7FFFFFFF
cb = MyCallback(callback)
- self.failUnlessEqual(13577625587, f(1000000000000, cb))
+ self.assertEqual(13577625587, f(1000000000000, cb))
def test_errors(self):
self.assertRaises(AttributeError, getattr, dll, "_xxx_yyy")
@@ -325,7 +325,7 @@
result = dll._testfunc_byval(ptin, byref(ptout))
got = result, ptout.x, ptout.y
expected = 3, 1, 2
- self.failUnlessEqual(got, expected)
+ self.assertEqual(got, expected)
# with prototype
ptin = POINT(101, 102)
@@ -335,7 +335,7 @@
result = dll._testfunc_byval(ptin, byref(ptout))
got = result, ptout.x, ptout.y
expected = 203, 101, 102
- self.failUnlessEqual(got, expected)
+ self.assertEqual(got, expected)
def test_struct_return_2H(self):
class S2H(Structure):
@@ -345,7 +345,7 @@
dll.ret_2h_func.argtypes = [S2H]
inp = S2H(99, 88)
s2h = dll.ret_2h_func(inp)
- self.failUnlessEqual((s2h.x, s2h.y), (99*2, 88*3))
+ self.assertEqual((s2h.x, s2h.y), (99*2, 88*3))
if sys.platform == "win32":
def test_struct_return_2H_stdcall(self):
@@ -356,7 +356,7 @@
windll.s_ret_2h_func.restype = S2H
windll.s_ret_2h_func.argtypes = [S2H]
s2h = windll.s_ret_2h_func(S2H(99, 88))
- self.failUnlessEqual((s2h.x, s2h.y), (99*2, 88*3))
+ self.assertEqual((s2h.x, s2h.y), (99*2, 88*3))
def test_struct_return_8H(self):
class S8I(Structure):
@@ -372,7 +372,7 @@
dll.ret_8i_func.argtypes = [S8I]
inp = S8I(9, 8, 7, 6, 5, 4, 3, 2)
s8i = dll.ret_8i_func(inp)
- self.failUnlessEqual((s8i.a, s8i.b, s8i.c, s8i.d, s8i.e, s8i.f, s8i.g, s8i.h),
+ self.assertEqual((s8i.a, s8i.b, s8i.c, s8i.d, s8i.e, s8i.f, s8i.g, s8i.h),
(9*2, 8*3, 7*4, 6*5, 5*6, 4*7, 3*8, 2*9))
if sys.platform == "win32":
@@ -390,7 +390,7 @@
windll.s_ret_8i_func.argtypes = [S8I]
inp = S8I(9, 8, 7, 6, 5, 4, 3, 2)
s8i = windll.s_ret_8i_func(inp)
- self.failUnlessEqual((s8i.a, s8i.b, s8i.c, s8i.d, s8i.e, s8i.f, s8i.g, s8i.h),
+ self.assertEqual((s8i.a, s8i.b, s8i.c, s8i.d, s8i.e, s8i.f, s8i.g, s8i.h),
(9*2, 8*3, 7*4, 6*5, 5*6, 4*7, 3*8, 2*9))
def test_sf1651235(self):
@@ -401,7 +401,7 @@
return 0
callback = proto(callback)
- self.failUnlessRaises(ArgumentError, lambda: callback((1, 2, 3, 4), POINT()))
+ self.assertRaises(ArgumentError, lambda: callback((1, 2, 3, 4), POINT()))
if __name__ == '__main__':
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_incomplete.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_incomplete.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_incomplete.py Wed Jul 1 01:06:06 2009
@@ -30,7 +30,7 @@
for i in range(8):
result.append(p.name)
p = p.next[0]
- self.failUnlessEqual(result, ["foo", "bar"] * 4)
+ self.assertEqual(result, ["foo", "bar"] * 4)
# to not leak references, we must clean _pointer_type_cache
from ctypes import _pointer_type_cache
Modified: python/branches/py3k/Lib/ctypes/test/test_init.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_init.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_init.py Wed Jul 1 01:06:06 2009
@@ -24,17 +24,17 @@
# make sure the only accessing a nested structure
# doesn't call the structure's __new__ and __init__
y = Y()
- self.failUnlessEqual((y.x.a, y.x.b), (0, 0))
- self.failUnlessEqual(y.x.new_was_called, False)
+ self.assertEqual((y.x.a, y.x.b), (0, 0))
+ self.assertEqual(y.x.new_was_called, False)
# But explicitely creating an X structure calls __new__ and __init__, of course.
x = X()
- self.failUnlessEqual((x.a, x.b), (9, 12))
- self.failUnlessEqual(x.new_was_called, True)
+ self.assertEqual((x.a, x.b), (9, 12))
+ self.assertEqual(x.new_was_called, True)
y.x = x
- self.failUnlessEqual((y.x.a, y.x.b), (9, 12))
- self.failUnlessEqual(y.x.new_was_called, False)
+ self.assertEqual((y.x.a, y.x.b), (9, 12))
+ self.assertEqual(y.x.new_was_called, False)
if __name__ == "__main__":
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_internals.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_internals.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_internals.py Wed Jul 1 01:06:06 2009
@@ -18,22 +18,22 @@
"""
class ObjectsTestCase(unittest.TestCase):
- def failUnlessSame(self, a, b):
- self.failUnlessEqual(id(a), id(b))
+ def assertTrueSame(self, a, b):
+ self.assertEqual(id(a), id(b))
def test_ints(self):
i = 42000123
rc = grc(i)
ci = c_int(i)
- self.failUnlessEqual(rc, grc(i))
- self.failUnlessEqual(ci._objects, None)
+ self.assertEqual(rc, grc(i))
+ self.assertEqual(ci._objects, None)
def test_c_char_p(self):
s = b"Hello, World"
rc = grc(s)
cs = c_char_p(s)
- self.failUnlessEqual(rc + 1, grc(s))
- self.failUnlessSame(cs._objects, s)
+ self.assertEqual(rc + 1, grc(s))
+ self.assertTrueSame(cs._objects, s)
def test_simple_struct(self):
class X(Structure):
@@ -42,10 +42,10 @@
a = 421234
b = 421235
x = X()
- self.failUnlessEqual(x._objects, None)
+ self.assertEqual(x._objects, None)
x.a = a
x.b = b
- self.failUnlessEqual(x._objects, None)
+ self.assertEqual(x._objects, None)
def test_embedded_structs(self):
class X(Structure):
@@ -55,13 +55,13 @@
_fields_ = [("x", X), ("y", X)]
y = Y()
- self.failUnlessEqual(y._objects, None)
+ self.assertEqual(y._objects, None)
x1, x2 = X(), X()
y.x, y.y = x1, x2
- self.failUnlessEqual(y._objects, {"0": {}, "1": {}})
+ self.assertEqual(y._objects, {"0": {}, "1": {}})
x1.a, x2.b = 42, 93
- self.failUnlessEqual(y._objects, {"0": {}, "1": {}})
+ self.assertEqual(y._objects, {"0": {}, "1": {}})
def test_xxx(self):
class X(Structure):
@@ -76,12 +76,12 @@
x = X()
x.a = s1
x.b = s2
- self.failUnlessEqual(x._objects, {"0": bytes(s1, "ascii"),
+ self.assertEqual(x._objects, {"0": bytes(s1, "ascii"),
"1": bytes(s2, "ascii")})
y = Y()
y.x = x
- self.failUnlessEqual(y._objects, {"0": {"0": bytes(s1, "ascii"),
+ self.assertEqual(y._objects, {"0": {"0": bytes(s1, "ascii"),
"1": bytes(s2, "ascii")}})
## x = y.x
## del y
@@ -93,7 +93,7 @@
A = c_int*4
a = A(11, 22, 33, 44)
- self.failUnlessEqual(a._objects, None)
+ self.assertEqual(a._objects, None)
x = X()
x.data = a
Modified: python/branches/py3k/Lib/ctypes/test/test_keeprefs.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_keeprefs.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_keeprefs.py Wed Jul 1 01:06:06 2009
@@ -91,7 +91,7 @@
def test_p_cint(self):
i = c_int(42)
x = pointer(i)
- self.failUnlessEqual(x._objects, {'1': i})
+ self.assertEqual(x._objects, {'1': i})
class DeletePointerTestCase(unittest.TestCase):
def X_test(self):
Modified: python/branches/py3k/Lib/ctypes/test/test_libc.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_libc.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_libc.py Wed Jul 1 01:06:06 2009
@@ -13,9 +13,9 @@
def test_sqrt(self):
lib.my_sqrt.argtypes = c_double,
lib.my_sqrt.restype = c_double
- self.failUnlessEqual(lib.my_sqrt(4.0), 2.0)
+ self.assertEqual(lib.my_sqrt(4.0), 2.0)
import math
- self.failUnlessEqual(lib.my_sqrt(2.0), math.sqrt(2.0))
+ self.assertEqual(lib.my_sqrt(2.0), math.sqrt(2.0))
def test_qsort(self):
comparefunc = CFUNCTYPE(c_int, POINTER(c_char), POINTER(c_char))
@@ -27,7 +27,7 @@
chars = create_string_buffer("spam, spam, and spam")
lib.my_qsort(chars, len(chars)-1, sizeof(c_char), comparefunc(sort))
- self.failUnlessEqual(chars.raw, b" ,,aaaadmmmnpppsss\x00")
+ self.assertEqual(chars.raw, b" ,,aaaadmmmnpppsss\x00")
if __name__ == "__main__":
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_loading.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_loading.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_loading.py Wed Jul 1 01:06:06 2009
@@ -43,7 +43,7 @@
if os.name in ("nt", "ce"):
def test_load_library(self):
- self.failIf(libc_name is None)
+ self.assertFalse(libc_name is None)
if is_resource_enabled("printing"):
print(find_library("kernel32"))
print(find_library("user32"))
@@ -70,9 +70,9 @@
a_name = addressof(func_name)
f_ord_addr = c_void_p.from_address(a_ord).value
f_name_addr = c_void_p.from_address(a_name).value
- self.failUnlessEqual(hex(f_ord_addr), hex(f_name_addr))
+ self.assertEqual(hex(f_ord_addr), hex(f_name_addr))
- self.failUnlessRaises(AttributeError, dll.__getitem__, 1234)
+ self.assertRaises(AttributeError, dll.__getitem__, 1234)
if os.name == "nt":
def test_1703286_A(self):
@@ -94,13 +94,13 @@
advapi32 = windll.advapi32
# Calling CloseEventLog with a NULL argument should fail,
# but the call should not segfault or so.
- self.failUnlessEqual(0, advapi32.CloseEventLog(None))
+ self.assertEqual(0, advapi32.CloseEventLog(None))
windll.kernel32.GetProcAddress.argtypes = c_void_p, c_char_p
windll.kernel32.GetProcAddress.restype = c_void_p
proc = windll.kernel32.GetProcAddress(advapi32._handle, "CloseEventLog")
- self.failUnless(proc)
+ self.assertTrue(proc)
# This is the real test: call the function via 'call_function'
- self.failUnlessEqual(0, call_function(proc, (None,)))
+ self.assertEqual(0, call_function(proc, (None,)))
if __name__ == "__main__":
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_macholib.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_macholib.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_macholib.py Wed Jul 1 01:06:06 2009
@@ -48,14 +48,14 @@
if sys.platform == "darwin":
def test_find(self):
- self.failUnlessEqual(find_lib('pthread'),
+ self.assertEqual(find_lib('pthread'),
'/usr/lib/libSystem.B.dylib')
result = find_lib('z')
- self.failUnless(result.startswith('/usr/lib/libz.1'))
- self.failUnless(result.endswith('.dylib'))
+ self.assertTrue(result.startswith('/usr/lib/libz.1'))
+ self.assertTrue(result.endswith('.dylib'))
- self.failUnlessEqual(find_lib('IOKit'),
+ self.assertEqual(find_lib('IOKit'),
'/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit')
if __name__ == "__main__":
Modified: python/branches/py3k/Lib/ctypes/test/test_memfunctions.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_memfunctions.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_memfunctions.py Wed Jul 1 01:06:06 2009
@@ -19,45 +19,45 @@
a = create_string_buffer(1000000)
p = b"Hello, World"
result = memmove(a, p, len(p))
- self.failUnlessEqual(a.value, b"Hello, World")
+ self.assertEqual(a.value, b"Hello, World")
- self.failUnlessEqual(string_at(result), b"Hello, World")
- self.failUnlessEqual(string_at(result, 5), b"Hello")
- self.failUnlessEqual(string_at(result, 16), b"Hello, World\0\0\0\0")
- self.failUnlessEqual(string_at(result, 0), b"")
+ self.assertEqual(string_at(result), b"Hello, World")
+ self.assertEqual(string_at(result, 5), b"Hello")
+ self.assertEqual(string_at(result, 16), b"Hello, World\0\0\0\0")
+ self.assertEqual(string_at(result, 0), b"")
def test_memset(self):
a = create_string_buffer(1000000)
result = memset(a, ord('x'), 16)
- self.failUnlessEqual(a.value, b"xxxxxxxxxxxxxxxx")
+ self.assertEqual(a.value, b"xxxxxxxxxxxxxxxx")
- self.failUnlessEqual(string_at(result), b"xxxxxxxxxxxxxxxx")
- self.failUnlessEqual(string_at(a), b"xxxxxxxxxxxxxxxx")
- self.failUnlessEqual(string_at(a, 20), b"xxxxxxxxxxxxxxxx\0\0\0\0")
+ self.assertEqual(string_at(result), b"xxxxxxxxxxxxxxxx")
+ self.assertEqual(string_at(a), b"xxxxxxxxxxxxxxxx")
+ self.assertEqual(string_at(a, 20), b"xxxxxxxxxxxxxxxx\0\0\0\0")
def test_cast(self):
a = (c_ubyte * 32)(*map(ord, "abcdef"))
- self.failUnlessEqual(cast(a, c_char_p).value, "abcdef")
- self.failUnlessEqual(cast(a, POINTER(c_byte))[:7],
+ self.assertEqual(cast(a, c_char_p).value, "abcdef")
+ self.assertEqual(cast(a, POINTER(c_byte))[:7],
[97, 98, 99, 100, 101, 102, 0])
- self.failUnlessEqual(cast(a, POINTER(c_byte))[:7:],
+ self.assertEqual(cast(a, POINTER(c_byte))[:7:],
[97, 98, 99, 100, 101, 102, 0])
- self.failUnlessEqual(cast(a, POINTER(c_byte))[6:-1:-1],
+ self.assertEqual(cast(a, POINTER(c_byte))[6:-1:-1],
[0, 102, 101, 100, 99, 98, 97])
- self.failUnlessEqual(cast(a, POINTER(c_byte))[:7:2],
+ self.assertEqual(cast(a, POINTER(c_byte))[:7:2],
[97, 99, 101, 0])
- self.failUnlessEqual(cast(a, POINTER(c_byte))[:7:7],
+ self.assertEqual(cast(a, POINTER(c_byte))[:7:7],
[97])
def test_string_at(self):
s = string_at(b"foo bar")
# XXX The following may be wrong, depending on how Python
# manages string instances
- self.failUnlessEqual(2, sys.getrefcount(s))
- self.failUnless(s, "foo bar")
+ self.assertEqual(2, sys.getrefcount(s))
+ self.assertTrue(s, "foo bar")
- self.failUnlessEqual(string_at(b"foo bar", 7), b"foo bar")
- self.failUnlessEqual(string_at(b"foo bar", 3), b"foo")
+ self.assertEqual(string_at(b"foo bar", 7), b"foo bar")
+ self.assertEqual(string_at(b"foo bar", 3), b"foo")
try:
create_unicode_buffer
@@ -68,12 +68,12 @@
p = create_unicode_buffer("Hello, World")
a = create_unicode_buffer(1000000)
result = memmove(a, p, len(p) * sizeof(c_wchar))
- self.failUnlessEqual(a.value, "Hello, World")
+ self.assertEqual(a.value, "Hello, World")
- self.failUnlessEqual(wstring_at(a), "Hello, World")
- self.failUnlessEqual(wstring_at(a, 5), "Hello")
- self.failUnlessEqual(wstring_at(a, 16), "Hello, World\0\0\0\0")
- self.failUnlessEqual(wstring_at(a, 0), "")
+ self.assertEqual(wstring_at(a), "Hello, World")
+ self.assertEqual(wstring_at(a, 5), "Hello")
+ self.assertEqual(wstring_at(a, 16), "Hello, World\0\0\0\0")
+ self.assertEqual(wstring_at(a, 0), "")
if __name__ == "__main__":
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_numbers.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_numbers.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_numbers.py Wed Jul 1 01:06:06 2009
@@ -55,25 +55,25 @@
def test_default_init(self):
# default values are set to zero
for t in signed_types + unsigned_types + float_types:
- self.failUnlessEqual(t().value, 0)
+ self.assertEqual(t().value, 0)
def test_unsigned_values(self):
# the value given to the constructor is available
# as the 'value' attribute
for t, (l, h) in zip(unsigned_types, unsigned_ranges):
- self.failUnlessEqual(t(l).value, l)
- self.failUnlessEqual(t(h).value, h)
+ self.assertEqual(t(l).value, l)
+ self.assertEqual(t(h).value, h)
def test_signed_values(self):
# see above
for t, (l, h) in zip(signed_types, signed_ranges):
- self.failUnlessEqual(t(l).value, l)
- self.failUnlessEqual(t(h).value, h)
+ self.assertEqual(t(l).value, l)
+ self.assertEqual(t(h).value, h)
def test_bool_values(self):
from operator import truth
for t, v in zip(bool_types, bool_values):
- self.failUnlessEqual(t(v).value, truth(v))
+ self.assertEqual(t(v).value, truth(v))
def test_typeerror(self):
# Only numbers are allowed in the contructor,
@@ -93,13 +93,13 @@
# the from_param class method attribute always
# returns PyCArgObject instances
for t in signed_types + unsigned_types + float_types:
- self.failUnlessEqual(ArgType, type(t.from_param(0)))
+ self.assertEqual(ArgType, type(t.from_param(0)))
def test_byref(self):
# calling byref returns also a PyCArgObject instance
for t in signed_types + unsigned_types + float_types + bool_types:
parm = byref(t())
- self.failUnlessEqual(ArgType, type(parm))
+ self.assertEqual(ArgType, type(parm))
def test_floats(self):
@@ -110,10 +110,10 @@
return 2.0
f = FloatLike()
for t in float_types:
- self.failUnlessEqual(t(2.0).value, 2.0)
- self.failUnlessEqual(t(2).value, 2.0)
- self.failUnlessEqual(t(2).value, 2.0)
- self.failUnlessEqual(t(f).value, 2.0)
+ self.assertEqual(t(2.0).value, 2.0)
+ self.assertEqual(t(2).value, 2.0)
+ self.assertEqual(t(2).value, 2.0)
+ self.assertEqual(t(f).value, 2.0)
def test_integers(self):
class FloatLike(object):
@@ -129,7 +129,7 @@
for t in signed_types + unsigned_types:
self.assertRaises(TypeError, t, 3.14)
self.assertRaises(TypeError, t, f)
- self.failUnlessEqual(t(i).value, 2)
+ self.assertEqual(t(i).value, 2)
def test_sizes(self):
for t in signed_types + unsigned_types + float_types + bool_types:
@@ -138,9 +138,9 @@
except struct.error:
continue
# sizeof of the type...
- self.failUnlessEqual(sizeof(t), size)
+ self.assertEqual(sizeof(t), size)
# and sizeof of an instance
- self.failUnlessEqual(sizeof(t()), size)
+ self.assertEqual(sizeof(t()), size)
def test_alignments(self):
for t in signed_types + unsigned_types + float_types:
@@ -148,10 +148,10 @@
align = struct.calcsize("c%c" % code) - struct.calcsize(code)
# alignment of the type...
- self.failUnlessEqual((code, alignment(t)),
+ self.assertEqual((code, alignment(t)),
(code, align))
# and alignment of an instance
- self.failUnlessEqual((code, alignment(t())),
+ self.assertEqual((code, alignment(t())),
(code, align))
def test_int_from_address(self):
@@ -167,12 +167,12 @@
# v now is an integer at an 'external' memory location
v = t.from_address(a.buffer_info()[0])
- self.failUnlessEqual(v.value, a[0])
- self.failUnlessEqual(type(v), t)
+ self.assertEqual(v.value, a[0])
+ self.assertEqual(type(v), t)
# changing the value at the memory location changes v's value also
a[0] = 42
- self.failUnlessEqual(v.value, a[0])
+ self.assertEqual(v.value, a[0])
def test_float_from_address(self):
@@ -180,11 +180,11 @@
for t in float_types:
a = array(t._type_, [3.14])
v = t.from_address(a.buffer_info()[0])
- self.failUnlessEqual(v.value, a[0])
- self.failUnless(type(v) is t)
+ self.assertEqual(v.value, a[0])
+ self.assertTrue(type(v) is t)
a[0] = 2.3456e17
- self.failUnlessEqual(v.value, a[0])
- self.failUnless(type(v) is t)
+ self.assertEqual(v.value, a[0])
+ self.assertTrue(type(v) is t)
def test_char_from_address(self):
from ctypes import c_char
@@ -193,11 +193,11 @@
a = array('b', [0])
a[0] = ord('x')
v = c_char.from_address(a.buffer_info()[0])
- self.failUnlessEqual(v.value, b'x')
- self.failUnless(type(v) is c_char)
+ self.assertEqual(v.value, b'x')
+ self.assertTrue(type(v) is c_char)
a[0] = ord('?')
- self.failUnlessEqual(v.value, b'?')
+ self.assertEqual(v.value, b'?')
# array does not support c_bool / 't'
# def test_bool_from_address(self):
@@ -205,11 +205,11 @@
# from array import array
# a = array(c_bool._type_, [True])
# v = t.from_address(a.buffer_info()[0])
- # self.failUnlessEqual(v.value, a[0])
- # self.failUnlessEqual(type(v) is t)
+ # self.assertEqual(v.value, a[0])
+ # self.assertEqual(type(v) is t)
# a[0] = False
- # self.failUnlessEqual(v.value, a[0])
- # self.failUnlessEqual(type(v) is t)
+ # self.assertEqual(v.value, a[0])
+ # self.assertEqual(type(v) is t)
def test_init(self):
# c_int() can be initialized from Python's int, and c_int.
Modified: python/branches/py3k/Lib/ctypes/test/test_parameters.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_parameters.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_parameters.py Wed Jul 1 01:06:06 2009
@@ -33,8 +33,8 @@
return value * 4
from_param = classmethod(from_param)
- self.failUnlessEqual(CVOIDP.from_param("abc"), "abcabc")
- self.failUnlessEqual(CCHARP.from_param("abc"), "abcabcabcabc")
+ self.assertEqual(CVOIDP.from_param("abc"), "abcabc")
+ self.assertEqual(CCHARP.from_param("abc"), "abcabcabcabc")
try:
from ctypes import c_wchar_p
@@ -46,7 +46,7 @@
return value * 3
from_param = classmethod(from_param)
- self.failUnlessEqual(CWCHARP.from_param("abc"), "abcabcabc")
+ self.assertEqual(CWCHARP.from_param("abc"), "abcabcabc")
# XXX Replace by c_char_p tests
def test_cstrings(self):
@@ -55,10 +55,10 @@
# c_char_p.from_param on a Python String packs the string
# into a cparam object
s = b"123"
- self.failUnless(c_char_p.from_param(s)._obj is s)
+ self.assertTrue(c_char_p.from_param(s)._obj is s)
# new in 0.9.1: convert (encode) unicode to ascii
- self.failUnlessEqual(c_char_p.from_param("123")._obj, b"123")
+ self.assertEqual(c_char_p.from_param("123")._obj, b"123")
self.assertRaises(UnicodeEncodeError, c_char_p.from_param, "123\377")
self.assertRaises(TypeError, c_char_p.from_param, 42)
@@ -66,7 +66,7 @@
# calling c_char_p.from_param with a c_char_p instance
# returns the argument itself:
a = c_char_p("123")
- self.failUnless(c_char_p.from_param(a) is a)
+ self.assertTrue(c_char_p.from_param(a) is a)
def test_cw_strings(self):
from ctypes import byref
@@ -77,15 +77,15 @@
return
s = "123"
if sys.platform == "win32":
- self.failUnless(c_wchar_p.from_param(s)._obj is s)
+ self.assertTrue(c_wchar_p.from_param(s)._obj is s)
self.assertRaises(TypeError, c_wchar_p.from_param, 42)
# new in 0.9.1: convert (decode) ascii to unicode
- self.failUnlessEqual(c_wchar_p.from_param("123")._obj, "123")
+ self.assertEqual(c_wchar_p.from_param("123")._obj, "123")
self.assertRaises(UnicodeDecodeError, c_wchar_p.from_param, b"123\377")
pa = c_wchar_p.from_param(c_wchar_p("123"))
- self.failUnlessEqual(type(pa), c_wchar_p)
+ self.assertEqual(type(pa), c_wchar_p)
def test_int_pointers(self):
from ctypes import c_short, c_uint, c_int, c_long, POINTER, pointer
@@ -94,10 +94,10 @@
## p = pointer(c_int(42))
## x = LPINT.from_param(p)
x = LPINT.from_param(pointer(c_int(42)))
- self.failUnlessEqual(x.contents.value, 42)
- self.failUnlessEqual(LPINT(c_int(42)).contents.value, 42)
+ self.assertEqual(x.contents.value, 42)
+ self.assertEqual(LPINT(c_int(42)).contents.value, 42)
- self.failUnlessEqual(LPINT.from_param(None), 0)
+ self.assertEqual(LPINT.from_param(None), 0)
if c_int != c_long:
self.assertRaises(TypeError, LPINT.from_param, pointer(c_long(42)))
@@ -133,8 +133,8 @@
from ctypes import c_short, c_uint, c_int, c_long, POINTER
INTARRAY = c_int * 3
ia = INTARRAY()
- self.failUnlessEqual(len(ia), 3)
- self.failUnlessEqual([ia[i] for i in range(3)], [0, 0, 0])
+ self.assertEqual(len(ia), 3)
+ self.assertEqual([ia[i] for i in range(3)], [0, 0, 0])
# Pointers are only compatible with arrays containing items of
# the same type!
@@ -161,8 +161,8 @@
return None
func.argtypes = (Adapter(),)
- self.failUnlessEqual(func(None), None)
- self.failUnlessEqual(func(object()), None)
+ self.assertEqual(func(None), None)
+ self.assertEqual(func(object()), None)
class Adapter(object):
def from_param(cls, obj):
@@ -171,7 +171,7 @@
func.argtypes = (Adapter(),)
# don't know how to convert parameter 1
self.assertRaises(ArgumentError, func, object())
- self.failUnlessEqual(func(c_void_p(42)), 42)
+ self.assertEqual(func(c_void_p(42)), 42)
class Adapter(object):
def from_param(cls, obj):
Modified: python/branches/py3k/Lib/ctypes/test/test_pep3118.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_pep3118.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_pep3118.py Wed Jul 1 01:06:06 2009
@@ -24,23 +24,23 @@
ob = tp()
v = memoryview(ob)
try:
- self.failUnlessEqual(normalize(v.format), normalize(fmt))
+ self.assertEqual(normalize(v.format), normalize(fmt))
if shape is not None:
- self.failUnlessEqual(len(v), shape[0])
+ self.assertEqual(len(v), shape[0])
else:
- self.failUnlessEqual(len(v) * sizeof(itemtp), sizeof(ob))
- self.failUnlessEqual(v.itemsize, sizeof(itemtp))
- self.failUnlessEqual(v.shape, shape)
+ self.assertEqual(len(v) * sizeof(itemtp), sizeof(ob))
+ self.assertEqual(v.itemsize, sizeof(itemtp))
+ self.assertEqual(v.shape, shape)
# ctypes object always have a non-strided memory block
- self.failUnlessEqual(v.strides, None)
+ self.assertEqual(v.strides, None)
# they are always read/write
- self.failIf(v.readonly)
+ self.assertFalse(v.readonly)
if v.shape:
n = 1
for dim in v.shape:
n = n * dim
- self.failUnlessEqual(n * v.itemsize, len(v.tobytes()))
+ self.assertEqual(n * v.itemsize, len(v.tobytes()))
except:
# so that we can see the failing type
print(tp)
@@ -51,23 +51,23 @@
ob = tp()
v = memoryview(ob)
try:
- self.failUnlessEqual(v.format, fmt)
+ self.assertEqual(v.format, fmt)
if shape is not None:
- self.failUnlessEqual(len(v), shape[0])
+ self.assertEqual(len(v), shape[0])
else:
- self.failUnlessEqual(len(v) * sizeof(itemtp), sizeof(ob))
- self.failUnlessEqual(v.itemsize, sizeof(itemtp))
- self.failUnlessEqual(v.shape, shape)
+ self.assertEqual(len(v) * sizeof(itemtp), sizeof(ob))
+ self.assertEqual(v.itemsize, sizeof(itemtp))
+ self.assertEqual(v.shape, shape)
# ctypes object always have a non-strided memory block
- self.failUnlessEqual(v.strides, None)
+ self.assertEqual(v.strides, None)
# they are always read/write
- self.failIf(v.readonly)
+ self.assertFalse(v.readonly)
if v.shape:
n = 1
for dim in v.shape:
n = n * dim
- self.failUnlessEqual(n, len(v))
+ self.assertEqual(n, len(v))
except:
# so that we can see the failing type
print(tp)
Modified: python/branches/py3k/Lib/ctypes/test/test_pickling.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_pickling.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_pickling.py Wed Jul 1 01:06:06 2009
@@ -27,8 +27,8 @@
c_double(3.14),
]:
dst = self.loads(self.dumps(src))
- self.failUnlessEqual(src.__dict__, dst.__dict__)
- self.failUnlessEqual(memoryview(src).tobytes(),
+ self.assertEqual(src.__dict__, dst.__dict__)
+ self.assertEqual(memoryview(src).tobytes(),
memoryview(dst).tobytes())
def test_struct(self):
@@ -36,17 +36,17 @@
x = X()
x.a = 42
- self.failUnlessEqual(X.init_called, 1)
+ self.assertEqual(X.init_called, 1)
y = self.loads(self.dumps(x))
# loads must NOT call __init__
- self.failUnlessEqual(X.init_called, 1)
+ self.assertEqual(X.init_called, 1)
# ctypes instances are identical when the instance __dict__
# and the memory buffer are identical
- self.failUnlessEqual(y.__dict__, x.__dict__)
- self.failUnlessEqual(memoryview(y).tobytes(),
+ self.assertEqual(y.__dict__, x.__dict__)
+ self.assertEqual(memoryview(y).tobytes(),
memoryview(x).tobytes())
def test_unpickable(self):
Modified: python/branches/py3k/Lib/ctypes/test/test_pointers.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_pointers.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_pointers.py Wed Jul 1 01:06:06 2009
@@ -17,7 +17,7 @@
POINTER(c_ulong)(c_ulong(22))
# Pointer can't set contents: has no _type_
- self.failUnlessRaises(TypeError, A, c_ulong(33))
+ self.assertRaises(TypeError, A, c_ulong(33))
def test_pass_pointers(self):
dll = CDLL(_ctypes_test.__file__)
@@ -27,12 +27,12 @@
i = c_int(12345678)
## func.argtypes = (POINTER(c_int),)
address = func(byref(i))
- self.failUnlessEqual(c_int.from_address(address).value, 12345678)
+ self.assertEqual(c_int.from_address(address).value, 12345678)
func.restype = POINTER(c_int)
res = func(pointer(i))
- self.failUnlessEqual(res.contents.value, 12345678)
- self.failUnlessEqual(res[0], 12345678)
+ self.assertEqual(res.contents.value, 12345678)
+ self.assertEqual(res[0], 12345678)
def test_change_pointers(self):
dll = CDLL(_ctypes_test.__file__)
@@ -43,18 +43,18 @@
func.argtypes = (POINTER(c_int),)
res = func(pointer(i))
- self.failUnlessEqual(res[0], 87654)
- self.failUnlessEqual(res.contents.value, 87654)
+ self.assertEqual(res[0], 87654)
+ self.assertEqual(res.contents.value, 87654)
# C code: *res = 54345
res[0] = 54345
- self.failUnlessEqual(i.value, 54345)
+ self.assertEqual(i.value, 54345)
# C code:
# int x = 12321;
# res = &x
res.contents = c_int(12321)
- self.failUnlessEqual(i.value, 54345)
+ self.assertEqual(i.value, 54345)
def test_callbacks_with_pointers(self):
# a function type receiving a pointer
@@ -78,7 +78,7 @@
## i = c_int(42)
## callback(byref(i))
-## self.failUnless(i.value == 84)
+## self.assertTrue(i.value == 84)
doit(callback)
## print self.result
@@ -91,11 +91,11 @@
i = ct(42)
p = pointer(i)
## print type(p.contents), ct
- self.failUnless(type(p.contents) is ct)
+ self.assertTrue(type(p.contents) is ct)
# p.contents is the same as p[0]
## print p.contents
-## self.failUnless(p.contents == 42)
-## self.failUnless(p[0] == 42)
+## self.assertTrue(p.contents == 42)
+## self.assertTrue(p[0] == 42)
self.assertRaises(TypeError, delitem, p, 0)
@@ -117,9 +117,9 @@
pt = pointer(Table(1, 2, 3))
- self.failUnlessEqual(pt.contents.a, 1)
- self.failUnlessEqual(pt.contents.b, 2)
- self.failUnlessEqual(pt.contents.c, 3)
+ self.assertEqual(pt.contents.a, 1)
+ self.assertEqual(pt.contents.b, 2)
+ self.assertEqual(pt.contents.c, 3)
pt.contents.c = 33
@@ -130,8 +130,8 @@
p = pointer(c_int(42))
# Although a pointer can be indexed, it ha no length
self.assertRaises(TypeError, len, p)
- self.failUnlessEqual(p[0], 42)
- self.failUnlessEqual(p.contents.value, 42)
+ self.assertEqual(p[0], 42)
+ self.assertEqual(p.contents.value, 42)
def test_charpp(self):
"""Test that a character pointer-to-pointer is correctly passed"""
@@ -156,20 +156,20 @@
pp = pointer(p)
q = pointer(y)
pp[0] = q # <==
- self.failUnlessEqual(p[0], 6)
+ self.assertEqual(p[0], 6)
def test_c_void_p(self):
# http://sourceforge.net/tracker/?func=detail&aid=1518190&group_id=5470&atid=…
if sizeof(c_void_p) == 4:
- self.failUnlessEqual(c_void_p(0xFFFFFFFF).value,
+ self.assertEqual(c_void_p(0xFFFFFFFF).value,
c_void_p(-1).value)
- self.failUnlessEqual(c_void_p(0xFFFFFFFFFFFFFFFF).value,
+ self.assertEqual(c_void_p(0xFFFFFFFFFFFFFFFF).value,
c_void_p(-1).value)
elif sizeof(c_void_p) == 8:
- self.failUnlessEqual(c_void_p(0xFFFFFFFF).value,
+ self.assertEqual(c_void_p(0xFFFFFFFF).value,
0xFFFFFFFF)
- self.failUnlessEqual(c_void_p(0xFFFFFFFFFFFFFFFF).value,
+ self.assertEqual(c_void_p(0xFFFFFFFFFFFFFFFF).value,
c_void_p(-1).value)
- self.failUnlessEqual(c_void_p(0xFFFFFFFFFFFFFFFFFFFFFFFF).value,
+ self.assertEqual(c_void_p(0xFFFFFFFFFFFFFFFFFFFFFFFF).value,
c_void_p(-1).value)
self.assertRaises(TypeError, c_void_p, 3.14) # make sure floats are NOT accepted
@@ -177,16 +177,16 @@
def test_pointers_bool(self):
# NULL pointers have a boolean False value, non-NULL pointers True.
- self.failUnlessEqual(bool(POINTER(c_int)()), False)
- self.failUnlessEqual(bool(pointer(c_int())), True)
+ self.assertEqual(bool(POINTER(c_int)()), False)
+ self.assertEqual(bool(pointer(c_int())), True)
- self.failUnlessEqual(bool(CFUNCTYPE(None)(0)), False)
- self.failUnlessEqual(bool(CFUNCTYPE(None)(42)), True)
+ self.assertEqual(bool(CFUNCTYPE(None)(0)), False)
+ self.assertEqual(bool(CFUNCTYPE(None)(42)), True)
# COM methods are boolean True:
if sys.platform == "win32":
mth = WINFUNCTYPE(None)(42, "name", (), None)
- self.failUnlessEqual(bool(mth), True)
+ self.assertEqual(bool(mth), True)
if __name__ == '__main__':
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_prototypes.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_prototypes.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_prototypes.py Wed Jul 1 01:06:06 2009
@@ -58,23 +58,23 @@
try:
func()
except TypeError as details:
- self.failUnlessEqual(str(details), "required argument 'input' missing")
+ self.assertEqual(str(details), "required argument 'input' missing")
else:
self.fail("TypeError not raised")
- self.failUnlessEqual(func(None), None)
- self.failUnlessEqual(func(input=None), None)
+ self.assertEqual(func(None), None)
+ self.assertEqual(func(input=None), None)
def test_int_pointer_arg(self):
func = testdll._testfunc_p_p
func.restype = c_long
- self.failUnlessEqual(0, func(0))
+ self.assertEqual(0, func(0))
ci = c_int(0)
func.argtypes = POINTER(c_int),
- self.failUnlessEqual(positive_address(addressof(ci)),
+ self.assertEqual(positive_address(addressof(ci)),
positive_address(func(byref(ci))))
func.argtypes = c_char_p,
@@ -91,45 +91,45 @@
func.restype = c_char_p
func.argtypes = POINTER(c_char),
- self.failUnlessEqual(None, func(None))
- self.failUnlessEqual("123", func("123"))
- self.failUnlessEqual(None, func(c_char_p(None)))
- self.failUnlessEqual("123", func(c_char_p("123")))
+ self.assertEqual(None, func(None))
+ self.assertEqual("123", func("123"))
+ self.assertEqual(None, func(c_char_p(None)))
+ self.assertEqual("123", func(c_char_p("123")))
- self.failUnlessEqual("123", func(c_buffer("123")))
+ self.assertEqual("123", func(c_buffer("123")))
ca = c_char("a")
- self.failUnlessEqual("a", func(pointer(ca))[0])
- self.failUnlessEqual("a", func(byref(ca))[0])
+ self.assertEqual("a", func(pointer(ca))[0])
+ self.assertEqual("a", func(byref(ca))[0])
def test_c_char_p_arg(self):
func = testdll._testfunc_p_p
func.restype = c_char_p
func.argtypes = c_char_p,
- self.failUnlessEqual(None, func(None))
- self.failUnlessEqual("123", func("123"))
- self.failUnlessEqual(None, func(c_char_p(None)))
- self.failUnlessEqual("123", func(c_char_p("123")))
+ self.assertEqual(None, func(None))
+ self.assertEqual("123", func("123"))
+ self.assertEqual(None, func(c_char_p(None)))
+ self.assertEqual("123", func(c_char_p("123")))
- self.failUnlessEqual("123", func(c_buffer("123")))
+ self.assertEqual("123", func(c_buffer("123")))
ca = c_char("a")
- self.failUnlessEqual("a", func(pointer(ca))[0])
- self.failUnlessEqual("a", func(byref(ca))[0])
+ self.assertEqual("a", func(pointer(ca))[0])
+ self.assertEqual("a", func(byref(ca))[0])
def test_c_void_p_arg(self):
func = testdll._testfunc_p_p
func.restype = c_char_p
func.argtypes = c_void_p,
- self.failUnlessEqual(None, func(None))
- self.failUnlessEqual("123", func(b"123"))
- self.failUnlessEqual("123", func(c_char_p("123")))
- self.failUnlessEqual(None, func(c_char_p(None)))
+ self.assertEqual(None, func(None))
+ self.assertEqual("123", func(b"123"))
+ self.assertEqual("123", func(c_char_p("123")))
+ self.assertEqual(None, func(c_char_p(None)))
- self.failUnlessEqual("123", func(c_buffer("123")))
+ self.assertEqual("123", func(c_buffer("123")))
ca = c_char("a")
- self.failUnlessEqual("a", func(pointer(ca))[0])
- self.failUnlessEqual("a", func(byref(ca))[0])
+ self.assertEqual("a", func(pointer(ca))[0])
+ self.assertEqual("a", func(byref(ca))[0])
func(byref(c_int()))
func(pointer(c_int()))
@@ -140,8 +140,8 @@
except NameError:
pass
else:
- self.failUnlessEqual(None, func(c_wchar_p(None)))
- self.failUnlessEqual("123", func(c_wchar_p("123")))
+ self.assertEqual(None, func(c_wchar_p(None)))
+ self.assertEqual("123", func(c_wchar_p("123")))
def test_instance(self):
func = testdll._testfunc_p_p
@@ -151,10 +151,10 @@
_as_parameter_ = None
func.argtypes = c_void_p,
- self.failUnlessEqual(None, func(X()))
+ self.assertEqual(None, func(X()))
func.argtypes = None
- self.failUnlessEqual(None, func(X()))
+ self.assertEqual(None, func(X()))
try:
c_wchar
@@ -174,15 +174,15 @@
func.restype = c_wchar_p
func.argtypes = POINTER(c_wchar),
- self.failUnlessEqual(None, func(None))
- self.failUnlessEqual("123", func("123"))
- self.failUnlessEqual(None, func(c_wchar_p(None)))
- self.failUnlessEqual("123", func(c_wchar_p("123")))
+ self.assertEqual(None, func(None))
+ self.assertEqual("123", func("123"))
+ self.assertEqual(None, func(c_wchar_p(None)))
+ self.assertEqual("123", func(c_wchar_p("123")))
- self.failUnlessEqual("123", func(c_wbuffer("123")))
+ self.assertEqual("123", func(c_wbuffer("123")))
ca = c_wchar("a")
- self.failUnlessEqual("a", func(pointer(ca))[0])
- self.failUnlessEqual("a", func(byref(ca))[0])
+ self.assertEqual("a", func(pointer(ca))[0])
+ self.assertEqual("a", func(byref(ca))[0])
def test_c_wchar_p_arg(self):
func = testdll._testfunc_p_p
@@ -191,16 +191,16 @@
c_wchar_p.from_param("123")
- self.failUnlessEqual(None, func(None))
- self.failUnlessEqual("123", func("123"))
- self.failUnlessEqual(None, func(c_wchar_p(None)))
- self.failUnlessEqual("123", func(c_wchar_p("123")))
+ self.assertEqual(None, func(None))
+ self.assertEqual("123", func("123"))
+ self.assertEqual(None, func(c_wchar_p(None)))
+ self.assertEqual("123", func(c_wchar_p("123")))
# XXX Currently, these raise TypeErrors, although they shouldn't:
- self.failUnlessEqual("123", func(c_wbuffer("123")))
+ self.assertEqual("123", func(c_wbuffer("123")))
ca = c_wchar("a")
- self.failUnlessEqual("a", func(pointer(ca))[0])
- self.failUnlessEqual("a", func(byref(ca))[0])
+ self.assertEqual("a", func(pointer(ca))[0])
+ self.assertEqual("a", func(byref(ca))[0])
class ArrayTest(unittest.TestCase):
def test(self):
Modified: python/branches/py3k/Lib/ctypes/test/test_python_api.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_python_api.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_python_api.py Wed Jul 1 01:06:06 2009
@@ -23,7 +23,7 @@
PyBytes_FromStringAndSize.restype = py_object
PyBytes_FromStringAndSize.argtypes = c_char_p, c_py_ssize_t
- self.failUnlessEqual(PyBytes_FromStringAndSize(b"abcdefghi", 3), b"abc")
+ self.assertEqual(PyBytes_FromStringAndSize(b"abcdefghi", 3), b"abc")
def test_PyString_FromString(self):
pythonapi.PyBytes_FromString.restype = py_object
@@ -32,10 +32,10 @@
s = b"abc"
refcnt = grc(s)
pyob = pythonapi.PyBytes_FromString(s)
- self.failUnlessEqual(grc(s), refcnt)
- self.failUnlessEqual(s, pyob)
+ self.assertEqual(grc(s), refcnt)
+ self.assertEqual(s, pyob)
del pyob
- self.failUnlessEqual(grc(s), refcnt)
+ self.assertEqual(grc(s), refcnt)
if is_resource_enabled("refcount"):
# This test is unreliable, because it is possible that code in
@@ -44,28 +44,28 @@
def test_PyLong_Long(self):
ref42 = grc(42)
pythonapi.PyLong_FromLong.restype = py_object
- self.failUnlessEqual(pythonapi.PyLong_FromLong(42), 42)
+ self.assertEqual(pythonapi.PyLong_FromLong(42), 42)
- self.failUnlessEqual(grc(42), ref42)
+ self.assertEqual(grc(42), ref42)
pythonapi.PyLong_AsLong.argtypes = (py_object,)
pythonapi.PyLong_AsLong.restype = c_long
res = pythonapi.PyLong_AsLong(42)
- self.failUnlessEqual(grc(res), ref42 + 1)
+ self.assertEqual(grc(res), ref42 + 1)
del res
- self.failUnlessEqual(grc(42), ref42)
+ self.assertEqual(grc(42), ref42)
def test_PyObj_FromPtr(self):
s = "abc def ghi jkl"
ref = grc(s)
# id(python-object) is the address
pyobj = PyObj_FromPtr(id(s))
- self.failUnless(s is pyobj)
+ self.assertTrue(s is pyobj)
- self.failUnlessEqual(grc(s), ref + 1)
+ self.assertEqual(grc(s), ref + 1)
del pyobj
- self.failUnlessEqual(grc(s), ref)
+ self.assertEqual(grc(s), ref)
def test_PyOS_snprintf(self):
PyOS_snprintf = pythonapi.PyOS_snprintf
@@ -73,18 +73,18 @@
buf = c_buffer(256)
PyOS_snprintf(buf, sizeof(buf), "Hello from %s", b"ctypes")
- self.failUnlessEqual(buf.value, b"Hello from ctypes")
+ self.assertEqual(buf.value, b"Hello from ctypes")
PyOS_snprintf(buf, sizeof(buf), "Hello from %s (%d, %d, %d)", b"ctypes", 1, 2, 3)
- self.failUnlessEqual(buf.value, b"Hello from ctypes (1, 2, 3)")
+ self.assertEqual(buf.value, b"Hello from ctypes (1, 2, 3)")
# not enough arguments
- self.failUnlessRaises(TypeError, PyOS_snprintf, buf)
+ self.assertRaises(TypeError, PyOS_snprintf, buf)
def test_pyobject_repr(self):
- self.failUnlessEqual(repr(py_object()), "py_object(<NULL>)")
- self.failUnlessEqual(repr(py_object(42)), "py_object(42)")
- self.failUnlessEqual(repr(py_object(object)), "py_object(%r)" % object)
+ self.assertEqual(repr(py_object()), "py_object(<NULL>)")
+ self.assertEqual(repr(py_object(42)), "py_object(42)")
+ self.assertEqual(repr(py_object(object)), "py_object(%r)" % object)
if __name__ == "__main__":
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_random_things.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_random_things.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_random_things.py Wed Jul 1 01:06:06 2009
@@ -20,7 +20,7 @@
hdll = windll.kernel32.LoadLibraryA(b"kernel32")
funcaddr = windll.kernel32.GetProcAddress(hdll, "GetModuleHandleA")
- self.failUnlessEqual(call_function(funcaddr, (None,)),
+ self.assertEqual(call_function(funcaddr, (None,)),
windll.kernel32.GetModuleHandleA(None))
class CallbackTracbackTestCase(unittest.TestCase):
@@ -49,25 +49,25 @@
def test_ValueError(self):
cb = CFUNCTYPE(c_int, c_int)(callback_func)
out = self.capture_stderr(cb, 42)
- self.failUnlessEqual(out.splitlines()[-1],
+ self.assertEqual(out.splitlines()[-1],
"ValueError: 42")
def test_IntegerDivisionError(self):
cb = CFUNCTYPE(c_int, c_int)(callback_func)
out = self.capture_stderr(cb, 0)
- self.failUnlessEqual(out.splitlines()[-1][:19],
+ self.assertEqual(out.splitlines()[-1][:19],
"ZeroDivisionError: ")
def test_FloatDivisionError(self):
cb = CFUNCTYPE(c_int, c_double)(callback_func)
out = self.capture_stderr(cb, 0.0)
- self.failUnlessEqual(out.splitlines()[-1][:19],
+ self.assertEqual(out.splitlines()[-1][:19],
"ZeroDivisionError: ")
def test_TypeErrorDivisionError(self):
cb = CFUNCTYPE(c_int, c_char_p)(callback_func)
out = self.capture_stderr(cb, "spam")
- self.failUnlessEqual(out.splitlines()[-1],
+ self.assertEqual(out.splitlines()[-1],
"TypeError: "
"unsupported operand type(s) for /: 'int' and 'str'")
Modified: python/branches/py3k/Lib/ctypes/test/test_refcounts.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_refcounts.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_refcounts.py Wed Jul 1 01:06:06 2009
@@ -21,17 +21,17 @@
#print "called back with", value
return value
- self.failUnlessEqual(grc(callback), 2)
+ self.assertEqual(grc(callback), 2)
cb = MyCallback(callback)
- self.failUnless(grc(callback) > 2)
+ self.assertTrue(grc(callback) > 2)
result = f(-10, cb)
- self.failUnlessEqual(result, -18)
+ self.assertEqual(result, -18)
cb = None
gc.collect()
- self.failUnlessEqual(grc(callback), 2)
+ self.assertEqual(grc(callback), 2)
def test_refcount(self):
@@ -39,19 +39,19 @@
def func(*args):
pass
# this is the standard refcount for func
- self.failUnlessEqual(grc(func), 2)
+ self.assertEqual(grc(func), 2)
# the CFuncPtr instance holds atr least one refcount on func:
f = OtherCallback(func)
- self.failUnless(grc(func) > 2)
+ self.assertTrue(grc(func) > 2)
# and may release it again
del f
- self.failUnless(grc(func) >= 2)
+ self.assertTrue(grc(func) >= 2)
# but now it must be gone
gc.collect()
- self.failUnless(grc(func) == 2)
+ self.assertTrue(grc(func) == 2)
class X(ctypes.Structure):
_fields_ = [("a", OtherCallback)]
@@ -59,27 +59,27 @@
x.a = OtherCallback(func)
# the CFuncPtr instance holds atr least one refcount on func:
- self.failUnless(grc(func) > 2)
+ self.assertTrue(grc(func) > 2)
# and may release it again
del x
- self.failUnless(grc(func) >= 2)
+ self.assertTrue(grc(func) >= 2)
# and now it must be gone again
gc.collect()
- self.failUnlessEqual(grc(func), 2)
+ self.assertEqual(grc(func), 2)
f = OtherCallback(func)
# the CFuncPtr instance holds atr least one refcount on func:
- self.failUnless(grc(func) > 2)
+ self.assertTrue(grc(func) > 2)
# create a cycle
f.cycle = f
del f
gc.collect()
- self.failUnlessEqual(grc(func), 2)
+ self.assertEqual(grc(func), 2)
class AnotherLeak(unittest.TestCase):
def test_callback(self):
@@ -92,7 +92,7 @@
a = sys.getrefcount(ctypes.c_int)
f(1, 2)
- self.failUnlessEqual(sys.getrefcount(ctypes.c_int), a)
+ self.assertEqual(sys.getrefcount(ctypes.c_int), a)
if __name__ == '__main__':
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_repr.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_repr.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_repr.py Wed Jul 1 01:06:06 2009
@@ -18,12 +18,12 @@
def test_numbers(self):
for typ in subclasses:
base = typ.__bases__[0]
- self.failUnless(repr(base(42)).startswith(base.__name__))
- self.failUnlessEqual("<X object at", repr(typ(42))[:12])
+ self.assertTrue(repr(base(42)).startswith(base.__name__))
+ self.assertEqual("<X object at", repr(typ(42))[:12])
def test_char(self):
- self.failUnlessEqual("c_char(b'x')", repr(c_char('x')))
- self.failUnlessEqual("<X object at", repr(X('x'))[:12])
+ self.assertEqual("c_char(b'x')", repr(c_char('x')))
+ self.assertEqual("<X object at", repr(X('x'))[:12])
if __name__ == "__main__":
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_returnfuncptrs.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_returnfuncptrs.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_returnfuncptrs.py Wed Jul 1 01:06:06 2009
@@ -12,10 +12,10 @@
get_strchr = dll.get_strchr
get_strchr.restype = CFUNCTYPE(c_char_p, c_char_p, c_char)
strchr = get_strchr()
- self.failUnlessEqual(strchr("abcdef", "b"), "bcdef")
- self.failUnlessEqual(strchr("abcdef", "x"), None)
- self.failUnlessEqual(strchr("abcdef", 98), "bcdef")
- self.failUnlessEqual(strchr("abcdef", 107), None)
+ self.assertEqual(strchr("abcdef", "b"), "bcdef")
+ self.assertEqual(strchr("abcdef", "x"), None)
+ self.assertEqual(strchr("abcdef", 98), "bcdef")
+ self.assertEqual(strchr("abcdef", 107), None)
self.assertRaises(ArgumentError, strchr, "abcdef", 3.0)
self.assertRaises(TypeError, strchr, "abcdef")
@@ -28,8 +28,8 @@
# _CFuncPtr instances are now callable with an integer argument
# which denotes a function address:
strchr = CFUNCTYPE(c_char_p, c_char_p, c_char)(addr)
- self.failUnless(strchr("abcdef", "b"), "bcdef")
- self.failUnlessEqual(strchr("abcdef", "x"), None)
+ self.assertTrue(strchr("abcdef", "b"), "bcdef")
+ self.assertEqual(strchr("abcdef", "x"), None)
self.assertRaises(ArgumentError, strchr, "abcdef", 3.0)
self.assertRaises(TypeError, strchr, "abcdef")
Modified: python/branches/py3k/Lib/ctypes/test/test_simplesubclasses.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_simplesubclasses.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_simplesubclasses.py Wed Jul 1 01:06:06 2009
@@ -10,8 +10,8 @@
class Test(unittest.TestCase):
def test_compare(self):
- self.failUnlessEqual(MyInt(3), MyInt(3))
- self.failIfEqual(MyInt(42), MyInt(43))
+ self.assertEqual(MyInt(3), MyInt(3))
+ self.assertNotEqual(MyInt(42), MyInt(43))
def test_ignore_retval(self):
# Test if the return value of a callback is ignored
@@ -21,7 +21,7 @@
return (1, "abc", None)
cb = proto(func)
- self.failUnlessEqual(None, cb())
+ self.assertEqual(None, cb())
def test_int_callback(self):
@@ -32,24 +32,24 @@
cb = CFUNCTYPE(None, MyInt)(func)
- self.failUnlessEqual(None, cb(42))
- self.failUnlessEqual(type(args[-1]), MyInt)
+ self.assertEqual(None, cb(42))
+ self.assertEqual(type(args[-1]), MyInt)
cb = CFUNCTYPE(c_int, c_int)(func)
- self.failUnlessEqual(42, cb(42))
- self.failUnlessEqual(type(args[-1]), int)
+ self.assertEqual(42, cb(42))
+ self.assertEqual(type(args[-1]), int)
def test_int_struct(self):
class X(Structure):
_fields_ = [("x", MyInt)]
- self.failUnlessEqual(X().x, MyInt())
+ self.assertEqual(X().x, MyInt())
s = X()
s.x = MyInt(42)
- self.failUnlessEqual(s.x, MyInt(42))
+ self.assertEqual(s.x, MyInt(42))
if __name__ == "__main__":
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_sizes.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_sizes.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_sizes.py Wed Jul 1 01:06:06 2009
@@ -5,23 +5,23 @@
class SizesTestCase(unittest.TestCase):
def test_8(self):
- self.failUnlessEqual(1, sizeof(c_int8))
- self.failUnlessEqual(1, sizeof(c_uint8))
+ self.assertEqual(1, sizeof(c_int8))
+ self.assertEqual(1, sizeof(c_uint8))
def test_16(self):
- self.failUnlessEqual(2, sizeof(c_int16))
- self.failUnlessEqual(2, sizeof(c_uint16))
+ self.assertEqual(2, sizeof(c_int16))
+ self.assertEqual(2, sizeof(c_uint16))
def test_32(self):
- self.failUnlessEqual(4, sizeof(c_int32))
- self.failUnlessEqual(4, sizeof(c_uint32))
+ self.assertEqual(4, sizeof(c_int32))
+ self.assertEqual(4, sizeof(c_uint32))
def test_64(self):
- self.failUnlessEqual(8, sizeof(c_int64))
- self.failUnlessEqual(8, sizeof(c_uint64))
+ self.assertEqual(8, sizeof(c_int64))
+ self.assertEqual(8, sizeof(c_uint64))
def test_size_t(self):
- self.failUnlessEqual(sizeof(c_void_p), sizeof(c_size_t))
+ self.assertEqual(sizeof(c_void_p), sizeof(c_size_t))
if __name__ == "__main__":
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_slicing.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_slicing.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_slicing.py Wed Jul 1 01:06:06 2009
@@ -7,43 +7,43 @@
def test_getslice_cint(self):
a = (c_int * 100)(*range(1100, 1200))
b = list(range(1100, 1200))
- self.failUnlessEqual(a[0:2], b[0:2])
- self.failUnlessEqual(a[0:2:], b[0:2:])
- self.failUnlessEqual(len(a), len(b))
- self.failUnlessEqual(a[5:7], b[5:7])
- self.failUnlessEqual(a[5:7:], b[5:7:])
- self.failUnlessEqual(a[-1], b[-1])
- self.failUnlessEqual(a[:], b[:])
- self.failUnlessEqual(a[::], b[::])
- self.failUnlessEqual(a[10::-1], b[10::-1])
- self.failUnlessEqual(a[30:20:-1], b[30:20:-1])
- self.failUnlessEqual(a[:12:6], b[:12:6])
- self.failUnlessEqual(a[2:6:4], b[2:6:4])
+ self.assertEqual(a[0:2], b[0:2])
+ self.assertEqual(a[0:2:], b[0:2:])
+ self.assertEqual(len(a), len(b))
+ self.assertEqual(a[5:7], b[5:7])
+ self.assertEqual(a[5:7:], b[5:7:])
+ self.assertEqual(a[-1], b[-1])
+ self.assertEqual(a[:], b[:])
+ self.assertEqual(a[::], b[::])
+ self.assertEqual(a[10::-1], b[10::-1])
+ self.assertEqual(a[30:20:-1], b[30:20:-1])
+ self.assertEqual(a[:12:6], b[:12:6])
+ self.assertEqual(a[2:6:4], b[2:6:4])
a[0:5] = range(5, 10)
- self.failUnlessEqual(a[0:5], list(range(5, 10)))
- self.failUnlessEqual(a[0:5:], list(range(5, 10)))
- self.failUnlessEqual(a[4::-1], list(range(9, 4, -1)))
+ self.assertEqual(a[0:5], list(range(5, 10)))
+ self.assertEqual(a[0:5:], list(range(5, 10)))
+ self.assertEqual(a[4::-1], list(range(9, 4, -1)))
def test_setslice_cint(self):
a = (c_int * 100)(*range(1100, 1200))
b = list(range(1100, 1200))
a[32:47] = list(range(32, 47))
- self.failUnlessEqual(a[32:47], list(range(32, 47)))
+ self.assertEqual(a[32:47], list(range(32, 47)))
a[32:47] = range(132, 147)
- self.failUnlessEqual(a[32:47:], list(range(132, 147)))
+ self.assertEqual(a[32:47:], list(range(132, 147)))
a[46:31:-1] = range(232, 247)
- self.failUnlessEqual(a[32:47:1], list(range(246, 231, -1)))
+ self.assertEqual(a[32:47:1], list(range(246, 231, -1)))
a[32:47] = range(1132, 1147)
- self.failUnlessEqual(a[:], b)
+ self.assertEqual(a[:], b)
a[32:47:7] = range(3)
b[32:47:7] = range(3)
- self.failUnlessEqual(a[:], b)
+ self.assertEqual(a[:], b)
a[33::-3] = range(12)
b[33::-3] = range(12)
- self.failUnlessEqual(a[:], b)
+ self.assertEqual(a[:], b)
from operator import setitem
@@ -65,12 +65,12 @@
dll.my_strdup.restype = POINTER(c_char)
dll.my_free.restype = None
res = dll.my_strdup(s)
- self.failUnlessEqual(res[:len(s)], s)
- self.failUnlessEqual(res[:3], s[:3])
- self.failUnlessEqual(res[:len(s):], s)
- self.failUnlessEqual(res[len(s)-1:-1:-1], s[::-1])
- self.failUnlessEqual(res[len(s)-1:5:-7], s[:5:-7])
- self.failUnlessEqual(res[0:-1:-1], s[0::-1])
+ self.assertEqual(res[:len(s)], s)
+ self.assertEqual(res[:3], s[:3])
+ self.assertEqual(res[:len(s):], s)
+ self.assertEqual(res[len(s)-1:-1:-1], s[::-1])
+ self.assertEqual(res[len(s)-1:5:-7], s[:5:-7])
+ self.assertEqual(res[0:-1:-1], s[0::-1])
import operator
self.assertRaises(ValueError, operator.getitem,
@@ -88,8 +88,8 @@
dll.my_strdup.restype = POINTER(c_byte)
res = dll.my_strdup(s)
- self.failUnlessEqual(res[:len(s)], list(range(ord("a"), ord("z")+1)))
- self.failUnlessEqual(res[:len(s):], list(range(ord("a"), ord("z")+1)))
+ self.assertEqual(res[:len(s)], list(range(ord("a"), ord("z")+1)))
+ self.assertEqual(res[:len(s):], list(range(ord("a"), ord("z")+1)))
dll.my_free(res)
def test_char_ptr_with_free(self):
@@ -109,7 +109,7 @@
dll.my_strdup.errcheck = errcheck
try:
res = dll.my_strdup(s)
- self.failUnlessEqual(res, s.decode())
+ self.assertEqual(res, s.decode())
finally:
del dll.my_strdup.errcheck
@@ -118,11 +118,11 @@
s = b"abcdefghijklmnopqrstuvwxyz\0"
p = (c_char * 27)(*s)
- self.failUnlessEqual(p[:], s)
- self.failUnlessEqual(p[::], s)
- self.failUnlessEqual(p[::-1], s[::-1])
- self.failUnlessEqual(p[5::-2], s[5::-2])
- self.failUnlessEqual(p[2:5:-3], s[2:5:-3])
+ self.assertEqual(p[:], s)
+ self.assertEqual(p[::], s)
+ self.assertEqual(p[::-1], s[::-1])
+ self.assertEqual(p[5::-2], s[5::-2])
+ self.assertEqual(p[2:5:-3], s[2:5:-3])
try:
@@ -138,10 +138,10 @@
dll.my_wcsdup.argtypes = POINTER(c_wchar),
dll.my_free.restype = None
res = dll.my_wcsdup(s)
- self.failUnlessEqual(res[:len(s)], s)
- self.failUnlessEqual(res[:len(s):], s)
- self.failUnlessEqual(res[len(s)-1:-1:-1], s[::-1])
- self.failUnlessEqual(res[len(s)-1:5:-7], s[:5:-7])
+ self.assertEqual(res[:len(s)], s)
+ self.assertEqual(res[:len(s):], s)
+ self.assertEqual(res[len(s)-1:-1:-1], s[::-1])
+ self.assertEqual(res[len(s)-1:5:-7], s[:5:-7])
import operator
self.assertRaises(TypeError, operator.setitem,
@@ -158,10 +158,10 @@
return
res = dll.my_wcsdup(s)
tmpl = list(range(ord("a"), ord("z")+1))
- self.failUnlessEqual(res[:len(s)-1], tmpl)
- self.failUnlessEqual(res[:len(s)-1:], tmpl)
- self.failUnlessEqual(res[len(s)-2:-1:-1], tmpl[::-1])
- self.failUnlessEqual(res[len(s)-2:5:-7], tmpl[:5:-7])
+ self.assertEqual(res[:len(s)-1], tmpl)
+ self.assertEqual(res[:len(s)-1:], tmpl)
+ self.assertEqual(res[len(s)-2:-1:-1], tmpl[::-1])
+ self.assertEqual(res[len(s)-2:5:-7], tmpl[:5:-7])
dll.my_free(res)
################################################################
Modified: python/branches/py3k/Lib/ctypes/test/test_stringptr.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_stringptr.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_stringptr.py Wed Jul 1 01:06:06 2009
@@ -16,14 +16,14 @@
self.assertRaises(ValueError, getattr, x.str, "contents")
b = c_buffer("Hello, World")
from sys import getrefcount as grc
- self.failUnlessEqual(grc(b), 2)
+ self.assertEqual(grc(b), 2)
x.str = b
- self.failUnlessEqual(grc(b), 3)
+ self.assertEqual(grc(b), 3)
# POINTER(c_char) and Python string is NOT compatible
# POINTER(c_char) and c_buffer() is compatible
for i in range(len(b)):
- self.failUnlessEqual(b[i], x.str[i])
+ self.assertEqual(b[i], x.str[i])
self.assertRaises(TypeError, setattr, x, "str", "Hello, World")
@@ -34,11 +34,11 @@
# c_char_p and Python string is compatible
# c_char_p and c_buffer is NOT compatible
- self.failUnlessEqual(x.str, None)
+ self.assertEqual(x.str, None)
x.str = "Hello, World"
- self.failUnlessEqual(x.str, "Hello, World")
+ self.assertEqual(x.str, "Hello, World")
b = c_buffer("Hello, World")
- self.failUnlessRaises(TypeError, setattr, x, "str", b)
+ self.assertRaises(TypeError, setattr, x, "str", b)
def test_functions(self):
@@ -48,15 +48,15 @@
# c_char_p and Python string is compatible
# c_char_p and c_buffer are now compatible
strchr.argtypes = c_char_p, c_char
- self.failUnlessEqual(strchr("abcdef", "c"), "cdef")
- self.failUnlessEqual(strchr(c_buffer("abcdef"), "c"), "cdef")
+ self.assertEqual(strchr("abcdef", "c"), "cdef")
+ self.assertEqual(strchr(c_buffer("abcdef"), "c"), "cdef")
# POINTER(c_char) and Python string is NOT compatible
# POINTER(c_char) and c_buffer() is compatible
strchr.argtypes = POINTER(c_char), c_char
buf = c_buffer("abcdef")
- self.failUnlessEqual(strchr(buf, "c"), "cdef")
- self.failUnlessEqual(strchr("abcdef", "c"), "cdef")
+ self.assertEqual(strchr(buf, "c"), "cdef")
+ self.assertEqual(strchr("abcdef", "c"), "cdef")
# XXX These calls are dangerous, because the first argument
# to strchr is no longer valid after the function returns!
@@ -66,7 +66,7 @@
buf = c_buffer("abcdef")
r = strchr(buf, "c")
x = r[0], r[1], r[2], r[3], r[4]
- self.failUnlessEqual(x, (b"c", b"d", b"e", b"f", b"\000"))
+ self.assertEqual(x, (b"c", b"d", b"e", b"f", b"\000"))
del buf
# x1 will NOT be the same as x, usually:
x1 = r[0], r[1], r[2], r[3], r[4]
Modified: python/branches/py3k/Lib/ctypes/test/test_strings.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_strings.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_strings.py Wed Jul 1 01:06:06 2009
@@ -6,20 +6,20 @@
BUF = c_char * 4
buf = BUF("a", "b", "c")
- self.failUnlessEqual(buf.value, b"abc")
- self.failUnlessEqual(buf.raw, b"abc\000")
+ self.assertEqual(buf.value, b"abc")
+ self.assertEqual(buf.raw, b"abc\000")
buf.value = "ABCD"
- self.failUnlessEqual(buf.value, b"ABCD")
- self.failUnlessEqual(buf.raw, b"ABCD")
+ self.assertEqual(buf.value, b"ABCD")
+ self.assertEqual(buf.raw, b"ABCD")
buf.value = "x"
- self.failUnlessEqual(buf.value, b"x")
- self.failUnlessEqual(buf.raw, b"x\000CD")
+ self.assertEqual(buf.value, b"x")
+ self.assertEqual(buf.raw, b"x\000CD")
buf[1] = "Z"
- self.failUnlessEqual(buf.value, b"xZCD")
- self.failUnlessEqual(buf.raw, b"xZCD")
+ self.assertEqual(buf.value, b"xZCD")
+ self.assertEqual(buf.raw, b"xZCD")
self.assertRaises(ValueError, setattr, buf, "value", "aaaaaaaa")
self.assertRaises(TypeError, setattr, buf, "value", 42)
@@ -28,9 +28,9 @@
buf = c_buffer(32)
buf.value = b"Hello, World"
- self.failUnlessEqual(buf.value, b"Hello, World")
+ self.assertEqual(buf.value, b"Hello, World")
- self.failUnlessRaises(TypeError, setattr, buf, "value", memoryview(b"Hello, World"))
+ self.assertRaises(TypeError, setattr, buf, "value", memoryview(b"Hello, World"))
self.assertRaises(TypeError, setattr, buf, "value", memoryview(b"abc"))
self.assertRaises(ValueError, setattr, buf, "raw", memoryview(b"x" * 100))
@@ -38,7 +38,7 @@
buf = c_buffer(32)
buf.raw = memoryview(b"Hello, World")
- self.failUnlessEqual(buf.value, b"Hello, World")
+ self.assertEqual(buf.value, b"Hello, World")
self.assertRaises(TypeError, setattr, buf, "value", memoryview(b"abc"))
self.assertRaises(ValueError, setattr, buf, "raw", memoryview(b"x" * 100))
@@ -63,16 +63,16 @@
BUF = c_wchar * 4
buf = BUF("a", "b", "c")
- self.failUnlessEqual(buf.value, "abc")
+ self.assertEqual(buf.value, "abc")
buf.value = "ABCD"
- self.failUnlessEqual(buf.value, "ABCD")
+ self.assertEqual(buf.value, "ABCD")
buf.value = "x"
- self.failUnlessEqual(buf.value, "x")
+ self.assertEqual(buf.value, "x")
buf[1] = "Z"
- self.failUnlessEqual(buf.value, "xZCD")
+ self.assertEqual(buf.value, "xZCD")
class StringTestCase(unittest.TestCase):
def XX_test_basic_strings(self):
@@ -80,24 +80,24 @@
# Cannot call len on a c_string any longer
self.assertRaises(TypeError, len, cs)
- self.failUnlessEqual(sizeof(cs), 7)
+ self.assertEqual(sizeof(cs), 7)
# The value property is the string up to the first terminating NUL.
- self.failUnlessEqual(cs.value, "abcdef")
- self.failUnlessEqual(c_string("abc\000def").value, "abc")
+ self.assertEqual(cs.value, "abcdef")
+ self.assertEqual(c_string("abc\000def").value, "abc")
# The raw property is the total buffer contents:
- self.failUnlessEqual(cs.raw, "abcdef\000")
- self.failUnlessEqual(c_string("abc\000def").raw, "abc\000def\000")
+ self.assertEqual(cs.raw, "abcdef\000")
+ self.assertEqual(c_string("abc\000def").raw, "abc\000def\000")
# We can change the value:
cs.value = "ab"
- self.failUnlessEqual(cs.value, "ab")
- self.failUnlessEqual(cs.raw, "ab\000\000\000\000\000")
+ self.assertEqual(cs.value, "ab")
+ self.assertEqual(cs.raw, "ab\000\000\000\000\000")
cs.raw = "XY"
- self.failUnlessEqual(cs.value, "XY")
- self.failUnlessEqual(cs.raw, "XY\000\000\000\000\000")
+ self.assertEqual(cs.value, "XY")
+ self.assertEqual(cs.raw, "XY\000\000\000\000\000")
self.assertRaises(TypeError, c_string, "123")
@@ -108,24 +108,24 @@
# New in releases later than 0.4.0:
# c_string(number) returns an empty string of size number
- self.failUnless(len(c_string(32).raw) == 32)
+ self.assertTrue(len(c_string(32).raw) == 32)
self.assertRaises(ValueError, c_string, -1)
self.assertRaises(ValueError, c_string, 0)
# These tests fail, because it is no longer initialized
-## self.failUnless(c_string(2).value == "")
-## self.failUnless(c_string(2).raw == "\000\000")
- self.failUnless(c_string(2).raw[-1] == "\000")
- self.failUnless(len(c_string(2).raw) == 2)
+## self.assertTrue(c_string(2).value == "")
+## self.assertTrue(c_string(2).raw == "\000\000")
+ self.assertTrue(c_string(2).raw[-1] == "\000")
+ self.assertTrue(len(c_string(2).raw) == 2)
def XX_test_initialized_strings(self):
- self.failUnless(c_string("ab", 4).raw[:2] == "ab")
- self.failUnless(c_string("ab", 4).raw[:2:] == "ab")
- self.failUnless(c_string("ab", 4).raw[:2:-1] == "ba")
- self.failUnless(c_string("ab", 4).raw[:2:2] == "a")
- self.failUnless(c_string("ab", 4).raw[-1] == "\000")
- self.failUnless(c_string("ab", 2).raw == "a\000")
+ self.assertTrue(c_string("ab", 4).raw[:2] == "ab")
+ self.assertTrue(c_string("ab", 4).raw[:2:] == "ab")
+ self.assertTrue(c_string("ab", 4).raw[:2:-1] == "ba")
+ self.assertTrue(c_string("ab", 4).raw[:2:2] == "a")
+ self.assertTrue(c_string("ab", 4).raw[-1] == "\000")
+ self.assertTrue(c_string("ab", 2).raw == "a\000")
def XX_test_toolong(self):
cs = c_string("abcdef")
@@ -156,22 +156,22 @@
# XXX This behaviour is about to change:
# len returns the size of the internal buffer in bytes.
# This includes the terminating NUL character.
- self.failUnless(sizeof(cs) == 14)
+ self.assertTrue(sizeof(cs) == 14)
# The value property is the string up to the first terminating NUL.
- self.failUnless(cs.value == "abcdef")
- self.failUnless(c_wstring("abc\000def").value == "abc")
+ self.assertTrue(cs.value == "abcdef")
+ self.assertTrue(c_wstring("abc\000def").value == "abc")
- self.failUnless(c_wstring("abc\000def").value == "abc")
+ self.assertTrue(c_wstring("abc\000def").value == "abc")
# The raw property is the total buffer contents:
- self.failUnless(cs.raw == "abcdef\000")
- self.failUnless(c_wstring("abc\000def").raw == "abc\000def\000")
+ self.assertTrue(cs.raw == "abcdef\000")
+ self.assertTrue(c_wstring("abc\000def").raw == "abc\000def\000")
# We can change the value:
cs.value = "ab"
- self.failUnless(cs.value == "ab")
- self.failUnless(cs.raw == "ab\000\000\000\000\000")
+ self.assertTrue(cs.value == "ab")
+ self.assertTrue(cs.raw == "ab\000\000\000\000\000")
self.assertRaises(TypeError, c_wstring, "123")
self.assertRaises(ValueError, c_wstring, 0)
Modified: python/branches/py3k/Lib/ctypes/test/test_struct_fields.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_struct_fields.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_struct_fields.py Wed Jul 1 01:06:06 2009
@@ -15,7 +15,7 @@
def test_1_A(self):
class X(Structure):
pass
- self.failUnlessEqual(sizeof(X), 0) # not finalized
+ self.assertEqual(sizeof(X), 0) # not finalized
X._fields_ = [] # finalized
self.assertRaises(AttributeError, setattr, X, "_fields_", [])
Modified: python/branches/py3k/Lib/ctypes/test/test_structures.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_structures.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_structures.py Wed Jul 1 01:06:06 2009
@@ -13,33 +13,33 @@
class Z(X):
pass
- self.failUnlessEqual(sizeof(X), sizeof(c_int))
- self.failUnlessEqual(sizeof(Y), sizeof(c_int)*2)
- self.failUnlessEqual(sizeof(Z), sizeof(c_int))
- self.failUnlessEqual(X._fields_, [("a", c_int)])
- self.failUnlessEqual(Y._fields_, [("b", c_int)])
- self.failUnlessEqual(Z._fields_, [("a", c_int)])
+ self.assertEqual(sizeof(X), sizeof(c_int))
+ self.assertEqual(sizeof(Y), sizeof(c_int)*2)
+ self.assertEqual(sizeof(Z), sizeof(c_int))
+ self.assertEqual(X._fields_, [("a", c_int)])
+ self.assertEqual(Y._fields_, [("b", c_int)])
+ self.assertEqual(Z._fields_, [("a", c_int)])
def test_subclass_delayed(self):
class X(Structure):
pass
- self.failUnlessEqual(sizeof(X), 0)
+ self.assertEqual(sizeof(X), 0)
X._fields_ = [("a", c_int)]
class Y(X):
pass
- self.failUnlessEqual(sizeof(Y), sizeof(X))
+ self.assertEqual(sizeof(Y), sizeof(X))
Y._fields_ = [("b", c_int)]
class Z(X):
pass
- self.failUnlessEqual(sizeof(X), sizeof(c_int))
- self.failUnlessEqual(sizeof(Y), sizeof(c_int)*2)
- self.failUnlessEqual(sizeof(Z), sizeof(c_int))
- self.failUnlessEqual(X._fields_, [("a", c_int)])
- self.failUnlessEqual(Y._fields_, [("b", c_int)])
- self.failUnlessEqual(Z._fields_, [("a", c_int)])
+ self.assertEqual(sizeof(X), sizeof(c_int))
+ self.assertEqual(sizeof(Y), sizeof(c_int)*2)
+ self.assertEqual(sizeof(Z), sizeof(c_int))
+ self.assertEqual(X._fields_, [("a", c_int)])
+ self.assertEqual(Y._fields_, [("b", c_int)])
+ self.assertEqual(Z._fields_, [("a", c_int)])
class StructureTestCase(unittest.TestCase):
formats = {"c": c_char,
@@ -62,7 +62,7 @@
class X(Structure):
_fields_ = [("x", c_char),
("y", tp)]
- self.failUnlessEqual((sizeof(X), code),
+ self.assertEqual((sizeof(X), code),
(calcsize("c%c0%c" % (code, code)), code))
def test_unions(self):
@@ -70,39 +70,39 @@
class X(Union):
_fields_ = [("x", c_char),
("y", tp)]
- self.failUnlessEqual((sizeof(X), code),
+ self.assertEqual((sizeof(X), code),
(calcsize("%c" % (code)), code))
def test_struct_alignment(self):
class X(Structure):
_fields_ = [("x", c_char * 3)]
- self.failUnlessEqual(alignment(X), calcsize("s"))
- self.failUnlessEqual(sizeof(X), calcsize("3s"))
+ self.assertEqual(alignment(X), calcsize("s"))
+ self.assertEqual(sizeof(X), calcsize("3s"))
class Y(Structure):
_fields_ = [("x", c_char * 3),
("y", c_int)]
- self.failUnlessEqual(alignment(Y), calcsize("i"))
- self.failUnlessEqual(sizeof(Y), calcsize("3si"))
+ self.assertEqual(alignment(Y), calcsize("i"))
+ self.assertEqual(sizeof(Y), calcsize("3si"))
class SI(Structure):
_fields_ = [("a", X),
("b", Y)]
- self.failUnlessEqual(alignment(SI), max(alignment(Y), alignment(X)))
- self.failUnlessEqual(sizeof(SI), calcsize("3s0i 3si 0i"))
+ self.assertEqual(alignment(SI), max(alignment(Y), alignment(X)))
+ self.assertEqual(sizeof(SI), calcsize("3s0i 3si 0i"))
class IS(Structure):
_fields_ = [("b", Y),
("a", X)]
- self.failUnlessEqual(alignment(SI), max(alignment(X), alignment(Y)))
- self.failUnlessEqual(sizeof(IS), calcsize("3si 3s 0i"))
+ self.assertEqual(alignment(SI), max(alignment(X), alignment(Y)))
+ self.assertEqual(sizeof(IS), calcsize("3si 3s 0i"))
class XX(Structure):
_fields_ = [("a", X),
("b", X)]
- self.failUnlessEqual(alignment(XX), alignment(X))
- self.failUnlessEqual(sizeof(XX), calcsize("3s 3s 0s"))
+ self.assertEqual(alignment(XX), alignment(X))
+ self.assertEqual(sizeof(XX), calcsize("3s 3s 0s"))
def test_emtpy(self):
# I had problems with these
@@ -115,15 +115,15 @@
_fields_ = []
# Is this really the correct alignment, or should it be 0?
- self.failUnless(alignment(X) == alignment(Y) == 1)
- self.failUnless(sizeof(X) == sizeof(Y) == 0)
+ self.assertTrue(alignment(X) == alignment(Y) == 1)
+ self.assertTrue(sizeof(X) == sizeof(Y) == 0)
class XX(Structure):
_fields_ = [("a", X),
("b", X)]
- self.failUnlessEqual(alignment(XX), 1)
- self.failUnlessEqual(sizeof(XX), 0)
+ self.assertEqual(alignment(XX), 1)
+ self.assertEqual(sizeof(XX), 0)
def test_fields(self):
# test the offset and size attributes of Structure/Unoin fields.
@@ -131,11 +131,11 @@
_fields_ = [("x", c_int),
("y", c_char)]
- self.failUnlessEqual(X.x.offset, 0)
- self.failUnlessEqual(X.x.size, sizeof(c_int))
+ self.assertEqual(X.x.offset, 0)
+ self.assertEqual(X.x.size, sizeof(c_int))
- self.failUnlessEqual(X.y.offset, sizeof(c_int))
- self.failUnlessEqual(X.y.size, sizeof(c_char))
+ self.assertEqual(X.y.offset, sizeof(c_int))
+ self.assertEqual(X.y.size, sizeof(c_char))
# readonly
self.assertRaises((TypeError, AttributeError), setattr, X.x, "offset", 92)
@@ -145,11 +145,11 @@
_fields_ = [("x", c_int),
("y", c_char)]
- self.failUnlessEqual(X.x.offset, 0)
- self.failUnlessEqual(X.x.size, sizeof(c_int))
+ self.assertEqual(X.x.offset, 0)
+ self.assertEqual(X.x.size, sizeof(c_int))
- self.failUnlessEqual(X.y.offset, 0)
- self.failUnlessEqual(X.y.size, sizeof(c_char))
+ self.assertEqual(X.y.offset, 0)
+ self.assertEqual(X.y.size, sizeof(c_char))
# readonly
self.assertRaises((TypeError, AttributeError), setattr, X.x, "offset", 92)
@@ -164,22 +164,22 @@
("b", c_longlong)]
_pack_ = 1
- self.failUnlessEqual(sizeof(X), 9)
- self.failUnlessEqual(X.b.offset, 1)
+ self.assertEqual(sizeof(X), 9)
+ self.assertEqual(X.b.offset, 1)
class X(Structure):
_fields_ = [("a", c_byte),
("b", c_longlong)]
_pack_ = 2
- self.failUnlessEqual(sizeof(X), 10)
- self.failUnlessEqual(X.b.offset, 2)
+ self.assertEqual(sizeof(X), 10)
+ self.assertEqual(X.b.offset, 2)
class X(Structure):
_fields_ = [("a", c_byte),
("b", c_longlong)]
_pack_ = 4
- self.failUnlessEqual(sizeof(X), 12)
- self.failUnlessEqual(X.b.offset, 4)
+ self.assertEqual(sizeof(X), 12)
+ self.assertEqual(X.b.offset, 4)
import struct
longlong_size = struct.calcsize("q")
@@ -190,8 +190,8 @@
("b", c_longlong)]
_pack_ = 8
- self.failUnlessEqual(sizeof(X), longlong_align + longlong_size)
- self.failUnlessEqual(X.b.offset, min(8, longlong_align))
+ self.assertEqual(sizeof(X), longlong_align + longlong_size)
+ self.assertEqual(X.b.offset, min(8, longlong_align))
d = {"_fields_": [("a", "b"),
@@ -209,9 +209,9 @@
self.assertRaises(TypeError, Person, "Name", "HI")
# short enough
- self.failUnlessEqual(Person("12345", 5).name, "12345")
+ self.assertEqual(Person("12345", 5).name, "12345")
# exact fit
- self.failUnlessEqual(Person("123456", 5).name, "123456")
+ self.assertEqual(Person("123456", 5).name, "123456")
# too long
self.assertRaises(ValueError, Person, "1234567", 5)
@@ -229,10 +229,10 @@
class POINT(Structure):
_fields_ = [("x", c_int), ("y", c_int)]
pt = POINT(1, 2)
- self.failUnlessEqual((pt.x, pt.y), (1, 2))
+ self.assertEqual((pt.x, pt.y), (1, 2))
pt = POINT(y=2, x=1)
- self.failUnlessEqual((pt.x, pt.y), (1, 2))
+ self.assertEqual((pt.x, pt.y), (1, 2))
def test_invalid_field_types(self):
class POINT(Structure):
@@ -244,14 +244,14 @@
_fields_ = [("a", c_int * 4)]
# can use tuple to initialize array (but not list!)
- self.failUnlessEqual(SomeInts((1, 2)).a[:], [1, 2, 0, 0])
- self.failUnlessEqual(SomeInts((1, 2)).a[::], [1, 2, 0, 0])
- self.failUnlessEqual(SomeInts((1, 2)).a[::-1], [0, 0, 2, 1])
- self.failUnlessEqual(SomeInts((1, 2)).a[::2], [1, 0])
- self.failUnlessEqual(SomeInts((1, 2)).a[1:5:6], [2])
- self.failUnlessEqual(SomeInts((1, 2)).a[6:4:-1], [])
- self.failUnlessEqual(SomeInts((1, 2, 3, 4)).a[:], [1, 2, 3, 4])
- self.failUnlessEqual(SomeInts((1, 2, 3, 4)).a[::], [1, 2, 3, 4])
+ self.assertEqual(SomeInts((1, 2)).a[:], [1, 2, 0, 0])
+ self.assertEqual(SomeInts((1, 2)).a[::], [1, 2, 0, 0])
+ self.assertEqual(SomeInts((1, 2)).a[::-1], [0, 0, 2, 1])
+ self.assertEqual(SomeInts((1, 2)).a[::2], [1, 0])
+ self.assertEqual(SomeInts((1, 2)).a[1:5:6], [2])
+ self.assertEqual(SomeInts((1, 2)).a[6:4:-1], [])
+ self.assertEqual(SomeInts((1, 2, 3, 4)).a[:], [1, 2, 3, 4])
+ self.assertEqual(SomeInts((1, 2, 3, 4)).a[::], [1, 2, 3, 4])
# too long
# XXX Should raise ValueError?, not RuntimeError
self.assertRaises(RuntimeError, SomeInts, (1, 2, 3, 4, 5))
@@ -269,10 +269,10 @@
p = Person("Someone", ("1234", "5678"), 5)
- self.failUnlessEqual(p.name, "Someone")
- self.failUnlessEqual(p.phone.areacode, "1234")
- self.failUnlessEqual(p.phone.number, "5678")
- self.failUnlessEqual(p.age, 5)
+ self.assertEqual(p.name, "Someone")
+ self.assertEqual(p.phone.areacode, "1234")
+ self.assertEqual(p.phone.number, "5678")
+ self.assertEqual(p.age, 5)
def test_structures_with_wchar(self):
try:
@@ -285,12 +285,12 @@
("age", c_int)]
p = PersonW("Someone")
- self.failUnlessEqual(p.name, "Someone")
+ self.assertEqual(p.name, "Someone")
- self.failUnlessEqual(PersonW("1234567890").name, "1234567890")
- self.failUnlessEqual(PersonW("12345678901").name, "12345678901")
+ self.assertEqual(PersonW("1234567890").name, "1234567890")
+ self.assertEqual(PersonW("12345678901").name, "12345678901")
# exact fit
- self.failUnlessEqual(PersonW("123456789012").name, "123456789012")
+ self.assertEqual(PersonW("123456789012").name, "123456789012")
#too long
self.assertRaises(ValueError, PersonW, "1234567890123")
@@ -305,18 +305,18 @@
("age", c_int)]
cls, msg = self.get_except(Person, "Someone", (1, 2))
- self.failUnlessEqual(cls, RuntimeError)
- self.failUnlessEqual(msg,
+ self.assertEqual(cls, RuntimeError)
+ self.assertEqual(msg,
"(Phone) <class 'TypeError'>: "
"expected string, int found")
cls, msg = self.get_except(Person, "Someone", ("a", "b", "c"))
- self.failUnlessEqual(cls, RuntimeError)
+ self.assertEqual(cls, RuntimeError)
if issubclass(Exception, object):
- self.failUnlessEqual(msg,
+ self.assertEqual(msg,
"(Phone) <class 'TypeError'>: too many initializers")
else:
- self.failUnlessEqual(msg, "(Phone) TypeError: too many initializers")
+ self.assertEqual(msg, "(Phone) TypeError: too many initializers")
def get_except(self, func, *args):
@@ -331,7 +331,7 @@
## # same as 'class X(Structure): pass'
## # fails, since we need either a _fields_ or a _abstract_ attribute
## cls, msg = self.get_except(meta, "X", (Structure,), {})
-## self.failUnlessEqual((cls, msg),
+## self.assertEqual((cls, msg),
## (AttributeError, "class must define a '_fields_' attribute"))
def test_abstract_class(self):
@@ -339,15 +339,15 @@
_abstract_ = "something"
# try 'X()'
cls, msg = self.get_except(eval, "X()", locals())
- self.failUnlessEqual((cls, msg), (TypeError, "abstract class"))
+ self.assertEqual((cls, msg), (TypeError, "abstract class"))
def test_methods(self):
## class X(Structure):
## _fields_ = []
- self.failUnless("in_dll" in dir(type(Structure)))
- self.failUnless("from_address" in dir(type(Structure)))
- self.failUnless("in_dll" in dir(type(Structure)))
+ self.assertTrue("in_dll" in dir(type(Structure)))
+ self.assertTrue("from_address" in dir(type(Structure)))
+ self.assertTrue("in_dll" in dir(type(Structure)))
class PointerMemberTestCase(unittest.TestCase):
@@ -360,7 +360,7 @@
# We can assign arrays of the correct type
s.array = (c_int * 3)(1, 2, 3)
items = [s.array[i] for i in range(3)]
- self.failUnlessEqual(items, [1, 2, 3])
+ self.assertEqual(items, [1, 2, 3])
# The following are bugs, but are included here because the unittests
# also describe the current behaviour.
@@ -371,14 +371,14 @@
s.array[0] = 42
items = [s.array[i] for i in range(3)]
- self.failUnlessEqual(items, [42, 2, 3])
+ self.assertEqual(items, [42, 2, 3])
s.array[0] = 1
## s.array[1] = 42
items = [s.array[i] for i in range(3)]
- self.failUnlessEqual(items, [1, 2, 3])
+ self.assertEqual(items, [1, 2, 3])
def test_none_to_pointer_fields(self):
class S(Structure):
@@ -388,7 +388,7 @@
s = S()
s.x = 12345678
s.p = None
- self.failUnlessEqual(s.x, 12345678)
+ self.assertEqual(s.x, 12345678)
class TestRecursiveStructure(unittest.TestCase):
def test_contains_itself(self):
@@ -398,7 +398,7 @@
try:
Recursive._fields_ = [("next", Recursive)]
except AttributeError as details:
- self.failUnless("Structure or union cannot contain itself" in
+ self.assertTrue("Structure or union cannot contain itself" in
str(details))
else:
self.fail("Structure or union cannot contain itself")
@@ -415,7 +415,7 @@
try:
Second._fields_ = [("first", First)]
except AttributeError as details:
- self.failUnless("_fields_ is final" in
+ self.assertTrue("_fields_ is final" in
str(details))
else:
self.fail("AttributeError not raised")
Modified: python/branches/py3k/Lib/ctypes/test/test_unaligned_structures.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_unaligned_structures.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_unaligned_structures.py Wed Jul 1 01:06:06 2009
@@ -28,18 +28,18 @@
def test_native(self):
for typ in structures:
## print typ.value
- self.failUnlessEqual(typ.value.offset, 1)
+ self.assertEqual(typ.value.offset, 1)
o = typ()
o.value = 4
- self.failUnlessEqual(o.value, 4)
+ self.assertEqual(o.value, 4)
def test_swapped(self):
for typ in byteswapped_structures:
## print >> sys.stderr, typ.value
- self.failUnlessEqual(typ.value.offset, 1)
+ self.assertEqual(typ.value.offset, 1)
o = typ()
o.value = 4
- self.failUnlessEqual(o.value, 4)
+ self.assertEqual(o.value, 4)
if __name__ == '__main__':
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_unicode.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_unicode.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_unicode.py Wed Jul 1 01:06:06 2009
@@ -22,55 +22,55 @@
def test_ascii_strict(self):
ctypes.set_conversion_mode("ascii", "strict")
# no conversions take place with unicode arguments
- self.failUnlessEqual(wcslen("abc"), 3)
- self.failUnlessEqual(wcslen("ab\u2070"), 3)
+ self.assertEqual(wcslen("abc"), 3)
+ self.assertEqual(wcslen("ab\u2070"), 3)
# string args are converted
- self.failUnlessEqual(wcslen("abc"), 3)
- self.failUnlessRaises(ctypes.ArgumentError, wcslen, b"ab\xe4")
+ self.assertEqual(wcslen("abc"), 3)
+ self.assertRaises(ctypes.ArgumentError, wcslen, b"ab\xe4")
def test_ascii_replace(self):
ctypes.set_conversion_mode("ascii", "replace")
- self.failUnlessEqual(wcslen("abc"), 3)
- self.failUnlessEqual(wcslen("ab\u2070"), 3)
- self.failUnlessEqual(wcslen("abc"), 3)
- self.failUnlessEqual(wcslen("ab\xe4"), 3)
+ self.assertEqual(wcslen("abc"), 3)
+ self.assertEqual(wcslen("ab\u2070"), 3)
+ self.assertEqual(wcslen("abc"), 3)
+ self.assertEqual(wcslen("ab\xe4"), 3)
def test_ascii_ignore(self):
ctypes.set_conversion_mode("ascii", "ignore")
- self.failUnlessEqual(wcslen("abc"), 3)
- self.failUnlessEqual(wcslen("ab\u2070"), 3)
+ self.assertEqual(wcslen("abc"), 3)
+ self.assertEqual(wcslen("ab\u2070"), 3)
# ignore error mode skips non-ascii characters
- self.failUnlessEqual(wcslen("abc"), 3)
- self.failUnlessEqual(wcslen(b"\xe4\xf6\xfc\xdf"), 0)
+ self.assertEqual(wcslen("abc"), 3)
+ self.assertEqual(wcslen(b"\xe4\xf6\xfc\xdf"), 0)
def test_latin1_strict(self):
ctypes.set_conversion_mode("latin-1", "strict")
- self.failUnlessEqual(wcslen("abc"), 3)
- self.failUnlessEqual(wcslen("ab\u2070"), 3)
- self.failUnlessEqual(wcslen("abc"), 3)
- self.failUnlessEqual(wcslen("\xe4\xf6\xfc\xdf"), 4)
+ self.assertEqual(wcslen("abc"), 3)
+ self.assertEqual(wcslen("ab\u2070"), 3)
+ self.assertEqual(wcslen("abc"), 3)
+ self.assertEqual(wcslen("\xe4\xf6\xfc\xdf"), 4)
def test_buffers(self):
ctypes.set_conversion_mode("ascii", "strict")
buf = ctypes.create_unicode_buffer("abc")
- self.failUnlessEqual(len(buf), 3+1)
+ self.assertEqual(len(buf), 3+1)
ctypes.set_conversion_mode("ascii", "replace")
buf = ctypes.create_unicode_buffer(b"ab\xe4\xf6\xfc")
- self.failUnlessEqual(buf[:], "ab\uFFFD\uFFFD\uFFFD\0")
- self.failUnlessEqual(buf[::], "ab\uFFFD\uFFFD\uFFFD\0")
- self.failUnlessEqual(buf[::-1], "\0\uFFFD\uFFFD\uFFFDba")
- self.failUnlessEqual(buf[::2], "a\uFFFD\uFFFD")
- self.failUnlessEqual(buf[6:5:-1], "")
+ self.assertEqual(buf[:], "ab\uFFFD\uFFFD\uFFFD\0")
+ self.assertEqual(buf[::], "ab\uFFFD\uFFFD\uFFFD\0")
+ self.assertEqual(buf[::-1], "\0\uFFFD\uFFFD\uFFFDba")
+ self.assertEqual(buf[::2], "a\uFFFD\uFFFD")
+ self.assertEqual(buf[6:5:-1], "")
ctypes.set_conversion_mode("ascii", "ignore")
buf = ctypes.create_unicode_buffer(b"ab\xe4\xf6\xfc")
# is that correct? not sure. But with 'ignore', you get what you pay for..
- self.failUnlessEqual(buf[:], "ab\0\0\0\0")
- self.failUnlessEqual(buf[::], "ab\0\0\0\0")
- self.failUnlessEqual(buf[::-1], "\0\0\0\0ba")
- self.failUnlessEqual(buf[::2], "a\0\0")
- self.failUnlessEqual(buf[6:5:-1], "")
+ self.assertEqual(buf[:], "ab\0\0\0\0")
+ self.assertEqual(buf[::], "ab\0\0\0\0")
+ self.assertEqual(buf[::-1], "\0\0\0\0ba")
+ self.assertEqual(buf[::2], "a\0\0")
+ self.assertEqual(buf[6:5:-1], "")
import _ctypes_test
func = ctypes.CDLL(_ctypes_test.__file__)._testfunc_p_p
@@ -88,41 +88,41 @@
def test_ascii_replace(self):
ctypes.set_conversion_mode("ascii", "strict")
- self.failUnlessEqual(func("abc"), "abc")
- self.failUnlessEqual(func("abc"), "abc")
+ self.assertEqual(func("abc"), "abc")
+ self.assertEqual(func("abc"), "abc")
self.assertRaises(ctypes.ArgumentError, func, "ab\xe4")
def test_ascii_ignore(self):
ctypes.set_conversion_mode("ascii", "ignore")
- self.failUnlessEqual(func("abc"), "abc")
- self.failUnlessEqual(func("abc"), "abc")
- self.failUnlessEqual(func("\xe4\xf6\xfc\xdf"), "")
+ self.assertEqual(func("abc"), "abc")
+ self.assertEqual(func("abc"), "abc")
+ self.assertEqual(func("\xe4\xf6\xfc\xdf"), "")
def test_ascii_replace(self):
ctypes.set_conversion_mode("ascii", "replace")
- self.failUnlessEqual(func("abc"), "abc")
- self.failUnlessEqual(func("abc"), "abc")
- self.failUnlessEqual(func("\xe4\xf6\xfc\xdf"), "????")
+ self.assertEqual(func("abc"), "abc")
+ self.assertEqual(func("abc"), "abc")
+ self.assertEqual(func("\xe4\xf6\xfc\xdf"), "????")
def test_buffers(self):
ctypes.set_conversion_mode("ascii", "strict")
buf = ctypes.create_string_buffer("abc")
- self.failUnlessEqual(len(buf), 3+1)
+ self.assertEqual(len(buf), 3+1)
ctypes.set_conversion_mode("ascii", "replace")
buf = ctypes.create_string_buffer("ab\xe4\xf6\xfc")
- self.failUnlessEqual(buf[:], b"ab???\0")
- self.failUnlessEqual(buf[::], b"ab???\0")
- self.failUnlessEqual(buf[::-1], b"\0???ba")
- self.failUnlessEqual(buf[::2], b"a??")
- self.failUnlessEqual(buf[6:5:-1], b"")
+ self.assertEqual(buf[:], b"ab???\0")
+ self.assertEqual(buf[::], b"ab???\0")
+ self.assertEqual(buf[::-1], b"\0???ba")
+ self.assertEqual(buf[::2], b"a??")
+ self.assertEqual(buf[6:5:-1], b"")
ctypes.set_conversion_mode("ascii", "ignore")
buf = ctypes.create_string_buffer("ab\xe4\xf6\xfc")
# is that correct? not sure. But with 'ignore', you get what you pay for..
- self.failUnlessEqual(buf[:], b"ab\0\0\0\0")
- self.failUnlessEqual(buf[::], b"ab\0\0\0\0")
- self.failUnlessEqual(buf[::-1], b"\0\0\0\0ba")
+ self.assertEqual(buf[:], b"ab\0\0\0\0")
+ self.assertEqual(buf[::], b"ab\0\0\0\0")
+ self.assertEqual(buf[::-1], b"\0\0\0\0ba")
if __name__ == '__main__':
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_values.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_values.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_values.py Wed Jul 1 01:06:06 2009
@@ -15,13 +15,13 @@
ctdll = CDLL(_ctypes_test.__file__)
an_integer = c_int.in_dll(ctdll, "an_integer")
x = an_integer.value
- self.failUnlessEqual(x, ctdll.get_an_integer())
+ self.assertEqual(x, ctdll.get_an_integer())
an_integer.value *= 2
- self.failUnlessEqual(x*2, ctdll.get_an_integer())
+ self.assertEqual(x*2, ctdll.get_an_integer())
# To avoid test failures when this test is repeated several
# times the original value must be restored
an_integer.value = x
- self.failUnlessEqual(x, ctdll.get_an_integer())
+ self.assertEqual(x, ctdll.get_an_integer())
def test_undefined(self):
ctdll = CDLL(_ctypes_test.__file__)
@@ -40,11 +40,11 @@
# docstrings are also removed in the latter case.
opt = c_int.in_dll(pydll, "Py_OptimizeFlag").value
if __debug__:
- self.failUnlessEqual(opt, 0)
+ self.assertEqual(opt, 0)
elif ValuesTestCase.__doc__ is not None:
- self.failUnlessEqual(opt, 1)
+ self.assertEqual(opt, 1)
else:
- self.failUnlessEqual(opt, 2)
+ self.assertEqual(opt, 2)
def test_frozentable(self):
# Python exports a PyImport_FrozenModules symbol. This is a
@@ -76,7 +76,7 @@
expected = [("__hello__", 104), ("__phello__", -104), ("__phello__.spam", 104)]
else:
expected = [("__hello__", 100), ("__phello__", -100), ("__phello__.spam", 100)]
- self.failUnlessEqual(items, expected)
+ self.assertEqual(items, expected)
from ctypes import _pointer_type_cache
del _pointer_type_cache[struct_frozen]
Modified: python/branches/py3k/Lib/ctypes/test/test_varsize_struct.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_varsize_struct.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_varsize_struct.py Wed Jul 1 01:06:06 2009
@@ -7,44 +7,44 @@
_fields_ = [("item", c_int),
("array", c_int * 1)]
- self.failUnlessEqual(sizeof(X), sizeof(c_int) * 2)
+ self.assertEqual(sizeof(X), sizeof(c_int) * 2)
x = X()
x.item = 42
x.array[0] = 100
- self.failUnlessEqual(sizeof(x), sizeof(c_int) * 2)
+ self.assertEqual(sizeof(x), sizeof(c_int) * 2)
# make room for one additional item
new_size = sizeof(X) + sizeof(c_int) * 1
resize(x, new_size)
- self.failUnlessEqual(sizeof(x), new_size)
- self.failUnlessEqual((x.item, x.array[0]), (42, 100))
+ self.assertEqual(sizeof(x), new_size)
+ self.assertEqual((x.item, x.array[0]), (42, 100))
# make room for 10 additional items
new_size = sizeof(X) + sizeof(c_int) * 9
resize(x, new_size)
- self.failUnlessEqual(sizeof(x), new_size)
- self.failUnlessEqual((x.item, x.array[0]), (42, 100))
+ self.assertEqual(sizeof(x), new_size)
+ self.assertEqual((x.item, x.array[0]), (42, 100))
# make room for one additional item
new_size = sizeof(X) + sizeof(c_int) * 1
resize(x, new_size)
- self.failUnlessEqual(sizeof(x), new_size)
- self.failUnlessEqual((x.item, x.array[0]), (42, 100))
+ self.assertEqual(sizeof(x), new_size)
+ self.assertEqual((x.item, x.array[0]), (42, 100))
def test_array_invalid_length(self):
# cannot create arrays with non-positive size
- self.failUnlessRaises(ValueError, lambda: c_int * -1)
- self.failUnlessRaises(ValueError, lambda: c_int * -3)
+ self.assertRaises(ValueError, lambda: c_int * -1)
+ self.assertRaises(ValueError, lambda: c_int * -3)
def test_zerosized_array(self):
array = (c_int * 0)()
# accessing elements of zero-sized arrays raise IndexError
- self.failUnlessRaises(IndexError, array.__setitem__, 0, None)
- self.failUnlessRaises(IndexError, array.__getitem__, 0)
- self.failUnlessRaises(IndexError, array.__setitem__, 1, None)
- self.failUnlessRaises(IndexError, array.__getitem__, 1)
- self.failUnlessRaises(IndexError, array.__setitem__, -1, None)
- self.failUnlessRaises(IndexError, array.__getitem__, -1)
+ self.assertRaises(IndexError, array.__setitem__, 0, None)
+ self.assertRaises(IndexError, array.__getitem__, 0)
+ self.assertRaises(IndexError, array.__setitem__, 1, None)
+ self.assertRaises(IndexError, array.__getitem__, 1)
+ self.assertRaises(IndexError, array.__setitem__, -1, None)
+ self.assertRaises(IndexError, array.__getitem__, -1)
if __name__ == "__main__":
unittest.main()
Modified: python/branches/py3k/Lib/ctypes/test/test_win32.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_win32.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_win32.py Wed Jul 1 01:06:06 2009
@@ -18,7 +18,7 @@
self.assertRaises(ValueError, IsWindow)
# This one should succeeed...
- self.failUnlessEqual(0, IsWindow(0))
+ self.assertEqual(0, IsWindow(0))
# ValueError: Procedure probably called with too many arguments (8 bytes in excess)
self.assertRaises(ValueError, IsWindow, 0, 0, 0)
@@ -49,13 +49,13 @@
class TestWintypes(unittest.TestCase):
def test_HWND(self):
from ctypes import wintypes
- self.failUnlessEqual(sizeof(wintypes.HWND), sizeof(c_void_p))
+ self.assertEqual(sizeof(wintypes.HWND), sizeof(c_void_p))
def test_PARAM(self):
from ctypes import wintypes
- self.failUnlessEqual(sizeof(wintypes.WPARAM),
+ self.assertEqual(sizeof(wintypes.WPARAM),
sizeof(c_void_p))
- self.failUnlessEqual(sizeof(wintypes.LPARAM),
+ self.assertEqual(sizeof(wintypes.LPARAM),
sizeof(c_void_p))
def test_COMError(self):
@@ -84,7 +84,7 @@
pt = POINT(10, 10)
rect = RECT(0, 0, 20, 20)
- self.failUnlessEqual(1, dll.PointInRect(byref(rect), pt))
+ self.assertEqual(1, dll.PointInRect(byref(rect), pt))
if __name__ == '__main__':
unittest.main()
Modified: python/branches/py3k/Lib/distutils/tests/test_archive_util.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_archive_util.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_archive_util.py Wed Jul 1 01:06:06 2009
@@ -47,7 +47,7 @@
# check if the compressed tarball was created
tarball = base_name + '.tar.gz'
- self.assert_(os.path.exists(tarball))
+ self.assertTrue(os.path.exists(tarball))
# trying an uncompressed one
base_name = os.path.join(tmpdir2, 'archive')
@@ -58,7 +58,7 @@
finally:
os.chdir(old_dir)
tarball = base_name + '.tar'
- self.assert_(os.path.exists(tarball))
+ self.assertTrue(os.path.exists(tarball))
def _tarinfo(self, path):
tar = tarfile.open(path)
@@ -96,7 +96,7 @@
# check if the compressed tarball was created
tarball = base_name + '.tar.gz'
- self.assert_(os.path.exists(tarball))
+ self.assertTrue(os.path.exists(tarball))
# now create another tarball using `tar`
tarball2 = os.path.join(tmpdir, 'archive2.tar.gz')
@@ -110,7 +110,7 @@
finally:
os.chdir(old_dir)
- self.assert_(os.path.exists(tarball2))
+ self.assertTrue(os.path.exists(tarball2))
# let's compare both tarballs
self.assertEquals(self._tarinfo(tarball), self._tarinfo(tarball2))
@@ -123,7 +123,7 @@
finally:
os.chdir(old_dir)
tarball = base_name + '.tar'
- self.assert_(os.path.exists(tarball))
+ self.assertTrue(os.path.exists(tarball))
# now for a dry_run
base_name = os.path.join(tmpdir2, 'archive')
@@ -134,7 +134,7 @@
finally:
os.chdir(old_dir)
tarball = base_name + '.tar'
- self.assert_(os.path.exists(tarball))
+ self.assertTrue(os.path.exists(tarball))
@unittest.skipUnless(find_executable('compress'),
'The compress program is required')
@@ -151,7 +151,7 @@
finally:
os.chdir(old_dir)
tarball = base_name + '.tar.Z'
- self.assert_(os.path.exists(tarball))
+ self.assertTrue(os.path.exists(tarball))
self.assertEquals(len(w.warnings), 1)
# same test with dry_run
@@ -165,7 +165,7 @@
dry_run=True)
finally:
os.chdir(old_dir)
- self.assert_(not os.path.exists(tarball))
+ self.assertTrue(not os.path.exists(tarball))
self.assertEquals(len(w.warnings), 1)
@unittest.skipUnless(ZIP_SUPPORT, 'Need zip support to run')
Modified: python/branches/py3k/Lib/distutils/tests/test_bdist_rpm.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_bdist_rpm.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_bdist_rpm.py Wed Jul 1 01:06:06 2009
@@ -74,7 +74,7 @@
cmd.run()
dist_created = os.listdir(os.path.join(pkg_dir, 'dist'))
- self.assert_('foo-0.1-1.noarch.rpm' in dist_created)
+ self.assertTrue('foo-0.1-1.noarch.rpm' in dist_created)
def test_no_optimize_flag(self):
@@ -114,7 +114,7 @@
cmd.run()
dist_created = os.listdir(os.path.join(pkg_dir, 'dist'))
- self.assert_('foo-0.1-1.noarch.rpm' in dist_created)
+ self.assertTrue('foo-0.1-1.noarch.rpm' in dist_created)
os.remove(os.path.join(pkg_dir, 'dist', 'foo-0.1-1.noarch.rpm'))
def test_suite():
Modified: python/branches/py3k/Lib/distutils/tests/test_bdist_wininst.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_bdist_wininst.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_bdist_wininst.py Wed Jul 1 01:06:06 2009
@@ -21,7 +21,7 @@
# and make sure it finds it and returns its content
# no matter what platform we have
exe_file = cmd.get_exe_bytes()
- self.assert_(len(exe_file) > 10)
+ self.assertTrue(len(exe_file) > 10)
def test_suite():
return unittest.makeSuite(BuildWinInstTestCase)
Modified: python/branches/py3k/Lib/distutils/tests/test_build_clib.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_build_clib.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_build_clib.py Wed Jul 1 01:06:06 2009
@@ -135,7 +135,7 @@
cmd.run()
# let's check the result
- self.assert_('libfoo.a' in os.listdir(build_temp))
+ self.assertTrue('libfoo.a' in os.listdir(build_temp))
def test_suite():
return unittest.makeSuite(BuildCLibTestCase)
Modified: python/branches/py3k/Lib/distutils/tests/test_build_ext.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_build_ext.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_build_ext.py Wed Jul 1 01:06:06 2009
@@ -74,15 +74,15 @@
import xx
for attr in ('error', 'foo', 'new', 'roj'):
- self.assert_(hasattr(xx, attr))
+ self.assertTrue(hasattr(xx, attr))
self.assertEquals(xx.foo(2, 5), 7)
self.assertEquals(xx.foo(13,15), 28)
self.assertEquals(xx.new().demo(), None)
doc = 'This is a template module just for instruction.'
self.assertEquals(xx.__doc__, doc)
- self.assert_(isinstance(xx.Null(), xx.Null))
- self.assert_(isinstance(xx.Str(), xx.Str))
+ self.assertTrue(isinstance(xx.Null(), xx.Null))
+ self.assertTrue(isinstance(xx.Str(), xx.Str))
def tearDown(self):
# Get everything back to normal
@@ -114,7 +114,7 @@
_config_vars['Py_ENABLE_SHARED'] = old_var
# make sure we get some library dirs under solaris
- self.assert_(len(cmd.library_dirs) > 0)
+ self.assertTrue(len(cmd.library_dirs) > 0)
def test_user_site(self):
# site.USER_SITE was introduced in 2.6
@@ -128,7 +128,7 @@
# making sure the user option is there
options = [name for name, short, lable in
cmd.user_options]
- self.assert_('user' in options)
+ self.assertTrue('user' in options)
# setting a value
cmd.user = 1
@@ -144,9 +144,9 @@
# see if include_dirs and library_dirs
# were set
- self.assert_(lib in cmd.library_dirs)
- self.assert_(lib in cmd.rpath)
- self.assert_(incl in cmd.include_dirs)
+ self.assertTrue(lib in cmd.library_dirs)
+ self.assertTrue(lib in cmd.rpath)
+ self.assertTrue(incl in cmd.include_dirs)
def test_optional_extension(self):
@@ -175,10 +175,10 @@
from distutils import sysconfig
py_include = sysconfig.get_python_inc()
- self.assert_(py_include in cmd.include_dirs)
+ self.assertTrue(py_include in cmd.include_dirs)
plat_py_include = sysconfig.get_python_inc(plat_specific=1)
- self.assert_(plat_py_include in cmd.include_dirs)
+ self.assertTrue(plat_py_include in cmd.include_dirs)
# make sure cmd.libraries is turned into a list
# if it's a string
@@ -192,7 +192,7 @@
cmd = build_ext(dist)
cmd.library_dirs = 'my_lib_dir'
cmd.finalize_options()
- self.assert_('my_lib_dir' in cmd.library_dirs)
+ self.assertTrue('my_lib_dir' in cmd.library_dirs)
# make sure rpath is turned into a list
# if it's a list of os.pathsep's paths
@@ -257,13 +257,13 @@
'some': 'bar'})]
cmd.check_extensions_list(exts)
ext = exts[0]
- self.assert_(isinstance(ext, Extension))
+ self.assertTrue(isinstance(ext, Extension))
# check_extensions_list adds in ext the values passed
# when they are in ('include_dirs', 'library_dirs', 'libraries'
# 'extra_objects', 'extra_compile_args', 'extra_link_args')
self.assertEquals(ext.libraries, 'foo')
- self.assert_(not hasattr(ext, 'some'))
+ self.assertTrue(not hasattr(ext, 'some'))
# 'macros' element of build info dict must be 1- or 2-tuple
exts = [('foo.bar', {'sources': [''], 'libraries': 'foo',
@@ -321,7 +321,7 @@
so_file = cmd.get_outputs()[0]
finally:
os.chdir(old_wd)
- self.assert_(os.path.exists(so_file))
+ self.assertTrue(os.path.exists(so_file))
self.assertEquals(os.path.splitext(so_file)[-1],
sysconfig.get_config_var('SO'))
so_dir = os.path.dirname(so_file)
@@ -330,7 +330,7 @@
cmd.inplace = 0
cmd.run()
so_file = cmd.get_outputs()[0]
- self.assert_(os.path.exists(so_file))
+ self.assertTrue(os.path.exists(so_file))
self.assertEquals(os.path.splitext(so_file)[-1],
sysconfig.get_config_var('SO'))
so_dir = os.path.dirname(so_file)
Modified: python/branches/py3k/Lib/distutils/tests/test_build_py.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_build_py.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_build_py.py Wed Jul 1 01:06:06 2009
@@ -52,9 +52,9 @@
self.assertEqual(len(cmd.get_outputs()), 3)
pkgdest = os.path.join(destination, "pkg")
files = os.listdir(pkgdest)
- self.assert_("__init__.py" in files)
- self.assert_("__init__.pyc" in files)
- self.assert_("README.txt" in files)
+ self.assertTrue("__init__.py" in files)
+ self.assertTrue("__init__.pyc" in files)
+ self.assertTrue("README.txt" in files)
def test_empty_package_dir (self):
# See SF 1668596/1720897.
Modified: python/branches/py3k/Lib/distutils/tests/test_build_scripts.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_build_scripts.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_build_scripts.py Wed Jul 1 01:06:06 2009
@@ -16,12 +16,12 @@
def test_default_settings(self):
cmd = self.get_build_scripts_cmd("/foo/bar", [])
- self.assert_(not cmd.force)
- self.assert_(cmd.build_dir is None)
+ self.assertTrue(not cmd.force)
+ self.assertTrue(cmd.build_dir is None)
cmd.finalize_options()
- self.assert_(cmd.force)
+ self.assertTrue(cmd.force)
self.assertEqual(cmd.build_dir, "/foo/bar")
def test_build(self):
@@ -37,7 +37,7 @@
built = os.listdir(target)
for name in expected:
- self.assert_(name in built)
+ self.assertTrue(name in built)
def get_build_scripts_cmd(self, target, scripts):
import sys
@@ -100,7 +100,7 @@
built = os.listdir(target)
for name in expected:
- self.assert_(name in built)
+ self.assertTrue(name in built)
def test_suite():
return unittest.makeSuite(BuildScriptsTestCase)
Modified: python/branches/py3k/Lib/distutils/tests/test_clean.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_clean.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_clean.py Wed Jul 1 01:06:06 2009
@@ -35,7 +35,7 @@
# make sure the files where removed
for name, path in dirs:
- self.assert_(not os.path.exists(path),
+ self.assertTrue(not os.path.exists(path),
'%s was not removed' % path)
# let's run the command again (should spit warnings but suceed)
Modified: python/branches/py3k/Lib/distutils/tests/test_cmd.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_cmd.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_cmd.py Wed Jul 1 01:06:06 2009
@@ -70,7 +70,7 @@
cmd.option2 = None
cmd.ensure_string('option2', 'xxx')
- self.assert_(hasattr(cmd, 'option2'))
+ self.assertTrue(hasattr(cmd, 'option2'))
cmd.option3 = 1
self.assertRaises(DistutilsOptionError, cmd.ensure_string, 'option3')
Modified: python/branches/py3k/Lib/distutils/tests/test_config.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_config.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_config.py Wed Jul 1 01:06:06 2009
@@ -102,9 +102,9 @@
def test_server_empty_registration(self):
cmd = self._cmd(self.dist)
rc = cmd._get_rc_file()
- self.assert_(not os.path.exists(rc))
+ self.assertTrue(not os.path.exists(rc))
cmd._store_pypirc('tarek', 'xxx')
- self.assert_(os.path.exists(rc))
+ self.assertTrue(os.path.exists(rc))
content = open(rc).read()
self.assertEquals(content, WANTED)
Modified: python/branches/py3k/Lib/distutils/tests/test_config_cmd.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_config_cmd.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_config_cmd.py Wed Jul 1 01:06:06 2009
@@ -73,14 +73,14 @@
self.write_file(f2, 'xxx')
for f in (f1, f2):
- self.assert_(os.path.exists(f))
+ self.assertTrue(os.path.exists(f))
pkg_dir, dist = self.create_dist()
cmd = config(dist)
cmd._clean(f1, f2)
for f in (f1, f2):
- self.assert_(not os.path.exists(f))
+ self.assertTrue(not os.path.exists(f))
def test_suite():
return unittest.makeSuite(ConfigTestCase)
Modified: python/branches/py3k/Lib/distutils/tests/test_dist.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_dist.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_dist.py Wed Jul 1 01:06:06 2009
@@ -72,7 +72,7 @@
self.assertEqual(d.get_command_packages(),
["distutils.command", "foo.bar", "distutils.tests"])
cmd = d.get_command_obj("test_dist")
- self.assert_(isinstance(cmd, test_dist))
+ self.assertTrue(isinstance(cmd, test_dist))
self.assertEqual(cmd.sample_option, "sometext")
def test_command_packages_configfile(self):
@@ -175,10 +175,10 @@
"version": "1.0"}
dist = Distribution(attrs)
meta = self.format_metadata(dist)
- self.assert_("Metadata-Version: 1.0" in meta)
- self.assert_("provides:" not in meta.lower())
- self.assert_("requires:" not in meta.lower())
- self.assert_("obsoletes:" not in meta.lower())
+ self.assertTrue("Metadata-Version: 1.0" in meta)
+ self.assertTrue("provides:" not in meta.lower())
+ self.assertTrue("requires:" not in meta.lower())
+ self.assertTrue("obsoletes:" not in meta.lower())
def test_provides(self):
attrs = {"name": "package",
@@ -190,9 +190,9 @@
self.assertEqual(dist.get_provides(),
["package", "package.sub"])
meta = self.format_metadata(dist)
- self.assert_("Metadata-Version: 1.1" in meta)
- self.assert_("requires:" not in meta.lower())
- self.assert_("obsoletes:" not in meta.lower())
+ self.assertTrue("Metadata-Version: 1.1" in meta)
+ self.assertTrue("requires:" not in meta.lower())
+ self.assertTrue("obsoletes:" not in meta.lower())
def test_provides_illegal(self):
self.assertRaises(ValueError, Distribution,
@@ -210,11 +210,11 @@
self.assertEqual(dist.get_requires(),
["other", "another (==1.0)"])
meta = self.format_metadata(dist)
- self.assert_("Metadata-Version: 1.1" in meta)
- self.assert_("provides:" not in meta.lower())
- self.assert_("Requires: other" in meta)
- self.assert_("Requires: another (==1.0)" in meta)
- self.assert_("obsoletes:" not in meta.lower())
+ self.assertTrue("Metadata-Version: 1.1" in meta)
+ self.assertTrue("provides:" not in meta.lower())
+ self.assertTrue("Requires: other" in meta)
+ self.assertTrue("Requires: another (==1.0)" in meta)
+ self.assertTrue("obsoletes:" not in meta.lower())
def test_requires_illegal(self):
self.assertRaises(ValueError, Distribution,
@@ -232,11 +232,11 @@
self.assertEqual(dist.get_obsoletes(),
["other", "another (<1.0)"])
meta = self.format_metadata(dist)
- self.assert_("Metadata-Version: 1.1" in meta)
- self.assert_("provides:" not in meta.lower())
- self.assert_("requires:" not in meta.lower())
- self.assert_("Obsoletes: other" in meta)
- self.assert_("Obsoletes: another (<1.0)" in meta)
+ self.assertTrue("Metadata-Version: 1.1" in meta)
+ self.assertTrue("provides:" not in meta.lower())
+ self.assertTrue("requires:" not in meta.lower())
+ self.assertTrue("Obsoletes: other" in meta)
+ self.assertTrue("Obsoletes: another (<1.0)" in meta)
def test_obsoletes_illegal(self):
self.assertRaises(ValueError, Distribution,
@@ -270,14 +270,14 @@
if sys.platform in ('linux', 'darwin'):
self.environ['HOME'] = temp_dir
files = dist.find_config_files()
- self.assert_(user_filename in files)
+ self.assertTrue(user_filename in files)
# win32-style
if sys.platform == 'win32':
# home drive should be found
self.environ['HOME'] = temp_dir
files = dist.find_config_files()
- self.assert_(user_filename in files,
+ self.assertTrue(user_filename in files,
'%r not found in %r' % (user_filename, files))
finally:
os.remove(user_filename)
@@ -303,7 +303,7 @@
output = [line for line in s.getvalue().split('\n')
if line.strip() != '']
- self.assert_(len(output) > 0)
+ self.assertTrue(len(output) > 0)
def test_suite():
suite = unittest.TestSuite()
Modified: python/branches/py3k/Lib/distutils/tests/test_install.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_install.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_install.py Wed Jul 1 01:06:06 2009
@@ -88,7 +88,7 @@
def _test_user_site(self):
for key in ('nt_user', 'unix_user', 'os2_home'):
- self.assert_(key in INSTALL_SCHEMES)
+ self.assertTrue(key in INSTALL_SCHEMES)
dist = Distribution({'name': 'xx'})
cmd = install(dist)
@@ -96,24 +96,24 @@
# making sure the user option is there
options = [name for name, short, lable in
cmd.user_options]
- self.assert_('user' in options)
+ self.assertTrue('user' in options)
# setting a value
cmd.user = 1
# user base and site shouldn't be created yet
- self.assert_(not os.path.exists(self.user_base))
- self.assert_(not os.path.exists(self.user_site))
+ self.assertTrue(not os.path.exists(self.user_base))
+ self.assertTrue(not os.path.exists(self.user_site))
# let's run finalize
cmd.ensure_finalized()
# now they should
- self.assert_(os.path.exists(self.user_base))
- self.assert_(os.path.exists(self.user_site))
+ self.assertTrue(os.path.exists(self.user_base))
+ self.assertTrue(os.path.exists(self.user_site))
- self.assert_('userbase' in cmd.config_vars)
- self.assert_('usersite' in cmd.config_vars)
+ self.assertTrue('userbase' in cmd.config_vars)
+ self.assertTrue('usersite' in cmd.config_vars)
def test_handle_extra_path(self):
dist = Distribution({'name': 'xx', 'extra_path': 'path,dirs'})
Modified: python/branches/py3k/Lib/distutils/tests/test_install_data.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_install_data.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_install_data.py Wed Jul 1 01:06:06 2009
@@ -35,9 +35,9 @@
# let's check the result
self.assertEquals(len(cmd.get_outputs()), 2)
rtwo = os.path.split(two)[-1]
- self.assert_(os.path.exists(os.path.join(inst2, rtwo)))
+ self.assertTrue(os.path.exists(os.path.join(inst2, rtwo)))
rone = os.path.split(one)[-1]
- self.assert_(os.path.exists(os.path.join(inst, rone)))
+ self.assertTrue(os.path.exists(os.path.join(inst, rone)))
cmd.outfiles = []
# let's try with warn_dir one
@@ -47,8 +47,8 @@
# let's check the result
self.assertEquals(len(cmd.get_outputs()), 2)
- self.assert_(os.path.exists(os.path.join(inst2, rtwo)))
- self.assert_(os.path.exists(os.path.join(inst, rone)))
+ self.assertTrue(os.path.exists(os.path.join(inst2, rtwo)))
+ self.assertTrue(os.path.exists(os.path.join(inst, rone)))
cmd.outfiles = []
# now using root and empty dir
@@ -65,8 +65,8 @@
# let's check the result
self.assertEquals(len(cmd.get_outputs()), 4)
- self.assert_(os.path.exists(os.path.join(inst2, rtwo)))
- self.assert_(os.path.exists(os.path.join(inst, rone)))
+ self.assertTrue(os.path.exists(os.path.join(inst2, rtwo)))
+ self.assertTrue(os.path.exists(os.path.join(inst, rone)))
def test_suite():
return unittest.makeSuite(InstallDataTestCase)
Modified: python/branches/py3k/Lib/distutils/tests/test_install_lib.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_install_lib.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_install_lib.py Wed Jul 1 01:06:06 2009
@@ -39,8 +39,8 @@
f = os.path.join(pkg_dir, 'foo.py')
self.write_file(f, '# python file')
cmd.byte_compile([f])
- self.assert_(os.path.exists(os.path.join(pkg_dir, 'foo.pyc')))
- self.assert_(os.path.exists(os.path.join(pkg_dir, 'foo.pyo')))
+ self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyc')))
+ self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyo')))
def test_get_outputs(self):
pkg_dir, dist = self.create_dist()
@@ -57,7 +57,7 @@
cmd.distribution.script_name = 'setup.py'
# get_output should return 4 elements
- self.assert_(len(cmd.get_outputs()) >= 2)
+ self.assertTrue(len(cmd.get_outputs()) >= 2)
def test_get_inputs(self):
pkg_dir, dist = self.create_dist()
Modified: python/branches/py3k/Lib/distutils/tests/test_install_scripts.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_install_scripts.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_install_scripts.py Wed Jul 1 01:06:06 2009
@@ -23,15 +23,15 @@
skip_build=1,
)
cmd = install_scripts(dist)
- self.assert_(not cmd.force)
- self.assert_(not cmd.skip_build)
- self.assert_(cmd.build_dir is None)
- self.assert_(cmd.install_dir is None)
+ self.assertTrue(not cmd.force)
+ self.assertTrue(not cmd.skip_build)
+ self.assertTrue(cmd.build_dir is None)
+ self.assertTrue(cmd.install_dir is None)
cmd.finalize_options()
- self.assert_(cmd.force)
- self.assert_(cmd.skip_build)
+ self.assertTrue(cmd.force)
+ self.assertTrue(cmd.skip_build)
self.assertEqual(cmd.build_dir, "/foo/bar")
self.assertEqual(cmd.install_dir, "/splat/funk")
@@ -69,7 +69,7 @@
installed = os.listdir(target)
for name in expected:
- self.assert_(name in installed)
+ self.assertTrue(name in installed)
def test_suite():
Modified: python/branches/py3k/Lib/distutils/tests/test_msvc9compiler.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_msvc9compiler.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_msvc9compiler.py Wed Jul 1 01:06:06 2009
@@ -46,7 +46,7 @@
# windows registeries versions.
path = r'Software\Microsoft\Notepad'
v = Reg.get_value(path, "lfitalic")
- self.assert_(v in (0, 1))
+ self.assertTrue(v in (0, 1))
import winreg
HKCU = winreg.HKEY_CURRENT_USER
@@ -54,7 +54,7 @@
self.assertEquals(keys, None)
keys = Reg.read_keys(HKCU, r'Software\Microsoft')
- self.assert_('Notepad' in keys)
+ self.assertTrue('Notepad' in keys)
def test_suite():
return unittest.makeSuite(msvc9compilerTestCase)
Modified: python/branches/py3k/Lib/distutils/tests/test_register.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_register.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_register.py Wed Jul 1 01:06:06 2009
@@ -96,7 +96,7 @@
cmd = self._get_cmd()
# we shouldn't have a .pypirc file yet
- self.assert_(not os.path.exists(self.rc))
+ self.assertTrue(not os.path.exists(self.rc))
# patching input and getpass.getpass
# so register gets happy
@@ -115,7 +115,7 @@
del register_module.input
# we should have a brand new .pypirc file
- self.assert_(os.path.exists(self.rc))
+ self.assertTrue(os.path.exists(self.rc))
# with the content similar to WANTED_PYPIRC
content = open(self.rc).read()
@@ -133,13 +133,13 @@
# let's see what the server received : we should
# have 2 similar requests
- self.assert_(self.conn.reqs, 2)
+ self.assertTrue(self.conn.reqs, 2)
req1 = dict(self.conn.reqs[0].headers)
req2 = dict(self.conn.reqs[1].headers)
self.assertEquals(req1['Content-length'], '1374')
self.assertEquals(req2['Content-length'], '1374')
- self.assert_((b'xxx') in self.conn.reqs[1].data)
+ self.assertTrue((b'xxx') in self.conn.reqs[1].data)
def test_password_not_in_file(self):
@@ -165,11 +165,11 @@
del register_module.input
# we should have send a request
- self.assert_(self.conn.reqs, 1)
+ self.assertTrue(self.conn.reqs, 1)
req = self.conn.reqs[0]
headers = dict(req.headers)
self.assertEquals(headers['Content-length'], '608')
- self.assert_((b'tarek') in req.data)
+ self.assertTrue((b'tarek') in req.data)
def test_password_reset(self):
# this test runs choice 3
@@ -183,11 +183,11 @@
del register_module.input
# we should have send a request
- self.assert_(self.conn.reqs, 1)
+ self.assertTrue(self.conn.reqs, 1)
req = self.conn.reqs[0]
headers = dict(req.headers)
self.assertEquals(headers['Content-length'], '290')
- self.assert_((b'tarek') in req.data)
+ self.assertTrue((b'tarek') in req.data)
def test_strict(self):
# testing the script option
Modified: python/branches/py3k/Lib/distutils/tests/test_sysconfig.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_sysconfig.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_sysconfig.py Wed Jul 1 01:06:06 2009
@@ -21,12 +21,12 @@
def test_get_config_h_filename(self):
config_h = sysconfig.get_config_h_filename()
- self.assert_(os.path.isfile(config_h), config_h)
+ self.assertTrue(os.path.isfile(config_h), config_h)
def test_get_python_lib(self):
lib_dir = sysconfig.get_python_lib()
# XXX doesn't work on Linux when Python was never installed before
- #self.assert_(os.path.isdir(lib_dir), lib_dir)
+ #self.assertTrue(os.path.isdir(lib_dir), lib_dir)
# test for pythonxx.lib?
self.assertNotEqual(sysconfig.get_python_lib(),
sysconfig.get_python_lib(prefix=TESTFN))
@@ -36,14 +36,14 @@
# This is not much of a test. We make sure Python.h exists
# in the directory returned by get_python_inc() but we don't know
# it is the correct file.
- self.assert_(os.path.isdir(inc_dir), inc_dir)
+ self.assertTrue(os.path.isdir(inc_dir), inc_dir)
python_h = os.path.join(inc_dir, "Python.h")
- self.assert_(os.path.isfile(python_h), python_h)
+ self.assertTrue(os.path.isfile(python_h), python_h)
def test_get_config_vars(self):
cvars = sysconfig.get_config_vars()
- self.assert_(isinstance(cvars, dict))
- self.assert_(cvars)
+ self.assertTrue(isinstance(cvars, dict))
+ self.assertTrue(cvars)
def test_customize_compiler(self):
Modified: python/branches/py3k/Lib/distutils/tests/test_upload.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_upload.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_upload.py Wed Jul 1 01:06:06 2009
@@ -96,11 +96,11 @@
# what did we send ?
headers = dict(self.last_open.req.headers)
self.assertEquals(headers['Content-length'], '2087')
- self.assert_(headers['Content-type'].startswith('multipart/form-data'))
+ self.assertTrue(headers['Content-type'].startswith('multipart/form-data'))
self.assertEquals(self.last_open.req.get_method(), 'POST')
self.assertEquals(self.last_open.req.get_full_url(),
'http://pypi.python.org/pypi')
- self.assert_(b'xxx' in self.last_open.req.data)
+ self.assertTrue(b'xxx' in self.last_open.req.data)
def test_suite():
return unittest.makeSuite(uploadTestCase)
Modified: python/branches/py3k/Lib/distutils/tests/test_util.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_util.py (original)
+++ python/branches/py3k/Lib/distutils/tests/test_util.py Wed Jul 1 01:06:06 2009
@@ -225,10 +225,10 @@
no = ('n', 'no', 'f', 'false', 'off', '0', 'Off', 'No', 'N')
for y in yes:
- self.assert_(strtobool(y))
+ self.assertTrue(strtobool(y))
for n in no:
- self.assert_(not strtobool(n))
+ self.assertTrue(not strtobool(n))
def test_rfc822_escape(self):
header = 'I am a\npoor\nlonesome\nheader\n'
Modified: python/branches/py3k/Lib/email/test/test_email.py
==============================================================================
--- python/branches/py3k/Lib/email/test/test_email.py (original)
+++ python/branches/py3k/Lib/email/test/test_email.py Wed Jul 1 01:06:06 2009
@@ -53,7 +53,7 @@
# Base test class
class TestEmailBase(unittest.TestCase):
def ndiffAssertEqual(self, first, second):
- """Like failUnlessEqual except use ndiff for readable output."""
+ """Like assertEqual except use ndiff for readable output."""
if first != second:
sfirst = str(first)
ssecond = str(second)
@@ -222,12 +222,12 @@
msg['From'] = 'Me'
msg['to'] = 'You'
# Check for case insensitivity
- self.failUnless('from' in msg)
- self.failUnless('From' in msg)
- self.failUnless('FROM' in msg)
- self.failUnless('to' in msg)
- self.failUnless('To' in msg)
- self.failUnless('TO' in msg)
+ self.assertTrue('from' in msg)
+ self.assertTrue('From' in msg)
+ self.assertTrue('FROM' in msg)
+ self.assertTrue('to' in msg)
+ self.assertTrue('To' in msg)
+ self.assertTrue('TO' in msg)
def test_as_string(self):
eq = self.ndiffAssertEqual
@@ -237,7 +237,7 @@
eq(text, str(msg))
fullrepr = msg.as_string(unixfrom=True)
lines = fullrepr.split('\n')
- self.failUnless(lines[0].startswith('From '))
+ self.assertTrue(lines[0].startswith('From '))
eq(text, NL.join(lines[1:]))
def test_bad_param(self):
@@ -307,12 +307,12 @@
'"Jim&&Jill"')
def test_field_containment(self):
- unless = self.failUnless
+ unless = self.assertTrue
msg = email.message_from_string('Header: exists')
unless('header' in msg)
unless('Header' in msg)
unless('HEADER' in msg)
- self.failIf('headerx' in msg)
+ self.assertFalse('headerx' in msg)
def test_set_param(self):
eq = self.assertEqual
@@ -952,7 +952,7 @@
def test_add_header(self):
eq = self.assertEqual
- unless = self.failUnless
+ unless = self.assertTrue
self._au.add_header('Content-Disposition', 'attachment',
filename='audiotest.au')
eq(self._au['content-disposition'],
@@ -992,7 +992,7 @@
def test_add_header(self):
eq = self.assertEqual
- unless = self.failUnless
+ unless = self.assertTrue
self._im.add_header('Content-Disposition', 'attachment',
filename='dingusfish.gif')
eq(self._im['content-disposition'],
@@ -1036,7 +1036,7 @@
def test_types(self):
eq = self.assertEqual
- unless = self.failUnless
+ unless = self.assertTrue
eq(self._msg.get_content_type(), 'text/plain')
eq(self._msg.get_param('charset'), 'us-ascii')
missing = []
@@ -1046,7 +1046,7 @@
def test_payload(self):
self.assertEqual(self._msg.get_payload(), 'hello there')
- self.failUnless(not self._msg.is_multipart())
+ self.assertTrue(not self._msg.is_multipart())
def test_charset(self):
eq = self.assertEqual
@@ -1097,7 +1097,7 @@
def test_hierarchy(self):
# convenience
eq = self.assertEqual
- unless = self.failUnless
+ unless = self.assertTrue
raises = self.assertRaises
# tests
m = self._msg
@@ -1411,7 +1411,7 @@
-- XXXX--
''')
- self.failUnless(msg.is_multipart())
+ self.assertTrue(msg.is_multipart())
eq(msg.get_boundary(), ' XXXX')
eq(len(msg.get_payload()), 2)
@@ -1441,7 +1441,7 @@
eq(msg.get_content_subtype(), 'plain')
def test_same_boundary_inner_outer(self):
- unless = self.failUnless
+ unless = self.assertTrue
msg = self._msgobj('msg_15.txt')
# XXX We can probably eventually do better
inner = msg.get_payload(0)
@@ -1451,7 +1451,7 @@
errors.StartBoundaryNotFoundDefect))
def test_multipart_no_boundary(self):
- unless = self.failUnless
+ unless = self.assertTrue
msg = self._msgobj('msg_25.txt')
unless(isinstance(msg.get_payload(), str))
self.assertEqual(len(msg.defects), 2)
@@ -1509,7 +1509,7 @@
""")
def test_lying_multipart(self):
- unless = self.failUnless
+ unless = self.assertTrue
msg = self._msgobj('msg_41.txt')
unless(hasattr(msg, 'defects'))
self.assertEqual(len(msg.defects), 2)
@@ -1529,7 +1529,7 @@
# [*] This message is missing its start boundary
bad = outer.get_payload(1).get_payload(0)
self.assertEqual(len(bad.defects), 1)
- self.failUnless(isinstance(bad.defects[0],
+ self.assertTrue(isinstance(bad.defects[0],
errors.StartBoundaryNotFoundDefect))
def test_first_line_is_continuation_header(self):
@@ -1539,7 +1539,7 @@
eq(msg.keys(), [])
eq(msg.get_payload(), 'Line 2\nLine 3')
eq(len(msg.defects), 1)
- self.failUnless(isinstance(msg.defects[0],
+ self.assertTrue(isinstance(msg.defects[0],
errors.FirstHeaderLineIsContinuationDefect))
eq(msg.defects[0].line, ' Line 1\n')
@@ -1607,7 +1607,7 @@
def test_valid_argument(self):
eq = self.assertEqual
- unless = self.failUnless
+ unless = self.assertTrue
subject = 'A sub-message'
m = Message()
m['Subject'] = subject
@@ -1651,20 +1651,20 @@
def test_parse_message_rfc822(self):
eq = self.assertEqual
- unless = self.failUnless
+ unless = self.assertTrue
msg = self._msgobj('msg_11.txt')
eq(msg.get_content_type(), 'message/rfc822')
payload = msg.get_payload()
unless(isinstance(payload, list))
eq(len(payload), 1)
submsg = payload[0]
- self.failUnless(isinstance(submsg, Message))
+ self.assertTrue(isinstance(submsg, Message))
eq(submsg['subject'], 'An enclosed message')
eq(submsg.get_payload(), 'Here is the body of the message.\n')
def test_dsn(self):
eq = self.assertEqual
- unless = self.failUnless
+ unless = self.assertTrue
# msg 16 is a Delivery Status Notification, see RFC 1894
msg = self._msgobj('msg_16.txt')
eq(msg.get_content_type(), 'multipart/report')
@@ -2002,7 +2002,7 @@
def test_content_type(self):
eq = self.assertEquals
- unless = self.failUnless
+ unless = self.assertTrue
# Get a message object and reset the seek pointer for other tests
msg, text = self._msgobj('msg_05.txt')
eq(msg.get_content_type(), 'multipart/report')
@@ -2024,7 +2024,7 @@
eq(msg2.get_payload(), 'Yadda yadda yadda\n')
msg3 = msg.get_payload(2)
eq(msg3.get_content_type(), 'message/rfc822')
- self.failUnless(isinstance(msg3, Message))
+ self.assertTrue(isinstance(msg3, Message))
payload = msg3.get_payload()
unless(isinstance(payload, list))
eq(len(payload), 1)
@@ -2034,7 +2034,7 @@
def test_parser(self):
eq = self.assertEquals
- unless = self.failUnless
+ unless = self.assertTrue
msg, text = self._msgobj('msg_06.txt')
# Check some of the outer headers
eq(msg.get_content_type(), 'message/rfc822')
@@ -2044,9 +2044,9 @@
unless(isinstance(payload, list))
eq(len(payload), 1)
msg1 = payload[0]
- self.failUnless(isinstance(msg1, Message))
+ self.assertTrue(isinstance(msg1, Message))
eq(msg1.get_content_type(), 'text/plain')
- self.failUnless(isinstance(msg1.get_payload(), str))
+ self.assertTrue(isinstance(msg1.get_payload(), str))
eq(msg1.get_payload(), '\n')
@@ -2077,7 +2077,7 @@
self.assertEqual(text, s.getvalue())
def test_message_from_string_with_class(self):
- unless = self.failUnless
+ unless = self.assertTrue
with openfile('msg_01.txt') as fp:
text = fp.read()
@@ -2095,7 +2095,7 @@
unless(isinstance(subpart, MyMessage))
def test_message_from_file_with_class(self):
- unless = self.failUnless
+ unless = self.assertTrue
# Create a subclass
class MyMessage(Message):
pass
@@ -2217,7 +2217,7 @@
def test_charset_richcomparisons(self):
eq = self.assertEqual
- ne = self.failIfEqual
+ ne = self.assertNotEqual
cset1 = Charset()
cset2 = Charset()
eq(cset1, 'us-ascii')
@@ -2410,8 +2410,8 @@
eq(msg['from'], 'ppp-request(a)zzz.org')
eq(msg['to'], 'ppp(a)zzz.org')
eq(msg.get_content_type(), 'multipart/mixed')
- self.failIf(msg.is_multipart())
- self.failUnless(isinstance(msg.get_payload(), str))
+ self.assertFalse(msg.is_multipart())
+ self.assertTrue(isinstance(msg.get_payload(), str))
def test_whitespace_continuation(self):
eq = self.assertEqual
@@ -2613,18 +2613,18 @@
def test_quopri_header_check(self):
for c in self.hlit:
- self.failIf(quoprimime.header_check(c),
+ self.assertFalse(quoprimime.header_check(c),
'Should not be header quopri encoded: %s' % chr(c))
for c in self.hnon:
- self.failUnless(quoprimime.header_check(c),
+ self.assertTrue(quoprimime.header_check(c),
'Should be header quopri encoded: %s' % chr(c))
def test_quopri_body_check(self):
for c in self.blit:
- self.failIf(quoprimime.body_check(c),
+ self.assertFalse(quoprimime.body_check(c),
'Should not be body quopri encoded: %s' % chr(c))
for c in self.bnon:
- self.failUnless(quoprimime.body_check(c),
+ self.assertTrue(quoprimime.body_check(c),
'Should be body quopri encoded: %s' % chr(c))
def test_header_quopri_len(self):
@@ -2789,7 +2789,7 @@
h = Header("I am the very model of a modern Major-General; I've information vegetable, animal, and mineral; I know the kings of England, and I quote the fights historical from Marathon to Waterloo, in order categorical; I'm very well acquainted, too, with matters mathematical; I understand equations, both the simple and quadratical; about binomial theorem I'm teeming with a lot o' news, with many cheerful facts about the square of the hypotenuse.",
maxlinelen=76)
for l in h.encode(splitchars=' ').split('\n '):
- self.failUnless(len(l) <= 76)
+ self.assertTrue(len(l) <= 76)
def test_multilingual(self):
eq = self.ndiffAssertEqual
@@ -3166,7 +3166,7 @@
'''
msg = email.message_from_string(m)
param = msg.get_param('NAME')
- self.failIf(isinstance(param, tuple))
+ self.assertFalse(isinstance(param, tuple))
self.assertEqual(
param,
'file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htm')
@@ -3319,7 +3319,7 @@
"""
msg = email.message_from_string(m)
param = msg.get_param('name')
- self.failIf(isinstance(param, tuple))
+ self.assertFalse(isinstance(param, tuple))
self.assertEqual(param, "Frank's Document")
def test_rfc2231_tick_attack_extended(self):
@@ -3343,7 +3343,7 @@
"""
msg = email.message_from_string(m)
param = msg.get_param('name')
- self.failIf(isinstance(param, tuple))
+ self.assertFalse(isinstance(param, tuple))
self.assertEqual(param, "us-ascii'en-us'Frank's Document")
def test_rfc2231_no_extended_values(self):
Modified: python/branches/py3k/Lib/importlib/test/builtin/test_finder.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/builtin/test_finder.py (original)
+++ python/branches/py3k/Lib/importlib/test/builtin/test_finder.py Wed Jul 1 01:06:06 2009
@@ -14,7 +14,7 @@
# Common case.
with util.uncache(builtin_util.NAME):
found = machinery.BuiltinImporter.find_module(builtin_util.NAME)
- self.assert_(found)
+ self.assertTrue(found)
def test_package(self):
# Built-in modules cannot be a package.
@@ -35,14 +35,14 @@
def test_failure(self):
assert 'importlib' not in sys.builtin_module_names
loader = machinery.BuiltinImporter.find_module('importlib')
- self.assert_(loader is None)
+ self.assertTrue(loader is None)
def test_ignore_path(self):
# The value for 'path' should always trigger a failed import.
with util.uncache(builtin_util.NAME):
loader = machinery.BuiltinImporter.find_module(builtin_util.NAME,
['pkg'])
- self.assert_(loader is None)
+ self.assertTrue(loader is None)
Modified: python/branches/py3k/Lib/importlib/test/builtin/test_loader.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/builtin/test_loader.py (original)
+++ python/branches/py3k/Lib/importlib/test/builtin/test_loader.py Wed Jul 1 01:06:06 2009
@@ -18,10 +18,10 @@
def verify(self, module):
"""Verify that the module matches against what it should have."""
- self.assert_(isinstance(module, types.ModuleType))
+ self.assertTrue(isinstance(module, types.ModuleType))
for attr, value in self.verification.items():
self.assertEqual(getattr(module, attr), value)
- self.assert_(module.__name__ in sys.modules)
+ self.assertTrue(module.__name__ in sys.modules)
load_module = staticmethod(lambda name:
machinery.BuiltinImporter.load_module(name))
@@ -49,7 +49,7 @@
with util.uncache(builtin_util.NAME):
module1 = self.load_module(builtin_util.NAME)
module2 = self.load_module(builtin_util.NAME)
- self.assert_(module1 is module2)
+ self.assertTrue(module1 is module2)
def test_unloadable(self):
name = 'dssdsdfff'
@@ -70,17 +70,17 @@
def test_get_code(self):
# There is no code object.
result = machinery.BuiltinImporter.get_code(builtin_util.NAME)
- self.assert_(result is None)
+ self.assertTrue(result is None)
def test_get_source(self):
# There is no source.
result = machinery.BuiltinImporter.get_source(builtin_util.NAME)
- self.assert_(result is None)
+ self.assertTrue(result is None)
def test_is_package(self):
# Cannot be a package.
result = machinery.BuiltinImporter.is_package(builtin_util.NAME)
- self.assert_(not result)
+ self.assertTrue(not result)
def test_not_builtin(self):
# Modules not built-in should raise ImportError.
Modified: python/branches/py3k/Lib/importlib/test/extension/test_finder.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/extension/test_finder.py (original)
+++ python/branches/py3k/Lib/importlib/test/extension/test_finder.py Wed Jul 1 01:06:06 2009
@@ -13,7 +13,7 @@
return importer.find_module(fullname)
def test_module(self):
- self.assert_(self.find_module(util.NAME))
+ self.assertTrue(self.find_module(util.NAME))
def test_package(self):
# Extension modules cannot be an __init__ for a package.
@@ -32,7 +32,7 @@
pass
def test_failure(self):
- self.assert_(self.find_module('asdfjkl;') is None)
+ self.assertTrue(self.find_module('asdfjkl;') is None)
# XXX Raise an exception if someone tries to use the 'path' argument?
Modified: python/branches/py3k/Lib/importlib/test/extension/test_loader.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/extension/test_loader.py (original)
+++ python/branches/py3k/Lib/importlib/test/extension/test_loader.py Wed Jul 1 01:06:06 2009
@@ -23,8 +23,8 @@
('__file__', ext_util.FILEPATH),
('__package__', '')]:
self.assertEqual(getattr(module, attr), value)
- self.assert_(ext_util.NAME in sys.modules)
- self.assert_(isinstance(module.__loader__,
+ self.assertTrue(ext_util.NAME in sys.modules)
+ self.assertTrue(isinstance(module.__loader__,
_bootstrap._ExtensionFileLoader))
def test_package(self):
@@ -39,7 +39,7 @@
with util.uncache(ext_util.NAME):
module1 = self.load_module(ext_util.NAME)
module2 = self.load_module(ext_util.NAME)
- self.assert_(module1 is module2)
+ self.assertTrue(module1 is module2)
def test_state_after_failure(self):
# No easy way to trigger a failure after a successful import.
Modified: python/branches/py3k/Lib/importlib/test/extension/test_path_hook.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/extension/test_path_hook.py (original)
+++ python/branches/py3k/Lib/importlib/test/extension/test_path_hook.py Wed Jul 1 01:06:06 2009
@@ -19,7 +19,7 @@
def test_success(self):
# Path hook should handle a directory where a known extension module
# exists.
- self.assert_(hasattr(self.hook(util.PATH), 'find_module'))
+ self.assertTrue(hasattr(self.hook(util.PATH), 'find_module'))
def test_main():
Modified: python/branches/py3k/Lib/importlib/test/frozen/test_finder.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/frozen/test_finder.py (original)
+++ python/branches/py3k/Lib/importlib/test/frozen/test_finder.py Wed Jul 1 01:06:06 2009
@@ -15,15 +15,15 @@
def test_module(self):
name = '__hello__'
loader = self.find(name)
- self.assert_(hasattr(loader, 'load_module'))
+ self.assertTrue(hasattr(loader, 'load_module'))
def test_package(self):
loader = self.find('__phello__')
- self.assert_(hasattr(loader, 'load_module'))
+ self.assertTrue(hasattr(loader, 'load_module'))
def test_module_in_package(self):
loader = self.find('__phello__.spam', ['__phello__'])
- self.assert_(hasattr(loader, 'load_module'))
+ self.assertTrue(hasattr(loader, 'load_module'))
def test_package_in_package(self):
# No frozen package within another package to test with.
@@ -35,7 +35,7 @@
def test_failure(self):
loader = self.find('<not real>')
- self.assert_(loader is None)
+ self.assertTrue(loader is None)
def test_main():
Modified: python/branches/py3k/Lib/importlib/test/frozen/test_loader.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/frozen/test_loader.py (original)
+++ python/branches/py3k/Lib/importlib/test/frozen/test_loader.py Wed Jul 1 01:06:06 2009
@@ -43,7 +43,7 @@
with util.uncache('__hello__'):
module1 = machinery.FrozenImporter.load_module('__hello__')
module2 = machinery.FrozenImporter.load_module('__hello__')
- self.assert_(module1 is module2)
+ self.assertTrue(module1 is module2)
def test_state_after_failure(self):
# No way to trigger an error in a frozen module.
@@ -65,12 +65,12 @@
code = machinery.FrozenImporter.get_code(name)
mod = imp.new_module(name)
exec(code, mod.__dict__)
- self.assert_(hasattr(mod, 'initialized'))
+ self.assertTrue(hasattr(mod, 'initialized'))
def test_get_source(self):
# Should always return None.
result = machinery.FrozenImporter.get_source('__hello__')
- self.assert_(result is None)
+ self.assertTrue(result is None)
def test_is_package(self):
# Should be able to tell what is a package.
@@ -78,7 +78,7 @@
('__phello__.spam', False))
for name, is_package in test_for:
result = machinery.FrozenImporter.is_package(name)
- self.assert_(bool(result) == is_package)
+ self.assertTrue(bool(result) == is_package)
def test_failure(self):
# Raise ImportError for modules that are not frozen.
Modified: python/branches/py3k/Lib/importlib/test/import_/test_caching.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/import_/test_caching.py (original)
+++ python/branches/py3k/Lib/importlib/test/import_/test_caching.py Wed Jul 1 01:06:06 2009
@@ -53,8 +53,8 @@
with self.create_mock('pkg.__init__', 'pkg.module') as importer:
with util.import_state(meta_path=[importer]):
module = import_util.import_('pkg.module')
- self.assert_(hasattr(module, 'module'))
- self.assert_(id(module.module), id(sys.modules['pkg.module']))
+ self.assertTrue(hasattr(module, 'module'))
+ self.assertTrue(id(module.module), id(sys.modules['pkg.module']))
# See test_using_cache_after_loader() for reasoning.
@import_util.importlib_only
@@ -63,7 +63,7 @@
with self.create_mock('pkg.__init__', 'pkg.module') as importer:
with util.import_state(meta_path=[importer]):
module = import_util.import_('pkg', fromlist=['module'])
- self.assert_(hasattr(module, 'module'))
+ self.assertTrue(hasattr(module, 'module'))
self.assertEquals(id(module.module),
id(sys.modules['pkg.module']))
Modified: python/branches/py3k/Lib/importlib/test/import_/test_fromlist.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/import_/test_fromlist.py (original)
+++ python/branches/py3k/Lib/importlib/test/import_/test_fromlist.py Wed Jul 1 01:06:06 2009
@@ -59,7 +59,7 @@
with util.import_state(meta_path=[importer]):
module = import_util.import_('module', fromlist=['non_existent'])
self.assertEquals(module.__name__, 'module')
- self.assert_(not hasattr(module, 'non_existent'))
+ self.assertTrue(not hasattr(module, 'non_existent'))
def test_module_from_package(self):
# [module]
@@ -67,7 +67,7 @@
with util.import_state(meta_path=[importer]):
module = import_util.import_('pkg', fromlist=['module'])
self.assertEquals(module.__name__, 'pkg')
- self.assert_(hasattr(module, 'module'))
+ self.assertTrue(hasattr(module, 'module'))
self.assertEquals(module.module.__name__, 'pkg.module')
def test_no_module_from_package(self):
@@ -76,7 +76,7 @@
with util.import_state(meta_path=[importer]):
module = import_util.import_('pkg', fromlist='non_existent')
self.assertEquals(module.__name__, 'pkg')
- self.assert_(not hasattr(module, 'non_existent'))
+ self.assertTrue(not hasattr(module, 'non_existent'))
def test_empty_string(self):
with util.mock_modules('pkg.__init__', 'pkg.mod') as importer:
@@ -91,7 +91,7 @@
mock['pkg'].__all__ = ['module']
module = import_util.import_('pkg', fromlist=['*'])
self.assertEquals(module.__name__, 'pkg')
- self.assert_(hasattr(module, 'module'))
+ self.assertTrue(hasattr(module, 'module'))
self.assertEqual(module.module.__name__, 'pkg.module')
def test_star_with_others(self):
@@ -102,8 +102,8 @@
mock['pkg'].__all__ = ['module1']
module = import_util.import_('pkg', fromlist=['module2', '*'])
self.assertEquals(module.__name__, 'pkg')
- self.assert_(hasattr(module, 'module1'))
- self.assert_(hasattr(module, 'module2'))
+ self.assertTrue(hasattr(module, 'module1'))
+ self.assertTrue(hasattr(module, 'module2'))
self.assertEquals(module.module1.__name__, 'pkg.module1')
self.assertEquals(module.module2.__name__, 'pkg.module2')
Modified: python/branches/py3k/Lib/importlib/test/import_/test_meta_path.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/import_/test_meta_path.py (original)
+++ python/branches/py3k/Lib/importlib/test/import_/test_meta_path.py Wed Jul 1 01:06:06 2009
@@ -64,7 +64,7 @@
self.assertEquals(len(args), 2)
self.assertEquals(len(kwargs), 0)
self.assertEquals(args[0], mod_name)
- self.assert_(args[1] is None)
+ self.assertTrue(args[1] is None)
def test_with_path(self):
# [path set]
@@ -82,9 +82,9 @@
args = log[1][0]
kwargs = log[1][1]
# Assuming all arguments are positional.
- self.assert_(not kwargs)
+ self.assertTrue(not kwargs)
self.assertEquals(args[0], mod_name)
- self.assert_(args[1] is path)
+ self.assertTrue(args[1] is path)
Modified: python/branches/py3k/Lib/importlib/test/import_/test_packages.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/import_/test_packages.py (original)
+++ python/branches/py3k/Lib/importlib/test/import_/test_packages.py Wed Jul 1 01:06:06 2009
@@ -13,7 +13,7 @@
with util.mock_modules('pkg.__init__', 'pkg.module') as mock:
with util.import_state(meta_path=[mock]):
module = import_util.import_('pkg.module')
- self.assert_('pkg' in sys.modules)
+ self.assertTrue('pkg' in sys.modules)
def test_bad_parent(self):
with util.mock_modules('pkg.module') as mock:
Modified: python/branches/py3k/Lib/importlib/test/import_/test_path.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/import_/test_path.py (original)
+++ python/branches/py3k/Lib/importlib/test/import_/test_path.py Wed Jul 1 01:06:06 2009
@@ -19,7 +19,7 @@
# Test None returned upon not finding a suitable finder.
module = '<test module>'
with util.import_state():
- self.assert_(machinery.PathFinder.find_module(module) is None)
+ self.assertTrue(machinery.PathFinder.find_module(module) is None)
def test_sys_path(self):
# Test that sys.path is used when 'path' is None.
@@ -30,7 +30,7 @@
with util.import_state(path_importer_cache={path: importer},
path=[path]):
loader = machinery.PathFinder.find_module(module)
- self.assert_(loader is importer)
+ self.assertTrue(loader is importer)
def test_path(self):
# Test that 'path' is used when set.
@@ -40,7 +40,7 @@
importer = util.mock_modules(module)
with util.import_state(path_importer_cache={path: importer}):
loader = machinery.PathFinder.find_module(module, [path])
- self.assert_(loader is importer)
+ self.assertTrue(loader is importer)
def test_path_hooks(self):
# Test that sys.path_hooks is used.
@@ -51,16 +51,16 @@
hook = import_util.mock_path_hook(path, importer=importer)
with util.import_state(path_hooks=[hook]):
loader = machinery.PathFinder.find_module(module, [path])
- self.assert_(loader is importer)
- self.assert_(path in sys.path_importer_cache)
- self.assert_(sys.path_importer_cache[path] is importer)
+ self.assertTrue(loader is importer)
+ self.assertTrue(path in sys.path_importer_cache)
+ self.assertTrue(sys.path_importer_cache[path] is importer)
def test_path_importer_cache_has_None(self):
# Test that if sys.path_importer_cache has None that None is returned.
clear_cache = {path: None for path in sys.path}
with util.import_state(path_importer_cache=clear_cache):
for name in ('asynchat', 'sys', '<test module>'):
- self.assert_(machinery.PathFinder.find_module(name) is None)
+ self.assertTrue(machinery.PathFinder.find_module(name) is None)
def test_path_importer_cache_has_None_continues(self):
# Test that having None in sys.path_importer_cache causes the search to
@@ -71,7 +71,7 @@
with util.import_state(path=['1', '2'],
path_importer_cache={'1': None, '2': importer}):
loader = machinery.PathFinder.find_module(module)
- self.assert_(loader is importer)
+ self.assertTrue(loader is importer)
@@ -88,15 +88,15 @@
with util.import_state():
nothing = _bootstrap._DefaultPathFinder.find_module(module,
path=[existing_path])
- self.assert_(nothing is None)
- self.assert_(existing_path in sys.path_importer_cache)
- self.assert_(not isinstance(sys.path_importer_cache[existing_path],
+ self.assertTrue(nothing is None)
+ self.assertTrue(existing_path in sys.path_importer_cache)
+ self.assertTrue(not isinstance(sys.path_importer_cache[existing_path],
imp.NullImporter))
nothing = _bootstrap._DefaultPathFinder.find_module(module,
path=[bad_path])
- self.assert_(nothing is None)
- self.assert_(bad_path in sys.path_importer_cache)
- self.assert_(isinstance(sys.path_importer_cache[bad_path],
+ self.assertTrue(nothing is None)
+ self.assertTrue(bad_path in sys.path_importer_cache)
+ self.assertTrue(isinstance(sys.path_importer_cache[bad_path],
imp.NullImporter))
def test_path_importer_cache_has_None(self):
@@ -113,7 +113,7 @@
with util.import_state(path_importer_cache={path: None}):
loader = _bootstrap._DefaultPathFinder.find_module(module,
path=[path])
- self.assert_(loader is importer)
+ self.assertTrue(loader is importer)
finally:
_bootstrap._DEFAULT_PATH_HOOK = original_hook
Modified: python/branches/py3k/Lib/importlib/test/import_/test_relative_imports.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/import_/test_relative_imports.py (original)
+++ python/branches/py3k/Lib/importlib/test/import_/test_relative_imports.py Wed Jul 1 01:06:06 2009
@@ -79,7 +79,7 @@
import_util.import_('pkg') # For __import__().
module = import_util.import_('', global_, fromlist=['mod2'], level=1)
self.assertEqual(module.__name__, 'pkg')
- self.assert_(hasattr(module, 'mod2'))
+ self.assertTrue(hasattr(module, 'mod2'))
self.assertEqual(module.mod2.attr, 'pkg.mod2')
self.relative_import_test(create, globals_, callback)
@@ -105,7 +105,7 @@
module = import_util.import_('', global_, fromlist=['module'],
level=1)
self.assertEqual(module.__name__, 'pkg')
- self.assert_(hasattr(module, 'module'))
+ self.assertTrue(hasattr(module, 'module'))
self.assertEqual(module.module.attr, 'pkg.module')
self.relative_import_test(create, globals_, callback)
@@ -129,7 +129,7 @@
module = import_util.import_('', global_, fromlist=['subpkg2'],
level=2)
self.assertEqual(module.__name__, 'pkg')
- self.assert_(hasattr(module, 'subpkg2'))
+ self.assertTrue(hasattr(module, 'subpkg2'))
self.assertEqual(module.subpkg2.attr, 'pkg.subpkg2.__init__')
def test_deep_import(self):
Modified: python/branches/py3k/Lib/importlib/test/source/test_abc_loader.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/source/test_abc_loader.py (original)
+++ python/branches/py3k/Lib/importlib/test/source/test_abc_loader.py Wed Jul 1 01:06:06 2009
@@ -133,10 +133,10 @@
mock = self.mocker({name: path})
with util.uncache(name):
module = mock.load_module(name)
- self.assert_(name in sys.modules)
+ self.assertTrue(name in sys.modules)
self.eq_attrs(module, __name__=name, __file__=path, __package__='',
__loader__=mock)
- self.assert_(not hasattr(module, '__path__'))
+ self.assertTrue(not hasattr(module, '__path__'))
return mock, name
def test_package(self):
@@ -145,7 +145,7 @@
mock = self.mocker({name: path})
with util.uncache(name):
module = mock.load_module(name)
- self.assert_(name in sys.modules)
+ self.assertTrue(name in sys.modules)
self.eq_attrs(module, __name__=name, __file__=path,
__path__=[os.path.dirname(path)], __package__=name,
__loader__=mock)
@@ -171,8 +171,8 @@
with util.uncache(name):
sys.modules[name] = module
loaded_module = mock.load_module(name)
- self.assert_(loaded_module is module)
- self.assert_(sys.modules[name] is module)
+ self.assertTrue(loaded_module is module)
+ self.assertTrue(sys.modules[name] is module)
return mock, name
def test_state_after_failure(self):
@@ -184,8 +184,8 @@
with util.uncache(name):
sys.modules[name] = module
self.assertRaises(ZeroDivisionError, mock.load_module, name)
- self.assert_(sys.modules[name] is module)
- self.assert_(hasattr(module, 'blah'))
+ self.assertTrue(sys.modules[name] is module)
+ self.assertTrue(hasattr(module, 'blah'))
return mock
def test_unloadable(self):
@@ -194,7 +194,7 @@
mock.source = b"1/0"
with util.uncache(name):
self.assertRaises(ZeroDivisionError, mock.load_module, name)
- self.assert_(name not in sys.modules)
+ self.assertTrue(name not in sys.modules)
return mock
@@ -293,7 +293,7 @@
sys.dont_write_bytecode = dont_write_bytecode
with util.uncache(name):
mock.load_module(name)
- self.assert_((name in mock.module_bytecode) is not
+ self.assertTrue((name in mock.module_bytecode) is not
dont_write_bytecode)
def test_no_bytecode_written(self):
@@ -319,7 +319,7 @@
'magic': bad_magic}})
with util.uncache(name):
mock.load_module(name)
- self.assert_(name in mock.module_bytecode)
+ self.assertTrue(name in mock.module_bytecode)
magic = mock.module_bytecode[name][:4]
self.assertEqual(magic, imp.get_magic())
@@ -332,7 +332,7 @@
{name: {'path': 'path/to/mod.bytecode', 'mtime': old_mtime}})
with util.uncache(name):
mock.load_module(name)
- self.assert_(name in mock.module_bytecode)
+ self.assertTrue(name in mock.module_bytecode)
mtime = importlib._r_long(mock.module_bytecode[name][4:8])
self.assertEqual(mtime, PyPycLoaderMock.default_mtime)
Modified: python/branches/py3k/Lib/importlib/test/source/test_file_loader.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/source/test_file_loader.py (original)
+++ python/branches/py3k/Lib/importlib/test/source/test_file_loader.py Wed Jul 1 01:06:06 2009
@@ -23,7 +23,7 @@
loader = _bootstrap._PyPycFileLoader('_temp', mapping['_temp'],
False)
module = loader.load_module('_temp')
- self.assert_('_temp' in sys.modules)
+ self.assertTrue('_temp' in sys.modules)
check = {'__name__': '_temp', '__file__': mapping['_temp'],
'__package__': ''}
for attr, value in check.items():
@@ -35,7 +35,7 @@
mapping['_pkg.__init__'],
True)
module = loader.load_module('_pkg')
- self.assert_('_pkg' in sys.modules)
+ self.assertTrue('_pkg' in sys.modules)
check = {'__name__': '_pkg', '__file__': mapping['_pkg.__init__'],
'__path__': [os.path.dirname(mapping['_pkg.__init__'])],
'__package__': '_pkg'}
@@ -48,7 +48,7 @@
loader = _bootstrap._PyPycFileLoader('_pkg.mod',
mapping['_pkg.mod'], False)
module = loader.load_module('_pkg.mod')
- self.assert_('_pkg.mod' in sys.modules)
+ self.assertTrue('_pkg.mod' in sys.modules)
check = {'__name__': '_pkg.mod', '__file__': mapping['_pkg.mod'],
'__package__': '_pkg'}
for attr, value in check.items():
@@ -73,7 +73,7 @@
# than the original mtime.
loader.source_mtime = self.fake_mtime(loader.source_mtime)
module = loader.load_module('_temp')
- self.assert_('testing_var' in module.__dict__,
+ self.assertTrue('testing_var' in module.__dict__,
"'testing_var' not in "
"{0}".format(list(module.__dict__.keys())))
self.assertEqual(module, sys.modules['_temp'])
@@ -105,7 +105,7 @@
loader = _bootstrap._PyPycFileLoader('_temp', mapping['_temp'],
False)
self.assertRaises(SyntaxError, loader.load_module, '_temp')
- self.assert_('_temp' not in sys.modules)
+ self.assertTrue('_temp' not in sys.modules)
class BadBytecodeTest(unittest.TestCase):
@@ -124,7 +124,7 @@
def import_(self, file, module_name):
loader = _bootstrap._PyPycFileLoader(module_name, file, False)
module = loader.load_module(module_name)
- self.assert_(module_name in sys.modules)
+ self.assertTrue(module_name in sys.modules)
# [bad magic]
@source_util.writes_bytecode_files
@@ -168,7 +168,7 @@
bytecode_file.write(b'AAAA')
self.assertRaises(ValueError, self.import_, mapping['_temp'],
'_temp')
- self.assert_('_temp' not in sys.modules)
+ self.assertTrue('_temp' not in sys.modules)
def test_main():
Modified: python/branches/py3k/Lib/importlib/test/source/test_finder.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/source/test_finder.py (original)
+++ python/branches/py3k/Lib/importlib/test/source/test_finder.py Wed Jul 1 01:06:06 2009
@@ -53,7 +53,7 @@
for name in unlink:
os.unlink(mapping[name])
loader = self.import_(mapping['.root'], test)
- self.assert_(hasattr(loader, 'load_module'))
+ self.assertTrue(hasattr(loader, 'load_module'))
return loader
def test_module(self):
@@ -79,7 +79,7 @@
with source_util.create_modules('pkg.__init__', 'pkg.sub') as mapping:
pkg_dir = os.path.dirname(mapping['pkg.__init__'])
loader = self.import_(pkg_dir, 'pkg.sub')
- self.assert_(hasattr(loader, 'load_module'))
+ self.assertTrue(hasattr(loader, 'load_module'))
# [sub package]
def test_package_in_package(self):
@@ -87,7 +87,7 @@
with context as mapping:
pkg_dir = os.path.dirname(mapping['pkg.__init__'])
loader = self.import_(pkg_dir, 'pkg.sub')
- self.assert_(hasattr(loader, 'load_module'))
+ self.assertTrue(hasattr(loader, 'load_module'))
# [sub empty]
def test_empty_sub_directory(self):
@@ -105,13 +105,13 @@
# XXX This is not a blackbox test!
name = '_temp'
loader = self.run_test(name, {'{0}.__init__'.format(name), name})
- self.assert_('__init__' in loader._base_path)
+ self.assertTrue('__init__' in loader._base_path)
def test_failure(self):
with source_util.create_modules('blah') as mapping:
nothing = self.import_(mapping['.root'], 'sdfsadsadf')
- self.assert_(nothing is None)
+ self.assertTrue(nothing is None)
# [empty dir]
def test_empty_dir(self):
Modified: python/branches/py3k/Lib/importlib/test/source/test_path_hook.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/source/test_path_hook.py (original)
+++ python/branches/py3k/Lib/importlib/test/source/test_path_hook.py Wed Jul 1 01:06:06 2009
@@ -10,7 +10,7 @@
def test_success(self):
# XXX Only work on existing directories?
with source_util.create_modules('dummy') as mapping:
- self.assert_(hasattr(_bootstrap._FileFinder(mapping['.root']),
+ self.assertTrue(hasattr(_bootstrap._FileFinder(mapping['.root']),
'find_module'))
Modified: python/branches/py3k/Lib/importlib/test/test_abc.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/test_abc.py (original)
+++ python/branches/py3k/Lib/importlib/test/test_abc.py Wed Jul 1 01:06:06 2009
@@ -11,7 +11,7 @@
def verify(self, ABC, *classes):
"""Verify the classes are subclasses of the ABC."""
for cls in classes:
- self.assert_(issubclass(cls, ABC))
+ self.assertTrue(issubclass(cls, ABC))
def test_Finder(self):
self.verify(abc.Finder, machinery.BuiltinImporter,
Modified: python/branches/py3k/Lib/importlib/test/test_util.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/test_util.py (original)
+++ python/branches/py3k/Lib/importlib/test/test_util.py Wed Jul 1 01:06:06 2009
@@ -29,8 +29,8 @@
module_name = 'a.b.c'
with test_util.uncache(module_name):
module = self.return_module(module_name)
- self.assert_(module_name in sys.modules)
- self.assert_(isinstance(module, types.ModuleType))
+ self.assertTrue(module_name in sys.modules)
+ self.assertTrue(isinstance(module, types.ModuleType))
self.assertEqual(module.__name__, module_name)
def test_reload(self):
@@ -40,7 +40,7 @@
with test_util.uncache(name):
sys.modules[name] = module
returned_module = self.return_module(name)
- self.assert_(sys.modules[name] is returned_module)
+ self.assertTrue(sys.modules[name] is returned_module)
def test_new_module_failure(self):
# Test that a module is removed from sys.modules if added but an
@@ -48,7 +48,7 @@
name = 'a.b.c'
with test_util.uncache(name):
self.raise_exception(name)
- self.assert_(name not in sys.modules)
+ self.assertTrue(name not in sys.modules)
def test_reload_failure(self):
# Test that a failure on reload leaves the module in-place.
@@ -57,7 +57,7 @@
with test_util.uncache(name):
sys.modules[name] = module
self.raise_exception(name)
- self.assert_(sys.modules[name] is module)
+ self.assertTrue(sys.modules[name] is module)
class SetPackageTests(unittest.TestCase):
@@ -71,7 +71,7 @@
fxn = lambda: module
wrapped = util.set_package(fxn)
wrapped()
- self.assert_(hasattr(module, '__package__'))
+ self.assertTrue(hasattr(module, '__package__'))
self.assertEqual(expect, module.__package__)
def test_top_level(self):
Modified: python/branches/py3k/Lib/json/tests/test_decode.py
==============================================================================
--- python/branches/py3k/Lib/json/tests/test_decode.py (original)
+++ python/branches/py3k/Lib/json/tests/test_decode.py Wed Jul 1 01:06:06 2009
@@ -8,12 +8,12 @@
class TestDecode(TestCase):
def test_decimal(self):
rval = json.loads('1.1', parse_float=decimal.Decimal)
- self.assert_(isinstance(rval, decimal.Decimal))
+ self.assertTrue(isinstance(rval, decimal.Decimal))
self.assertEquals(rval, decimal.Decimal('1.1'))
def test_float(self):
rval = json.loads('1', parse_int=float)
- self.assert_(isinstance(rval, float))
+ self.assertTrue(isinstance(rval, float))
self.assertEquals(rval, 1.0)
def test_object_pairs_hook(self):
Modified: python/branches/py3k/Lib/json/tests/test_speedups.py
==============================================================================
--- python/branches/py3k/Lib/json/tests/test_speedups.py (original)
+++ python/branches/py3k/Lib/json/tests/test_speedups.py Wed Jul 1 01:06:06 2009
@@ -7,9 +7,9 @@
class TestSpeedups(TestCase):
def test_scanstring(self):
self.assertEquals(decoder.scanstring.__module__, "_json")
- self.assert_(decoder.scanstring is decoder.c_scanstring)
+ self.assertTrue(decoder.scanstring is decoder.c_scanstring)
def test_encode_basestring_ascii(self):
self.assertEquals(encoder.encode_basestring_ascii.__module__, "_json")
- self.assert_(encoder.encode_basestring_ascii is
+ self.assertTrue(encoder.encode_basestring_ascii is
encoder.c_encode_basestring_ascii)
Modified: python/branches/py3k/Lib/test/mapping_tests.py
==============================================================================
--- python/branches/py3k/Lib/test/mapping_tests.py (original)
+++ python/branches/py3k/Lib/test/mapping_tests.py Wed Jul 1 01:06:06 2009
@@ -50,15 +50,15 @@
for key, value in self.reference.items():
self.assertEqual(d[key], value)
knownkey = list(self.other.keys())[0]
- self.failUnlessRaises(KeyError, lambda:d[knownkey])
+ self.assertRaises(KeyError, lambda:d[knownkey])
#len
self.assertEqual(len(p), 0)
self.assertEqual(len(d), len(self.reference))
#__contains__
for k in self.reference:
- self.assert_(k in d)
+ self.assertTrue(k in d)
for k in self.other:
- self.failIf(k in d)
+ self.assertFalse(k in d)
#cmp
self.assertEqual(p, p)
self.assertEqual(d, d)
@@ -69,10 +69,10 @@
if not d: self.fail("Full mapping must compare to True")
# keys(), items(), iterkeys() ...
def check_iterandlist(iter, lst, ref):
- self.assert_(hasattr(iter, '__next__'))
- self.assert_(hasattr(iter, '__iter__'))
+ self.assertTrue(hasattr(iter, '__next__'))
+ self.assertTrue(hasattr(iter, '__iter__'))
x = list(iter)
- self.assert_(set(x)==set(lst)==set(ref))
+ self.assertTrue(set(x)==set(lst)==set(ref))
check_iterandlist(iter(d.keys()), list(d.keys()),
self.reference.keys())
check_iterandlist(iter(d), list(d.keys()), self.reference.keys())
@@ -85,7 +85,7 @@
knownkey, knownvalue = next(iter(self.other.items()))
self.assertEqual(d.get(key, knownvalue), value)
self.assertEqual(d.get(knownkey, knownvalue), knownvalue)
- self.failIf(knownkey in d)
+ self.assertFalse(knownkey in d)
def test_write(self):
# Test for write operations on mapping
@@ -96,7 +96,7 @@
self.assertEqual(p[key], value)
for key in self.reference.keys():
del p[key]
- self.failUnlessRaises(KeyError, lambda:p[key])
+ self.assertRaises(KeyError, lambda:p[key])
p = self._empty_mapping()
#update
p.update(self.reference)
@@ -115,16 +115,16 @@
self.assertEqual(d[knownkey], knownvalue)
#pop
self.assertEqual(d.pop(knownkey), knownvalue)
- self.failIf(knownkey in d)
+ self.assertFalse(knownkey in d)
self.assertRaises(KeyError, d.pop, knownkey)
default = 909
d[knownkey] = knownvalue
self.assertEqual(d.pop(knownkey, default), knownvalue)
- self.failIf(knownkey in d)
+ self.assertFalse(knownkey in d)
self.assertEqual(d.pop(knownkey, default), default)
#popitem
key, value = d.popitem()
- self.failIf(key in d)
+ self.assertFalse(key in d)
self.assertEqual(value, self.reference[key])
p=self._empty_mapping()
self.assertRaises(KeyError, p.popitem)
@@ -133,17 +133,17 @@
self.assertEqual(self._empty_mapping(), self._empty_mapping())
def test_bool(self):
- self.assert_(not self._empty_mapping())
- self.assert_(self.reference)
- self.assert_(bool(self._empty_mapping()) is False)
- self.assert_(bool(self.reference) is True)
+ self.assertTrue(not self._empty_mapping())
+ self.assertTrue(self.reference)
+ self.assertTrue(bool(self._empty_mapping()) is False)
+ self.assertTrue(bool(self.reference) is True)
def test_keys(self):
d = self._empty_mapping()
self.assertEqual(list(d.keys()), [])
d = self.reference
- self.assert_(list(self.inmapping.keys())[0] in d.keys())
- self.assert_(list(self.other.keys())[0] not in d.keys())
+ self.assertTrue(list(self.inmapping.keys())[0] in d.keys())
+ self.assertTrue(list(self.other.keys())[0] not in d.keys())
self.assertRaises(TypeError, d.keys, None)
def test_values(self):
@@ -268,10 +268,10 @@
def test_get(self):
d = self._empty_mapping()
- self.assert_(d.get(list(self.other.keys())[0]) is None)
+ self.assertTrue(d.get(list(self.other.keys())[0]) is None)
self.assertEqual(d.get(list(self.other.keys())[0], 3), 3)
d = self.reference
- self.assert_(d.get(list(self.other.keys())[0]) is None)
+ self.assertTrue(d.get(list(self.other.keys())[0]) is None)
self.assertEqual(d.get(list(self.other.keys())[0], 3), 3)
self.assertEqual(d.get(list(self.inmapping.keys())[0]),
list(self.inmapping.values())[0])
@@ -304,15 +304,15 @@
class TestMappingProtocol(BasicTestMappingProtocol):
def test_constructor(self):
BasicTestMappingProtocol.test_constructor(self)
- self.assert_(self._empty_mapping() is not self._empty_mapping())
+ self.assertTrue(self._empty_mapping() is not self._empty_mapping())
self.assertEqual(self.type2test(x=1, y=2), {"x": 1, "y": 2})
def test_bool(self):
BasicTestMappingProtocol.test_bool(self)
- self.assert_(not self._empty_mapping())
- self.assert_(self._full_mapping({"x": "y"}))
- self.assert_(bool(self._empty_mapping()) is False)
- self.assert_(bool(self._full_mapping({"x": "y"})) is True)
+ self.assertTrue(not self._empty_mapping())
+ self.assertTrue(self._full_mapping({"x": "y"}))
+ self.assertTrue(bool(self._empty_mapping()) is False)
+ self.assertTrue(bool(self._full_mapping({"x": "y"})) is True)
def test_keys(self):
BasicTestMappingProtocol.test_keys(self)
@@ -320,9 +320,9 @@
self.assertEqual(list(d.keys()), [])
d = self._full_mapping({'a': 1, 'b': 2})
k = d.keys()
- self.assert_('a' in k)
- self.assert_('b' in k)
- self.assert_('c' not in k)
+ self.assertTrue('a' in k)
+ self.assertTrue('b' in k)
+ self.assertTrue('c' not in k)
def test_values(self):
BasicTestMappingProtocol.test_values(self)
@@ -337,12 +337,12 @@
def test_contains(self):
d = self._empty_mapping()
- self.assert_(not ('a' in d))
- self.assert_('a' not in d)
+ self.assertTrue(not ('a' in d))
+ self.assertTrue('a' not in d)
d = self._full_mapping({'a': 1, 'b': 2})
- self.assert_('a' in d)
- self.assert_('b' in d)
- self.assert_('c' not in d)
+ self.assertTrue('a' in d)
+ self.assertTrue('b' in d)
+ self.assertTrue('c' not in d)
self.assertRaises(TypeError, d.__contains__)
@@ -421,7 +421,7 @@
def test_fromkeys(self):
self.assertEqual(self.type2test.fromkeys('abc'), {'a':None, 'b':None, 'c':None})
d = self._empty_mapping()
- self.assert_(not(d.fromkeys('abc') is d))
+ self.assertTrue(not(d.fromkeys('abc') is d))
self.assertEqual(d.fromkeys('abc'), {'a':None, 'b':None, 'c':None})
self.assertEqual(d.fromkeys((4,5),0), {4:0, 5:0})
self.assertEqual(d.fromkeys([]), {})
@@ -432,17 +432,17 @@
class dictlike(self.type2test): pass
self.assertEqual(dictlike.fromkeys('a'), {'a':None})
self.assertEqual(dictlike().fromkeys('a'), {'a':None})
- self.assert_(dictlike.fromkeys('a').__class__ is dictlike)
- self.assert_(dictlike().fromkeys('a').__class__ is dictlike)
+ self.assertTrue(dictlike.fromkeys('a').__class__ is dictlike)
+ self.assertTrue(dictlike().fromkeys('a').__class__ is dictlike)
# FIXME: the following won't work with UserDict, because it's an old style class
- # self.assert_(type(dictlike.fromkeys('a')) is dictlike)
+ # self.assertTrue(type(dictlike.fromkeys('a')) is dictlike)
class mydict(self.type2test):
def __new__(cls):
return collections.UserDict()
ud = mydict.fromkeys('ab')
self.assertEqual(ud, {'a':None, 'b':None})
# FIXME: the following won't work with UserDict, because it's an old style class
- # self.assert_(isinstance(ud, collections.UserDict))
+ # self.assertTrue(isinstance(ud, collections.UserDict))
self.assertRaises(TypeError, dict.fromkeys)
class Exc(Exception): pass
@@ -472,16 +472,16 @@
self.assertEqual(d.copy(), {1:1, 2:2, 3:3})
d = self._empty_mapping()
self.assertEqual(d.copy(), d)
- self.assert_(isinstance(d.copy(), d.__class__))
+ self.assertTrue(isinstance(d.copy(), d.__class__))
self.assertRaises(TypeError, d.copy, None)
def test_get(self):
BasicTestMappingProtocol.test_get(self)
d = self._empty_mapping()
- self.assert_(d.get('c') is None)
+ self.assertTrue(d.get('c') is None)
self.assertEqual(d.get('c', 3), 3)
d = self._full_mapping({'a' : 1, 'b' : 2})
- self.assert_(d.get('c') is None)
+ self.assertTrue(d.get('c') is None)
self.assertEqual(d.get('c', 3), 3)
self.assertEqual(d.get('a'), 1)
self.assertEqual(d.get('a', 3), 1)
@@ -489,9 +489,9 @@
def test_setdefault(self):
BasicTestMappingProtocol.test_setdefault(self)
d = self._empty_mapping()
- self.assert_(d.setdefault('key0') is None)
+ self.assertTrue(d.setdefault('key0') is None)
d.setdefault('key0', [])
- self.assert_(d.setdefault('key0') is None)
+ self.assertTrue(d.setdefault('key0') is None)
d.setdefault('key', []).append(3)
self.assertEqual(d['key'][0], 3)
d.setdefault('key', []).append(4)
@@ -517,9 +517,9 @@
self.assertEqual(va, int(ka))
kb, vb = tb = b.popitem()
self.assertEqual(vb, int(kb))
- self.assert_(not(copymode < 0 and ta != tb))
- self.assert_(not a)
- self.assert_(not b)
+ self.assertTrue(not(copymode < 0 and ta != tb))
+ self.assertTrue(not a)
+ self.assertTrue(not b)
def test_pop(self):
BasicTestMappingProtocol.test_pop(self)
@@ -577,7 +577,7 @@
return collections.UserDict()
ud = mydict.fromkeys('ab')
self.assertEqual(ud, {'a':None, 'b':None})
- self.assert_(isinstance(ud, collections.UserDict))
+ self.assertTrue(isinstance(ud, collections.UserDict))
def test_pop(self):
TestMappingProtocol.test_pop(self)
Modified: python/branches/py3k/Lib/test/pickletester.py
==============================================================================
--- python/branches/py3k/Lib/test/pickletester.py (original)
+++ python/branches/py3k/Lib/test/pickletester.py Wed Jul 1 01:06:06 2009
@@ -449,7 +449,7 @@
s = self.dumps(l, proto)
x = self.loads(s)
self.assertEqual(len(x), 1)
- self.assert_(x is x[0])
+ self.assertTrue(x is x[0])
def test_recursive_tuple(self):
t = ([],)
@@ -459,7 +459,7 @@
x = self.loads(s)
self.assertEqual(len(x), 1)
self.assertEqual(len(x[0]), 1)
- self.assert_(x is x[0][0])
+ self.assertTrue(x is x[0][0])
def test_recursive_dict(self):
d = {}
@@ -468,7 +468,7 @@
s = self.dumps(d, proto)
x = self.loads(s)
self.assertEqual(list(x.keys()), [1])
- self.assert_(x[1] is x)
+ self.assertTrue(x[1] is x)
def test_recursive_inst(self):
i = C()
@@ -477,7 +477,7 @@
s = self.dumps(i, 2)
x = self.loads(s)
self.assertEqual(dir(x), dir(i))
- self.assert_(x.attr is x)
+ self.assertTrue(x.attr is x)
def test_recursive_multi(self):
l = []
@@ -491,7 +491,7 @@
self.assertEqual(len(x), 1)
self.assertEqual(dir(x[0]), dir(i))
self.assertEqual(list(x[0].attr.keys()), [1])
- self.assert_(x[0].attr[1] is x)
+ self.assertTrue(x[0].attr[1] is x)
def test_get(self):
self.assertRaises(KeyError, self.loads, b'g0\np0')
@@ -639,7 +639,7 @@
try:
self.loads(badpickle)
except ValueError as detail:
- self.failUnless(str(detail).startswith(
+ self.assertTrue(str(detail).startswith(
"unsupported pickle protocol"))
else:
self.fail("expected bad protocol number to raise ValueError")
@@ -720,7 +720,7 @@
for x in None, False, True:
s = self.dumps(x, proto)
y = self.loads(s)
- self.assert_(x is y, (proto, x, s, y))
+ self.assertTrue(x is y, (proto, x, s, y))
expected = expected_opcode[proto, x]
self.assertEqual(opcode_in_pickle(expected, s), True)
@@ -770,8 +770,8 @@
# Dump using protocol 1 for comparison.
s1 = self.dumps(x, 1)
- self.assert_(__name__.encode("utf-8") in s1)
- self.assert_(b"MyList" in s1)
+ self.assertTrue(__name__.encode("utf-8") in s1)
+ self.assertTrue(b"MyList" in s1)
self.assertEqual(opcode_in_pickle(opcode, s1), False)
y = self.loads(s1)
@@ -780,8 +780,8 @@
# Dump using protocol 2 for test.
s2 = self.dumps(x, 2)
- self.assert_(__name__.encode("utf-8") not in s2)
- self.assert_(b"MyList" not in s2)
+ self.assertTrue(__name__.encode("utf-8") not in s2)
+ self.assertTrue(b"MyList" not in s2)
self.assertEqual(opcode_in_pickle(opcode, s2), True, repr(s2))
y = self.loads(s2)
@@ -825,7 +825,7 @@
if proto == 0:
self.assertEqual(num_appends, 0)
else:
- self.failUnless(num_appends >= 2)
+ self.assertTrue(num_appends >= 2)
def test_dict_chunking(self):
n = 10 # too small to chunk
@@ -848,7 +848,7 @@
if proto == 0:
self.assertEqual(num_setitems, 0)
else:
- self.failUnless(num_setitems >= 2)
+ self.assertTrue(num_setitems >= 2)
def test_simple_newobj(self):
x = object.__new__(SimpleNewObj) # avoid __init__
Modified: python/branches/py3k/Lib/test/test___all__.py
==============================================================================
--- python/branches/py3k/Lib/test/test___all__.py (original)
+++ python/branches/py3k/Lib/test/test___all__.py Wed Jul 1 01:06:06 2009
@@ -17,7 +17,7 @@
# Silent fail here seems the best route since some modules
# may not be available in all environments.
return
- self.failUnless(hasattr(sys.modules[modname], "__all__"),
+ self.assertTrue(hasattr(sys.modules[modname], "__all__"),
"%s has no __all__ attribute" % modname)
names = {}
exec("from %s import *" % modname, names)
Modified: python/branches/py3k/Lib/test/test___future__.py
==============================================================================
--- python/branches/py3k/Lib/test/test___future__.py (original)
+++ python/branches/py3k/Lib/test/test___future__.py Wed Jul 1 01:06:06 2009
@@ -15,7 +15,7 @@
for name in dir(__future__):
obj = getattr(__future__, name, None)
if obj is not None and isinstance(obj, __future__._Feature):
- self.assert_(
+ self.assertTrue(
name in given_feature_names,
"%r should have been in all_feature_names" % name
)
@@ -30,7 +30,7 @@
optional = value.getOptionalRelease()
mandatory = value.getMandatoryRelease()
- a = self.assert_
+ a = self.assertTrue
e = self.assertEqual
def check(t, name):
a(isinstance(t, tuple), "%s isn't tuple" % name)
Modified: python/branches/py3k/Lib/test/test_abc.py
==============================================================================
--- python/branches/py3k/Lib/test/test_abc.py (original)
+++ python/branches/py3k/Lib/test/test_abc.py Wed Jul 1 01:06:06 2009
@@ -42,23 +42,23 @@
def bar(self): pass # concrete
self.assertEqual(C.__abstractmethods__, {"foo"})
self.assertRaises(TypeError, C) # because foo is abstract
- self.assert_(isabstract(C))
+ self.assertTrue(isabstract(C))
class D(C):
def bar(self): pass # concrete override of concrete
self.assertEqual(D.__abstractmethods__, {"foo"})
self.assertRaises(TypeError, D) # because foo is still abstract
- self.assert_(isabstract(D))
+ self.assertTrue(isabstract(D))
class E(D):
def foo(self): pass
self.assertEqual(E.__abstractmethods__, set())
E() # now foo is concrete, too
- self.failIf(isabstract(E))
+ self.assertFalse(isabstract(E))
class F(E):
@abstractthing
def bar(self): pass # abstract override of concrete
self.assertEqual(F.__abstractmethods__, {"bar"})
self.assertRaises(TypeError, F) # because bar is abstract now
- self.assert_(isabstract(F))
+ self.assertTrue(isabstract(F))
def test_subclass_oldstyle_class(self):
class A:
@@ -142,41 +142,41 @@
def test_registration_transitiveness(self):
class A(metaclass=abc.ABCMeta):
pass
- self.failUnless(issubclass(A, A))
- self.failUnless(issubclass(A, (A,)))
+ self.assertTrue(issubclass(A, A))
+ self.assertTrue(issubclass(A, (A,)))
class B(metaclass=abc.ABCMeta):
pass
- self.failIf(issubclass(A, B))
- self.failIf(issubclass(A, (B,)))
- self.failIf(issubclass(B, A))
- self.failIf(issubclass(B, (A,)))
+ self.assertFalse(issubclass(A, B))
+ self.assertFalse(issubclass(A, (B,)))
+ self.assertFalse(issubclass(B, A))
+ self.assertFalse(issubclass(B, (A,)))
class C(metaclass=abc.ABCMeta):
pass
A.register(B)
class B1(B):
pass
- self.failUnless(issubclass(B1, A))
- self.failUnless(issubclass(B1, (A,)))
+ self.assertTrue(issubclass(B1, A))
+ self.assertTrue(issubclass(B1, (A,)))
class C1(C):
pass
B1.register(C1)
- self.failIf(issubclass(C, B))
- self.failIf(issubclass(C, (B,)))
- self.failIf(issubclass(C, B1))
- self.failIf(issubclass(C, (B1,)))
- self.failUnless(issubclass(C1, A))
- self.failUnless(issubclass(C1, (A,)))
- self.failUnless(issubclass(C1, B))
- self.failUnless(issubclass(C1, (B,)))
- self.failUnless(issubclass(C1, B1))
- self.failUnless(issubclass(C1, (B1,)))
+ self.assertFalse(issubclass(C, B))
+ self.assertFalse(issubclass(C, (B,)))
+ self.assertFalse(issubclass(C, B1))
+ self.assertFalse(issubclass(C, (B1,)))
+ self.assertTrue(issubclass(C1, A))
+ self.assertTrue(issubclass(C1, (A,)))
+ self.assertTrue(issubclass(C1, B))
+ self.assertTrue(issubclass(C1, (B,)))
+ self.assertTrue(issubclass(C1, B1))
+ self.assertTrue(issubclass(C1, (B1,)))
C1.register(int)
class MyInt(int):
pass
- self.failUnless(issubclass(MyInt, A))
- self.failUnless(issubclass(MyInt, (A,)))
- self.failUnless(isinstance(42, A))
- self.failUnless(isinstance(42, (A,)))
+ self.assertTrue(issubclass(MyInt, A))
+ self.assertTrue(issubclass(MyInt, (A,)))
+ self.assertTrue(isinstance(42, A))
+ self.assertTrue(isinstance(42, (A,)))
def test_all_new_methods_are_called(self):
class A(metaclass=abc.ABCMeta):
Modified: python/branches/py3k/Lib/test/test_abstract_numbers.py
==============================================================================
--- python/branches/py3k/Lib/test/test_abstract_numbers.py (original)
+++ python/branches/py3k/Lib/test/test_abstract_numbers.py Wed Jul 1 01:06:06 2009
@@ -9,8 +9,8 @@
class TestNumbers(unittest.TestCase):
def test_int(self):
- self.failUnless(issubclass(int, Integral))
- self.failUnless(issubclass(int, Complex))
+ self.assertTrue(issubclass(int, Integral))
+ self.assertTrue(issubclass(int, Complex))
self.assertEqual(7, int(7).real)
self.assertEqual(0, int(7).imag)
@@ -19,16 +19,16 @@
self.assertEqual(1, int(7).denominator)
def test_float(self):
- self.failIf(issubclass(float, Rational))
- self.failUnless(issubclass(float, Real))
+ self.assertFalse(issubclass(float, Rational))
+ self.assertTrue(issubclass(float, Real))
self.assertEqual(7.3, float(7.3).real)
self.assertEqual(0, float(7.3).imag)
self.assertEqual(7.3, float(7.3).conjugate())
def test_complex(self):
- self.failIf(issubclass(complex, Real))
- self.failUnless(issubclass(complex, Complex))
+ self.assertFalse(issubclass(complex, Real))
+ self.assertTrue(issubclass(complex, Complex))
c1, c2 = complex(3, 2), complex(4,1)
# XXX: This is not ideal, but see the comment in math_trunc().
Modified: python/branches/py3k/Lib/test/test_array.py
==============================================================================
--- python/branches/py3k/Lib/test/test_array.py (original)
+++ python/branches/py3k/Lib/test/test_array.py Wed Jul 1 01:06:06 2009
@@ -49,7 +49,7 @@
def test_constructor(self):
a = array.array(self.typecode)
self.assertEqual(a.typecode, self.typecode)
- self.assert_(a.itemsize>=self.minitemsize)
+ self.assertTrue(a.itemsize>=self.minitemsize)
self.assertRaises(TypeError, array.array, self.typecode, None)
def test_len(self):
@@ -64,10 +64,10 @@
a = array.array(self.typecode, self.example)
self.assertRaises(TypeError, a.buffer_info, 42)
bi = a.buffer_info()
- self.assert_(isinstance(bi, tuple))
+ self.assertTrue(isinstance(bi, tuple))
self.assertEqual(len(bi), 2)
- self.assert_(isinstance(bi[0], int))
- self.assert_(isinstance(bi[1], int))
+ self.assertTrue(isinstance(bi[0], int))
+ self.assertTrue(isinstance(bi[1], int))
self.assertEqual(bi[1], len(a))
def test_byteswap(self):
@@ -216,39 +216,39 @@
def test_cmp(self):
a = array.array(self.typecode, self.example)
- self.assert_((a == 42) is False)
- self.assert_((a != 42) is True)
+ self.assertTrue((a == 42) is False)
+ self.assertTrue((a != 42) is True)
- self.assert_((a == a) is True)
- self.assert_((a != a) is False)
- self.assert_((a < a) is False)
- self.assert_((a <= a) is True)
- self.assert_((a > a) is False)
- self.assert_((a >= a) is True)
+ self.assertTrue((a == a) is True)
+ self.assertTrue((a != a) is False)
+ self.assertTrue((a < a) is False)
+ self.assertTrue((a <= a) is True)
+ self.assertTrue((a > a) is False)
+ self.assertTrue((a >= a) is True)
al = array.array(self.typecode, self.smallerexample)
ab = array.array(self.typecode, self.biggerexample)
- self.assert_((a == 2*a) is False)
- self.assert_((a != 2*a) is True)
- self.assert_((a < 2*a) is True)
- self.assert_((a <= 2*a) is True)
- self.assert_((a > 2*a) is False)
- self.assert_((a >= 2*a) is False)
-
- self.assert_((a == al) is False)
- self.assert_((a != al) is True)
- self.assert_((a < al) is False)
- self.assert_((a <= al) is False)
- self.assert_((a > al) is True)
- self.assert_((a >= al) is True)
-
- self.assert_((a == ab) is False)
- self.assert_((a != ab) is True)
- self.assert_((a < ab) is True)
- self.assert_((a <= ab) is True)
- self.assert_((a > ab) is False)
- self.assert_((a >= ab) is False)
+ self.assertTrue((a == 2*a) is False)
+ self.assertTrue((a != 2*a) is True)
+ self.assertTrue((a < 2*a) is True)
+ self.assertTrue((a <= 2*a) is True)
+ self.assertTrue((a > 2*a) is False)
+ self.assertTrue((a >= 2*a) is False)
+
+ self.assertTrue((a == al) is False)
+ self.assertTrue((a != al) is True)
+ self.assertTrue((a < al) is False)
+ self.assertTrue((a <= al) is False)
+ self.assertTrue((a > al) is True)
+ self.assertTrue((a >= al) is True)
+
+ self.assertTrue((a == ab) is False)
+ self.assertTrue((a != ab) is True)
+ self.assertTrue((a < ab) is True)
+ self.assertTrue((a <= ab) is True)
+ self.assertTrue((a > ab) is False)
+ self.assertTrue((a >= ab) is False)
def test_add(self):
a = array.array(self.typecode, self.example) \
@@ -267,7 +267,7 @@
a = array.array(self.typecode, self.example[::-1])
b = a
a += array.array(self.typecode, 2*self.example)
- self.assert_(a is b)
+ self.assertTrue(a is b)
self.assertEqual(
a,
array.array(self.typecode, self.example[::-1]+2*self.example)
@@ -310,22 +310,22 @@
b = a
a *= 5
- self.assert_(a is b)
+ self.assertTrue(a is b)
self.assertEqual(
a,
array.array(self.typecode, 5*self.example)
)
a *= 0
- self.assert_(a is b)
+ self.assertTrue(a is b)
self.assertEqual(a, array.array(self.typecode))
a *= 1000
- self.assert_(a is b)
+ self.assertTrue(a is b)
self.assertEqual(a, array.array(self.typecode))
a *= -1
- self.assert_(a is b)
+ self.assertTrue(a is b)
self.assertEqual(a, array.array(self.typecode))
a = array.array(self.typecode, self.example)
Modified: python/branches/py3k/Lib/test/test_ast.py
==============================================================================
--- python/branches/py3k/Lib/test/test_ast.py (original)
+++ python/branches/py3k/Lib/test/test_ast.py Wed Jul 1 01:06:06 2009
@@ -116,20 +116,20 @@
class AST_Tests(unittest.TestCase):
- def _assert_order(self, ast_node, parent_pos):
+ def _assertTrueorder(self, ast_node, parent_pos):
if not isinstance(ast_node, ast.AST) or ast_node._fields is None:
return
if isinstance(ast_node, (ast.expr, ast.stmt, ast.excepthandler)):
node_pos = (ast_node.lineno, ast_node.col_offset)
- self.assert_(node_pos >= parent_pos)
+ self.assertTrue(node_pos >= parent_pos)
parent_pos = (ast_node.lineno, ast_node.col_offset)
for name in ast_node._fields:
value = getattr(ast_node, name)
if isinstance(value, list):
for child in value:
- self._assert_order(child, parent_pos)
+ self._assertTrueorder(child, parent_pos)
elif value is not None:
- self._assert_order(value, parent_pos)
+ self._assertTrueorder(value, parent_pos)
def test_snippets(self):
for input, output, kind in ((exec_tests, exec_results, "exec"),
@@ -138,7 +138,7 @@
for i, o in zip(input, output):
ast_tree = compile(i, "?", kind, ast.PyCF_ONLY_AST)
self.assertEquals(to_tuple(ast_tree), o)
- self._assert_order(ast_tree, (0, 0))
+ self._assertTrueorder(ast_tree, (0, 0))
def test_slice(self):
slc = ast.parse("x[::]").body[0].value.slice
Modified: python/branches/py3k/Lib/test/test_augassign.py
==============================================================================
--- python/branches/py3k/Lib/test/test_augassign.py (original)
+++ python/branches/py3k/Lib/test/test_augassign.py Wed Jul 1 01:06:06 2009
@@ -60,7 +60,7 @@
y[1:2] += [1]
self.assertEquals(x, [1, 2, 1, 2, 3])
- self.assert_(x is y)
+ self.assertTrue(x is y)
def testCustomMethods1(self):
@@ -85,23 +85,23 @@
y = x
x += 10
- self.assert_(isinstance(x, aug_test))
- self.assert_(y is not x)
+ self.assertTrue(isinstance(x, aug_test))
+ self.assertTrue(y is not x)
self.assertEquals(x.val, 11)
x = aug_test2(2)
y = x
x += 10
- self.assert_(y is x)
+ self.assertTrue(y is x)
self.assertEquals(x.val, 12)
x = aug_test3(3)
y = x
x += 10
- self.assert_(isinstance(x, aug_test3))
- self.assert_(y is not x)
+ self.assertTrue(isinstance(x, aug_test3))
+ self.assertTrue(y is not x)
self.assertEquals(x.val, 13)
Modified: python/branches/py3k/Lib/test/test_base64.py
==============================================================================
--- python/branches/py3k/Lib/test/test_base64.py (original)
+++ python/branches/py3k/Lib/test/test_base64.py Wed Jul 1 01:06:06 2009
@@ -204,7 +204,7 @@
self.assertRaises(TypeError, base64.b16decode, "")
def test_ErrorHeritage(self):
- self.assert_(issubclass(binascii.Error, ValueError))
+ self.assertTrue(issubclass(binascii.Error, ValueError))
Modified: python/branches/py3k/Lib/test/test_bigmem.py
==============================================================================
--- python/branches/py3k/Lib/test/test_bigmem.py (original)
+++ python/branches/py3k/Lib/test/test_bigmem.py Wed Jul 1 01:06:06 2009
@@ -80,12 +80,12 @@
_ = self.from_latin1
SUBSTR = _(' abc def ghi')
s = _('-') * size + SUBSTR
- self.failUnless(s.endswith(SUBSTR))
- self.failUnless(s.endswith(s))
+ self.assertTrue(s.endswith(SUBSTR))
+ self.assertTrue(s.endswith(s))
s2 = _('...') + s
- self.failUnless(s2.endswith(s))
- self.failIf(s.endswith(_('a') + SUBSTR))
- self.failIf(SUBSTR.endswith(s))
+ self.assertTrue(s2.endswith(s))
+ self.assertFalse(s.endswith(_('a') + SUBSTR))
+ self.assertFalse(SUBSTR.endswith(s))
@bigmemtest(minsize=_2G + 10, memuse=2)
def test_expandtabs(self, size):
@@ -139,27 +139,27 @@
_ = self.from_latin1
SUBSTR = _('123456')
s = _('a') * size + SUBSTR
- self.failUnless(s.isalnum())
+ self.assertTrue(s.isalnum())
s += _('.')
- self.failIf(s.isalnum())
+ self.assertFalse(s.isalnum())
@bigmemtest(minsize=_2G, memuse=2)
def test_isalpha(self, size):
_ = self.from_latin1
SUBSTR = _('zzzzzzz')
s = _('a') * size + SUBSTR
- self.failUnless(s.isalpha())
+ self.assertTrue(s.isalpha())
s += _('.')
- self.failIf(s.isalpha())
+ self.assertFalse(s.isalpha())
@bigmemtest(minsize=_2G, memuse=2)
def test_isdigit(self, size):
_ = self.from_latin1
SUBSTR = _('123456')
s = _('9') * size + SUBSTR
- self.failUnless(s.isdigit())
+ self.assertTrue(s.isdigit())
s += _('z')
- self.failIf(s.isdigit())
+ self.assertFalse(s.isdigit())
@bigmemtest(minsize=_2G, memuse=2)
def test_islower(self, size):
@@ -168,9 +168,9 @@
chr(c) for c in range(255) if not chr(c).isupper()))
repeats = size // len(chars) + 2
s = chars * repeats
- self.failUnless(s.islower())
+ self.assertTrue(s.islower())
s += _('A')
- self.failIf(s.islower())
+ self.assertFalse(s.islower())
@bigmemtest(minsize=_2G, memuse=2)
def test_isspace(self, size):
@@ -178,20 +178,20 @@
whitespace = _(' \f\n\r\t\v')
repeats = size // len(whitespace) + 2
s = whitespace * repeats
- self.failUnless(s.isspace())
+ self.assertTrue(s.isspace())
s += _('j')
- self.failIf(s.isspace())
+ self.assertFalse(s.isspace())
@bigmemtest(minsize=_2G, memuse=2)
def test_istitle(self, size):
_ = self.from_latin1
SUBSTR = _('123456')
s = _('').join([_('A'), _('a') * size, SUBSTR])
- self.failUnless(s.istitle())
+ self.assertTrue(s.istitle())
s += _('A')
- self.failUnless(s.istitle())
+ self.assertTrue(s.istitle())
s += _('aA')
- self.failIf(s.istitle())
+ self.assertFalse(s.istitle())
@bigmemtest(minsize=_2G, memuse=2)
def test_isupper(self, size):
@@ -200,9 +200,9 @@
chr(c) for c in range(255) if not chr(c).islower()))
repeats = size // len(chars) + 2
s = chars * repeats
- self.failUnless(s.isupper())
+ self.assertTrue(s.isupper())
s += _('a')
- self.failIf(s.isupper())
+ self.assertFalse(s.isupper())
@bigmemtest(minsize=_2G, memuse=2)
def test_join(self, size):
@@ -211,15 +211,15 @@
x = s.join([_('aaaaa'), _('bbbbb')])
self.assertEquals(x.count(_('a')), 5)
self.assertEquals(x.count(_('b')), 5)
- self.failUnless(x.startswith(_('aaaaaA')))
- self.failUnless(x.endswith(_('Abbbbb')))
+ self.assertTrue(x.startswith(_('aaaaaA')))
+ self.assertTrue(x.endswith(_('Abbbbb')))
@bigmemtest(minsize=_2G + 10, memuse=1)
def test_ljust(self, size):
_ = self.from_latin1
SUBSTR = _(' abc def ghi')
s = SUBSTR.ljust(size)
- self.failUnless(s.startswith(SUBSTR + _(' ')))
+ self.assertTrue(s.startswith(SUBSTR + _(' ')))
self.assertEquals(len(s), size)
self.assertEquals(s.strip(), SUBSTR.strip())
@@ -244,7 +244,7 @@
# Type-specific optimization
if isinstance(s, (str, bytes)):
stripped = s.lstrip()
- self.failUnless(stripped is s)
+ self.assertTrue(stripped is s)
@bigmemtest(minsize=_2G + 10, memuse=2)
def test_replace(self, size):
@@ -299,7 +299,7 @@
_ = self.from_latin1
SUBSTR = _(' abc def ghi')
s = SUBSTR.ljust(size)
- self.failUnless(s.startswith(SUBSTR + _(' ')))
+ self.assertTrue(s.startswith(SUBSTR + _(' ')))
self.assertEquals(len(s), size)
self.assertEquals(s.strip(), SUBSTR.strip())
@@ -316,7 +316,7 @@
# Type-specific optimization
if isinstance(s, (str, bytes)):
stripped = s.rstrip()
- self.failUnless(stripped is s)
+ self.assertTrue(stripped is s)
# The test takes about size bytes to build a string, and then about
# sqrt(size) substrings of sqrt(size) in size and a list to
@@ -378,9 +378,9 @@
_ = self.from_latin1
SUBSTR = _(' abc def ghi')
s = _('-') * size + SUBSTR
- self.failUnless(s.startswith(s))
- self.failUnless(s.startswith(_('-') * size))
- self.failIf(s.startswith(SUBSTR))
+ self.assertTrue(s.startswith(s))
+ self.assertTrue(s.startswith(_('-') * size))
+ self.assertFalse(s.startswith(SUBSTR))
@bigmemtest(minsize=_2G, memuse=1)
def test_strip(self, size):
@@ -412,8 +412,8 @@
SUBSTR = _('SpaaHAaaAaham')
s = SUBSTR * (size // len(SUBSTR) + 2)
s = s.title()
- self.failUnless(s.startswith((SUBSTR * 3).title()))
- self.failUnless(s.endswith(SUBSTR.lower() * 3))
+ self.assertTrue(s.startswith((SUBSTR * 3).title()))
+ self.assertTrue(s.endswith(SUBSTR.lower() * 3))
@bigmemtest(minsize=_2G, memuse=2)
def test_translate(self, size):
@@ -451,8 +451,8 @@
_ = self.from_latin1
SUBSTR = _('-568324723598234')
s = SUBSTR.zfill(size)
- self.failUnless(s.endswith(_('0') + SUBSTR[1:]))
- self.failUnless(s.startswith(_('-0')))
+ self.assertTrue(s.endswith(_('0') + SUBSTR[1:]))
+ self.assertTrue(s.startswith(_('-0')))
self.assertEquals(len(s), size)
self.assertEquals(s.count(_('0')), size - len(SUBSTR))
@@ -519,12 +519,12 @@
edge = _('-') * (size // 2)
s = _('').join([edge, SUBSTR, edge])
del edge
- self.failUnless(SUBSTR in s)
- self.failIf(SUBSTR * 2 in s)
- self.failUnless(_('-') in s)
- self.failIf(_('a') in s)
+ self.assertTrue(SUBSTR in s)
+ self.assertFalse(SUBSTR * 2 in s)
+ self.assertTrue(_('-') in s)
+ self.assertFalse(_('a') in s)
s += _('a')
- self.failUnless(_('a') in s)
+ self.assertTrue(_('a') in s)
@bigmemtest(minsize=_2G + 10, memuse=2)
def test_compare(self, size):
@@ -534,10 +534,10 @@
self.assertEqual(s1, s2)
del s2
s2 = s1 + _('a')
- self.failIf(s1 == s2)
+ self.assertFalse(s1 == s2)
del s2
s2 = _('.') * size
- self.failIf(s1 == s2)
+ self.assertFalse(s1 == s2)
@bigmemtest(minsize=_2G + 10, memuse=1)
def test_hash(self, size):
@@ -552,7 +552,7 @@
h1 = hash(s)
del s
s = _('\x00') * (size + 1)
- self.failIf(h1 == hash(s))
+ self.assertFalse(h1 == hash(s))
class StrTest(unittest.TestCase, BaseStrTest):
@@ -623,7 +623,7 @@
except MemoryError:
pass # acceptable on 32-bit
else:
- self.failUnless(s == eval(r))
+ self.assertTrue(s == eval(r))
@bigmemtest(minsize=_2G + 10, memuse=character_size * 2)
def test_format(self, size):
@@ -633,8 +633,8 @@
del sf
sf = '..%s..' % (s,)
self.assertEquals(len(sf), len(s) + 4)
- self.failUnless(sf.startswith('..-'))
- self.failUnless(sf.endswith('-..'))
+ self.assertTrue(sf.startswith('..-'))
+ self.assertTrue(sf.endswith('-..'))
del s, sf
size //= 2
@@ -682,8 +682,8 @@
s = "\uAAAA" * size
for f in (repr, ascii):
r = f(s)
- self.failUnless(len(r) > size)
- self.failUnless(r.endswith(r"\uaaaa'"), r[-10:])
+ self.assertTrue(len(r) > size)
+ self.assertTrue(r.endswith(r"\uaaaa'"), r[-10:])
del r
# The character takes 4 bytes even in UCS-2 builds because it will
@@ -693,8 +693,8 @@
s = "\U0001AAAA" * size
for f in (repr, ascii):
r = f(s)
- self.failUnless(len(r) > size)
- self.failUnless(r.endswith(r"\U0001aaaa'"), r[-12:])
+ self.assertTrue(len(r) > size)
+ self.assertTrue(r.endswith(r"\U0001aaaa'"), r[-12:])
del r
@@ -740,10 +740,10 @@
self.assertEqual(t1, t2)
del t2
t2 = ('',) * (size + 1)
- self.failIf(t1 == t2)
+ self.assertFalse(t1 == t2)
del t2
t2 = (1,) * size
- self.failIf(t1 == t2)
+ self.assertFalse(t1 == t2)
# Test concatenating into a single tuple of more than 2G in length,
# and concatenating a tuple of more than 2G in length separately, so
@@ -768,9 +768,9 @@
def test_contains(self, size):
t = (1, 2, 3, 4, 5) * size
self.assertEquals(len(t), size * 5)
- self.failUnless(5 in t)
- self.failIf((1, 2, 3, 4, 5) in t)
- self.failIf(0 in t)
+ self.assertTrue(5 in t)
+ self.assertFalse((1, 2, 3, 4, 5) in t)
+ self.assertFalse(0 in t)
@bigmemtest(minsize=_2G + 10, memuse=8)
def test_hash(self, size):
@@ -778,7 +778,7 @@
h1 = hash(t1)
del t1
t2 = (0,) * (size + 1)
- self.failIf(h1 == hash(t2))
+ self.assertFalse(h1 == hash(t2))
@bigmemtest(minsize=_2G + 10, memuse=8)
def test_index_and_slice(self, size):
@@ -874,10 +874,10 @@
self.assertEqual(l1, l2)
del l2
l2 = [''] * (size + 1)
- self.failIf(l1 == l2)
+ self.assertFalse(l1 == l2)
del l2
l2 = [2] * size
- self.failIf(l1 == l2)
+ self.assertFalse(l1 == l2)
# Test concatenating into a single list of more than 2G in length,
# and concatenating a list of more than 2G in length separately, so
@@ -902,8 +902,8 @@
l = [sys.stdout] * size
l += l
self.assertEquals(len(l), size * 2)
- self.failUnless(l[0] is l[-1])
- self.failUnless(l[size - 1] is l[size + 1])
+ self.assertTrue(l[0] is l[-1])
+ self.assertTrue(l[size - 1] is l[size + 1])
@bigmemtest(minsize=_2G // 2 + 2, memuse=24)
def test_inplace_concat_small(self, size):
@@ -917,14 +917,14 @@
def test_contains(self, size):
l = [1, 2, 3, 4, 5] * size
self.assertEquals(len(l), size * 5)
- self.failUnless(5 in l)
- self.failIf([1, 2, 3, 4, 5] in l)
- self.failIf(0 in l)
+ self.assertTrue(5 in l)
+ self.assertFalse([1, 2, 3, 4, 5] in l)
+ self.assertFalse(0 in l)
@bigmemtest(minsize=_2G + 10, memuse=8)
def test_hash(self, size):
l = [0] * size
- self.failUnlessRaises(TypeError, hash, l)
+ self.assertRaises(TypeError, hash, l)
@bigmemtest(minsize=_2G + 10, memuse=8)
def test_index_and_slice(self, size):
@@ -984,7 +984,7 @@
# Like test_concat, split in two.
def basic_test_repeat(self, size):
l = [] * size
- self.failIf(l)
+ self.assertFalse(l)
l = [''] * size
self.assertEquals(len(l), size)
l = l * 2
@@ -1002,13 +1002,13 @@
l = ['']
l *= size
self.assertEquals(len(l), size)
- self.failUnless(l[0] is l[-1])
+ self.assertTrue(l[0] is l[-1])
del l
l = [''] * size
l *= 2
self.assertEquals(len(l), size * 2)
- self.failUnless(l[size - 1] is l[-1])
+ self.assertTrue(l[size - 1] is l[-1])
@bigmemtest(minsize=_2G // 2 + 2, memuse=16)
def test_inplace_repeat_small(self, size):
@@ -1042,8 +1042,8 @@
l = [object()] * size
l.append(object())
self.assertEquals(len(l), size+1)
- self.failUnless(l[-3] is l[-2])
- self.failIf(l[-2] is l[-1])
+ self.assertTrue(l[-3] is l[-2])
+ self.assertFalse(l[-2] is l[-1])
@bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5)
def test_count(self, size):
@@ -1055,8 +1055,8 @@
l = [object] * size
l.extend(l)
self.assertEquals(len(l), size * 2)
- self.failUnless(l[0] is l[-1])
- self.failUnless(l[size - 1] is l[size + 1])
+ self.assertTrue(l[0] is l[-1])
+ self.assertTrue(l[size - 1] is l[size + 1])
@bigmemtest(minsize=_2G // 2 + 2, memuse=16)
def test_extend_small(self, size):
Modified: python/branches/py3k/Lib/test/test_binascii.py
==============================================================================
--- python/branches/py3k/Lib/test/test_binascii.py (original)
+++ python/branches/py3k/Lib/test/test_binascii.py Wed Jul 1 01:06:06 2009
@@ -14,8 +14,8 @@
def test_exceptions(self):
# Check module exceptions
- self.assert_(issubclass(binascii.Error, Exception))
- self.assert_(issubclass(binascii.Incomplete, Exception))
+ self.assertTrue(issubclass(binascii.Error, Exception))
+ self.assertTrue(issubclass(binascii.Incomplete, Exception))
def test_functions(self):
# Check presence of all functions
@@ -26,10 +26,10 @@
prefixes.extend(["crc_", "rlecode_", "rledecode_"])
for prefix in prefixes:
name = prefix + suffix
- self.assert_(hasattr(getattr(binascii, name), '__call__'))
+ self.assertTrue(hasattr(getattr(binascii, name), '__call__'))
self.assertRaises(TypeError, getattr(binascii, name))
for name in ("hexlify", "unhexlify"):
- self.assert_(hasattr(getattr(binascii, name), '__call__'))
+ self.assertTrue(hasattr(getattr(binascii, name), '__call__'))
self.assertRaises(TypeError, getattr(binascii, name))
def test_base64valid(self):
Modified: python/branches/py3k/Lib/test/test_binop.py
==============================================================================
--- python/branches/py3k/Lib/test/test_binop.py (original)
+++ python/branches/py3k/Lib/test/test_binop.py Wed Jul 1 01:06:06 2009
@@ -210,10 +210,10 @@
self.assertEqual(gcd(-10, -2), -2)
for i in range(1, 20):
for j in range(1, 20):
- self.assert_(gcd(i, j) > 0)
- self.assert_(gcd(-i, j) < 0)
- self.assert_(gcd(i, -j) > 0)
- self.assert_(gcd(-i, -j) < 0)
+ self.assertTrue(gcd(i, j) > 0)
+ self.assertTrue(gcd(-i, j) < 0)
+ self.assertTrue(gcd(i, -j) > 0)
+ self.assertTrue(gcd(-i, -j) < 0)
def test_constructor(self):
a = Rat(10, 15)
Modified: python/branches/py3k/Lib/test/test_bisect.py
==============================================================================
--- python/branches/py3k/Lib/test/test_bisect.py (original)
+++ python/branches/py3k/Lib/test/test_bisect.py Wed Jul 1 01:06:06 2009
@@ -130,14 +130,14 @@
elem = randrange(-1, n+1)
ip = self.module.bisect_left(data, elem)
if ip < len(data):
- self.failUnless(elem <= data[ip])
+ self.assertTrue(elem <= data[ip])
if ip > 0:
- self.failUnless(data[ip-1] < elem)
+ self.assertTrue(data[ip-1] < elem)
ip = self.module.bisect_right(data, elem)
if ip < len(data):
- self.failUnless(elem < data[ip])
+ self.assertTrue(elem < data[ip])
if ip > 0:
- self.failUnless(data[ip-1] <= elem)
+ self.assertTrue(data[ip-1] <= elem)
def test_optionalSlicing(self):
for func, data, elem, expected in self.precomputedCases:
@@ -146,15 +146,15 @@
for hi in range(3,8):
hi = min(len(data), hi)
ip = func(data, elem, lo, hi)
- self.failUnless(lo <= ip <= hi)
+ self.assertTrue(lo <= ip <= hi)
if func is self.module.bisect_left and ip < hi:
- self.failUnless(elem <= data[ip])
+ self.assertTrue(elem <= data[ip])
if func is self.module.bisect_left and ip > lo:
- self.failUnless(data[ip-1] < elem)
+ self.assertTrue(data[ip-1] < elem)
if func is self.module.bisect_right and ip < hi:
- self.failUnless(elem < data[ip])
+ self.assertTrue(elem < data[ip])
if func is self.module.bisect_right and ip > lo:
- self.failUnless(data[ip-1] <= elem)
+ self.assertTrue(data[ip-1] <= elem)
self.assertEqual(ip, max(lo, min(hi, expected)))
def test_backcompatibility(self):
Modified: python/branches/py3k/Lib/test/test_bool.py
==============================================================================
--- python/branches/py3k/Lib/test/test_bool.py (original)
+++ python/branches/py3k/Lib/test/test_bool.py Wed Jul 1 01:06:06 2009
@@ -8,10 +8,10 @@
class BoolTest(unittest.TestCase):
def assertIs(self, a, b):
- self.assert_(a is b)
+ self.assertTrue(a is b)
def assertIsNot(self, a, b):
- self.assert_(a is not b)
+ self.assertTrue(a is not b)
def test_subclass(self):
try:
@@ -221,15 +221,15 @@
def test_boolean(self):
self.assertEqual(True & 1, 1)
- self.assert_(not isinstance(True & 1, bool))
+ self.assertTrue(not isinstance(True & 1, bool))
self.assertIs(True & True, True)
self.assertEqual(True | 1, 1)
- self.assert_(not isinstance(True | 1, bool))
+ self.assertTrue(not isinstance(True | 1, bool))
self.assertIs(True | True, True)
self.assertEqual(True ^ 1, 0)
- self.assert_(not isinstance(True ^ 1, bool))
+ self.assertTrue(not isinstance(True ^ 1, bool))
self.assertIs(True ^ True, False)
def test_fileclosed(self):
Modified: python/branches/py3k/Lib/test/test_bufio.py
==============================================================================
--- python/branches/py3k/Lib/test/test_bufio.py (original)
+++ python/branches/py3k/Lib/test/test_bufio.py Wed Jul 1 01:06:06 2009
@@ -34,7 +34,7 @@
line = f.readline()
self.assertEqual(line, s)
line = f.readline()
- self.assert_(not line) # Must be at EOF
+ self.assertTrue(not line) # Must be at EOF
f.close()
finally:
support.unlink(support.TESTFN)
Modified: python/branches/py3k/Lib/test/test_builtin.py
==============================================================================
--- python/branches/py3k/Lib/test/test_builtin.py (original)
+++ python/branches/py3k/Lib/test/test_builtin.py Wed Jul 1 01:06:06 2009
@@ -176,24 +176,24 @@
def test_neg(self):
x = -sys.maxsize-1
- self.assert_(isinstance(x, int))
+ self.assertTrue(isinstance(x, int))
self.assertEqual(-x, sys.maxsize+1)
# XXX(nnorwitz): This test case for callable should probably be removed.
def test_callable(self):
- self.assert_(hasattr(len, '__call__'))
+ self.assertTrue(hasattr(len, '__call__'))
def f(): pass
- self.assert_(hasattr(f, '__call__'))
+ self.assertTrue(hasattr(f, '__call__'))
class C:
def meth(self): pass
- self.assert_(hasattr(C, '__call__'))
+ self.assertTrue(hasattr(C, '__call__'))
x = C()
- self.assert_(hasattr(x.meth, '__call__'))
- self.assert_(not hasattr(x, '__call__'))
+ self.assertTrue(hasattr(x.meth, '__call__'))
+ self.assertTrue(not hasattr(x, '__call__'))
class D(C):
def __call__(self): pass
y = D()
- self.assert_(hasattr(y, '__call__'))
+ self.assertTrue(hasattr(y, '__call__'))
y()
def test_chr(self):
@@ -220,7 +220,7 @@
self.assertRaises((OverflowError, ValueError), chr, 2**32)
def test_cmp(self):
- self.assert_(not hasattr(builtins, "cmp"))
+ self.assertTrue(not hasattr(builtins, "cmp"))
def test_compile(self):
compile('print(1)\n', '', 'exec')
@@ -252,11 +252,11 @@
# dir() - local scope
local_var = 1
- self.assert_('local_var' in dir())
+ self.assertTrue('local_var' in dir())
# dir(module)
import sys
- self.assert_('exit' in dir(sys))
+ self.assertTrue('exit' in dir(sys))
# dir(module_with_invalid__dict__)
import types
@@ -266,8 +266,8 @@
self.assertRaises(TypeError, dir, f)
# dir(type)
- self.assert_("strip" in dir(str))
- self.assert_("__mro__" not in dir(str))
+ self.assertTrue("strip" in dir(str))
+ self.assertTrue("__mro__" not in dir(str))
# dir(obj)
class Foo(object):
@@ -276,13 +276,13 @@
self.y = 8
self.z = 9
f = Foo()
- self.assert_("y" in dir(f))
+ self.assertTrue("y" in dir(f))
# dir(obj_no__dict__)
class Foo(object):
__slots__ = []
f = Foo()
- self.assert_("__repr__" in dir(f))
+ self.assertTrue("__repr__" in dir(f))
# dir(obj_no__class__with__dict__)
# (an ugly trick to cause getattr(f, "__class__") to fail)
@@ -291,15 +291,15 @@
def __init__(self):
self.bar = "wow"
f = Foo()
- self.assert_("__repr__" not in dir(f))
- self.assert_("bar" in dir(f))
+ self.assertTrue("__repr__" not in dir(f))
+ self.assertTrue("bar" in dir(f))
# dir(obj_using __dir__)
class Foo(object):
def __dir__(self):
return ["kan", "ga", "roo"]
f = Foo()
- self.assert_(dir(f) == ["ga", "kan", "roo"])
+ self.assertTrue(dir(f) == ["ga", "kan", "roo"])
# dir(obj__dir__not_list)
class Foo(object):
@@ -334,10 +334,10 @@
self.assertEqual(divmod(-sys.maxsize-1, -1),
(sys.maxsize+1, 0))
- self.assert_(not fcmp(divmod(3.25, 1.0), (3.0, 0.25)))
- self.assert_(not fcmp(divmod(-3.25, 1.0), (-4.0, 0.75)))
- self.assert_(not fcmp(divmod(3.25, -1.0), (-4.0, -0.75)))
- self.assert_(not fcmp(divmod(-3.25, -1.0), (3.0, -0.25)))
+ self.assertTrue(not fcmp(divmod(3.25, 1.0), (3.0, 0.25)))
+ self.assertTrue(not fcmp(divmod(-3.25, 1.0), (-4.0, 0.75)))
+ self.assertTrue(not fcmp(divmod(3.25, -1.0), (-4.0, -0.75)))
+ self.assertTrue(not fcmp(divmod(-3.25, -1.0), (3.0, -0.25)))
self.assertRaises(TypeError, divmod)
@@ -489,7 +489,7 @@
def test_getattr(self):
import sys
- self.assert_(getattr(sys, 'stdout') is sys.stdout)
+ self.assertTrue(getattr(sys, 'stdout') is sys.stdout)
self.assertRaises(TypeError, getattr, sys, 1)
self.assertRaises(TypeError, getattr, sys, 1, "foo")
self.assertRaises(TypeError, getattr)
@@ -497,7 +497,7 @@
def test_hasattr(self):
import sys
- self.assert_(hasattr(sys, 'stdout'))
+ self.assertTrue(hasattr(sys, 'stdout'))
self.assertRaises(TypeError, hasattr, sys, 1)
self.assertRaises(TypeError, hasattr)
self.assertEqual(False, hasattr(sys, chr(sys.maxunicode)))
@@ -575,11 +575,11 @@
c = C()
d = D()
e = E()
- self.assert_(isinstance(c, C))
- self.assert_(isinstance(d, C))
- self.assert_(not isinstance(e, C))
- self.assert_(not isinstance(c, D))
- self.assert_(not isinstance('foo', E))
+ self.assertTrue(isinstance(c, C))
+ self.assertTrue(isinstance(d, C))
+ self.assertTrue(not isinstance(e, C))
+ self.assertTrue(not isinstance(c, D))
+ self.assertTrue(not isinstance('foo', E))
self.assertRaises(TypeError, isinstance, E, 'foo')
self.assertRaises(TypeError, isinstance)
@@ -593,9 +593,9 @@
c = C()
d = D()
e = E()
- self.assert_(issubclass(D, C))
- self.assert_(issubclass(C, C))
- self.assert_(not issubclass(C, D))
+ self.assertTrue(issubclass(D, C))
+ self.assertTrue(issubclass(C, C))
+ self.assertTrue(not issubclass(C, D))
self.assertRaises(TypeError, issubclass, 'foo', E)
self.assertRaises(TypeError, issubclass, E, 'foo')
self.assertRaises(TypeError, issubclass)
@@ -958,18 +958,18 @@
self.assertEqual(list(range(a+4, a, -2)), [a+4, a+2])
seq = list(range(a, b, c))
- self.assert_(a in seq)
- self.assert_(b not in seq)
+ self.assertTrue(a in seq)
+ self.assertTrue(b not in seq)
self.assertEqual(len(seq), 2)
seq = list(range(b, a, -c))
- self.assert_(b in seq)
- self.assert_(a not in seq)
+ self.assertTrue(b in seq)
+ self.assertTrue(a not in seq)
self.assertEqual(len(seq), 2)
seq = list(range(-a, -b, -c))
- self.assert_(-a in seq)
- self.assert_(-b not in seq)
+ self.assertTrue(-a in seq)
+ self.assertTrue(-b not in seq)
self.assertEqual(len(seq), 2)
self.assertRaises(TypeError, range)
Modified: python/branches/py3k/Lib/test/test_bytes.py
==============================================================================
--- python/branches/py3k/Lib/test/test_bytes.py (original)
+++ python/branches/py3k/Lib/test/test_bytes.py Wed Jul 1 01:06:06 2009
@@ -102,22 +102,22 @@
b3 = self.type2test([1, 3])
self.assertEqual(b1, b2)
- self.failUnless(b2 != b3)
- self.failUnless(b1 <= b2)
- self.failUnless(b1 <= b3)
- self.failUnless(b1 < b3)
- self.failUnless(b1 >= b2)
- self.failUnless(b3 >= b2)
- self.failUnless(b3 > b2)
-
- self.failIf(b1 != b2)
- self.failIf(b2 == b3)
- self.failIf(b1 > b2)
- self.failIf(b1 > b3)
- self.failIf(b1 >= b3)
- self.failIf(b1 < b2)
- self.failIf(b3 < b2)
- self.failIf(b3 <= b2)
+ self.assertTrue(b2 != b3)
+ self.assertTrue(b1 <= b2)
+ self.assertTrue(b1 <= b3)
+ self.assertTrue(b1 < b3)
+ self.assertTrue(b1 >= b2)
+ self.assertTrue(b3 >= b2)
+ self.assertTrue(b3 > b2)
+
+ self.assertFalse(b1 != b2)
+ self.assertFalse(b2 == b3)
+ self.assertFalse(b1 > b2)
+ self.assertFalse(b1 > b3)
+ self.assertFalse(b1 >= b3)
+ self.assertFalse(b1 < b2)
+ self.assertFalse(b3 < b2)
+ self.assertFalse(b3 <= b2)
def test_compare_to_str(self):
warnings.simplefilter('ignore', BytesWarning)
@@ -220,27 +220,27 @@
def test_contains(self):
b = self.type2test(b"abc")
- self.failUnless(ord('a') in b)
- self.failUnless(int(ord('a')) in b)
- self.failIf(200 in b)
- self.failIf(200 in b)
+ self.assertTrue(ord('a') in b)
+ self.assertTrue(int(ord('a')) in b)
+ self.assertFalse(200 in b)
+ self.assertFalse(200 in b)
self.assertRaises(ValueError, lambda: 300 in b)
self.assertRaises(ValueError, lambda: -1 in b)
self.assertRaises(TypeError, lambda: None in b)
self.assertRaises(TypeError, lambda: float(ord('a')) in b)
self.assertRaises(TypeError, lambda: "a" in b)
for f in bytes, bytearray:
- self.failUnless(f(b"") in b)
- self.failUnless(f(b"a") in b)
- self.failUnless(f(b"b") in b)
- self.failUnless(f(b"c") in b)
- self.failUnless(f(b"ab") in b)
- self.failUnless(f(b"bc") in b)
- self.failUnless(f(b"abc") in b)
- self.failIf(f(b"ac") in b)
- self.failIf(f(b"d") in b)
- self.failIf(f(b"dab") in b)
- self.failIf(f(b"abd") in b)
+ self.assertTrue(f(b"") in b)
+ self.assertTrue(f(b"a") in b)
+ self.assertTrue(f(b"b") in b)
+ self.assertTrue(f(b"c") in b)
+ self.assertTrue(f(b"ab") in b)
+ self.assertTrue(f(b"bc") in b)
+ self.assertTrue(f(b"abc") in b)
+ self.assertFalse(f(b"ac") in b)
+ self.assertFalse(f(b"d") in b)
+ self.assertFalse(f(b"dab") in b)
+ self.assertFalse(f(b"abd") in b)
def test_fromhex(self):
self.assertRaises(TypeError, self.type2test.fromhex)
@@ -626,7 +626,7 @@
b += b"def"
self.assertEqual(b, b"abcdef")
self.assertEqual(b, b1)
- self.failUnless(b is b1)
+ self.assertTrue(b is b1)
b += b"xyz"
self.assertEqual(b, b"abcdefxyz")
try:
@@ -642,7 +642,7 @@
b *= 3
self.assertEqual(b, b"abcabcabc")
self.assertEqual(b, b1)
- self.failUnless(b is b1)
+ self.assertTrue(b is b1)
def test_irepeat_1char(self):
b = bytearray(b"x")
@@ -650,17 +650,17 @@
b *= 100
self.assertEqual(b, b"x"*100)
self.assertEqual(b, b1)
- self.failUnless(b is b1)
+ self.assertTrue(b is b1)
def test_alloc(self):
b = bytearray()
alloc = b.__alloc__()
- self.assert_(alloc >= 0)
+ self.assertTrue(alloc >= 0)
seq = [alloc]
for i in range(100):
b += b"x"
alloc = b.__alloc__()
- self.assert_(alloc >= len(b))
+ self.assertTrue(alloc >= len(b))
if alloc not in seq:
seq.append(alloc)
@@ -759,7 +759,7 @@
a, b, c = bytearray(b"x").partition(b"y")
self.assertEqual(b, b"")
self.assertEqual(c, b"")
- self.assert_(b is not c)
+ self.assertTrue(b is not c)
b += b"!"
self.assertEqual(c, b"")
a, b, c = bytearray(b"x").partition(b"y")
@@ -769,7 +769,7 @@
b, c, a = bytearray(b"x").rpartition(b"y")
self.assertEqual(b, b"")
self.assertEqual(c, b"")
- self.assert_(b is not c)
+ self.assertTrue(b is not c)
b += b"!"
self.assertEqual(c, b"")
c, b, a = bytearray(b"x").rpartition(b"y")
@@ -860,10 +860,10 @@
self.assertEqual(bytes(b"abc") <= b"ab", False)
def test_doc(self):
- self.failUnless(bytearray.__doc__ != None)
- self.failUnless(bytearray.__doc__.startswith("bytearray("), bytearray.__doc__)
- self.failUnless(bytes.__doc__ != None)
- self.failUnless(bytes.__doc__.startswith("bytes("), bytes.__doc__)
+ self.assertTrue(bytearray.__doc__ != None)
+ self.assertTrue(bytearray.__doc__.startswith("bytearray("), bytearray.__doc__)
+ self.assertTrue(bytes.__doc__ != None)
+ self.assertTrue(bytes.__doc__.startswith("bytes("), bytes.__doc__)
def test_from_bytearray(self):
sample = bytes(b"Hello world\n\x80\x81\xfe\xff")
@@ -920,7 +920,7 @@
def test_return_self(self):
# bytearray.replace must always return a new bytearray
b = bytearray()
- self.failIf(b.replace(b'', b'') is b)
+ self.assertFalse(b.replace(b'', b'') is b)
def test_compare(self):
if sys.flags.bytes_warning:
@@ -997,20 +997,20 @@
class ByteArraySubclassTest(unittest.TestCase):
def test_basic(self):
- self.assert_(issubclass(ByteArraySubclass, bytearray))
- self.assert_(isinstance(ByteArraySubclass(), bytearray))
+ self.assertTrue(issubclass(ByteArraySubclass, bytearray))
+ self.assertTrue(isinstance(ByteArraySubclass(), bytearray))
a, b = b"abcd", b"efgh"
_a, _b = ByteArraySubclass(a), ByteArraySubclass(b)
# test comparison operators with subclass instances
- self.assert_(_a == _a)
- self.assert_(_a != _b)
- self.assert_(_a < _b)
- self.assert_(_a <= _b)
- self.assert_(_b >= _a)
- self.assert_(_b > _a)
- self.assert_(_a is not a)
+ self.assertTrue(_a == _a)
+ self.assertTrue(_a != _b)
+ self.assertTrue(_a < _b)
+ self.assertTrue(_a <= _b)
+ self.assertTrue(_b >= _a)
+ self.assertTrue(_b > _a)
+ self.assertTrue(_a is not a)
# test concat of subclass instances
self.assertEqual(a + b, _a + _b)
@@ -1018,7 +1018,7 @@
self.assertEqual(a + b, _a + b)
# test repeat
- self.assert_(a*5 == _a*5)
+ self.assertTrue(a*5 == _a*5)
def test_join(self):
# Make sure join returns a NEW object for single item sequences
@@ -1026,12 +1026,12 @@
# Make sure that it is of the appropriate type.
s1 = ByteArraySubclass(b"abcd")
s2 = bytearray().join([s1])
- self.assert_(s1 is not s2)
- self.assert_(type(s2) is bytearray, type(s2))
+ self.assertTrue(s1 is not s2)
+ self.assertTrue(type(s2) is bytearray, type(s2))
# Test reverse, calling join on subclass
s3 = s1.join([b"abcd"])
- self.assert_(type(s3) is bytearray)
+ self.assertTrue(type(s3) is bytearray)
def test_pickle(self):
a = ByteArraySubclass(b"abcd")
Modified: python/branches/py3k/Lib/test/test_capi.py
==============================================================================
--- python/branches/py3k/Lib/test/test_capi.py (original)
+++ python/branches/py3k/Lib/test/test_capi.py Wed Jul 1 01:06:06 2009
@@ -24,7 +24,7 @@
def test_instancemethod(self):
inst = InstanceMethod()
self.assertEqual(id(inst), inst.id())
- self.assert_(inst.testfunction() is inst)
+ self.assertTrue(inst.testfunction() is inst)
self.assertEqual(inst.testfunction.__doc__, testfunction.__doc__)
self.assertEqual(InstanceMethod.testfunction.__doc__, testfunction.__doc__)
@@ -64,7 +64,7 @@
if context and not context.event.is_set():
continue
count += 1
- self.failUnless(count < 10000,
+ self.assertTrue(count < 10000,
"timeout waiting for %i callbacks, got %i"%(n, len(l)))
if False and support.verbose:
print("(%i)"%(len(l),))
Modified: python/branches/py3k/Lib/test/test_cfgparser.py
==============================================================================
--- python/branches/py3k/Lib/test/test_cfgparser.py (original)
+++ python/branches/py3k/Lib/test/test_cfgparser.py Wed Jul 1 01:06:06 2009
@@ -76,16 +76,16 @@
eq(cf.get('Spaces', 'key with spaces'), 'value')
eq(cf.get('Spaces', 'another with spaces'), 'splat!')
- self.failIf('__name__' in cf.options("Foo Bar"),
+ self.assertFalse('__name__' in cf.options("Foo Bar"),
'__name__ "option" should not be exposed by the API!')
# Make sure the right things happen for remove_option();
# added to include check for SourceForge bug #123324:
- self.failUnless(cf.remove_option('Foo Bar', 'foo'),
+ self.assertTrue(cf.remove_option('Foo Bar', 'foo'),
"remove_option() failed to report existence of option")
- self.failIf(cf.has_option('Foo Bar', 'foo'),
+ self.assertFalse(cf.has_option('Foo Bar', 'foo'),
"remove_option() failed to remove option")
- self.failIf(cf.remove_option('Foo Bar', 'foo'),
+ self.assertFalse(cf.remove_option('Foo Bar', 'foo'),
"remove_option() failed to report non-existence of option"
" that was removed")
@@ -107,10 +107,10 @@
eq(cf.options("a"), ["b"])
eq(cf.get("a", "b"), "value",
"could not locate option, expecting case-insensitive option names")
- self.failUnless(cf.has_option("a", "b"))
+ self.assertTrue(cf.has_option("a", "b"))
cf.set("A", "A-B", "A-B value")
for opt in ("a-b", "A-b", "a-B", "A-B"):
- self.failUnless(
+ self.assertTrue(
cf.has_option("A", opt),
"has_option() returned false for option which should exist")
eq(cf.options("A"), ["a-b"])
@@ -127,7 +127,7 @@
# SF bug #561822:
cf = self.fromstring("[section]\nnekey=nevalue\n",
defaults={"key":"value"})
- self.failUnless(cf.has_option("section", "Key"))
+ self.assertTrue(cf.has_option("section", "Key"))
def test_default_case_sensitivity(self):
@@ -163,7 +163,7 @@
cf = self.newconfig()
self.assertEqual(cf.sections(), [],
"new ConfigParser should have no defined sections")
- self.failIf(cf.has_section("Foo"),
+ self.assertFalse(cf.has_section("Foo"),
"new ConfigParser should have no acknowledged sections")
self.assertRaises(configparser.NoSectionError,
cf.options, "Foo")
@@ -202,8 +202,8 @@
"E5=FALSE AND MORE"
)
for x in range(1, 5):
- self.failUnless(cf.getboolean('BOOLTEST', 't%d' % x))
- self.failIf(cf.getboolean('BOOLTEST', 'f%d' % x))
+ self.assertTrue(cf.getboolean('BOOLTEST', 't%d' % x))
+ self.assertFalse(cf.getboolean('BOOLTEST', 'f%d' % x))
self.assertRaises(ValueError,
cf.getboolean, 'BOOLTEST', 'e%d' % x)
Modified: python/branches/py3k/Lib/test/test_cgi.py
==============================================================================
--- python/branches/py3k/Lib/test/test_cgi.py (original)
+++ python/branches/py3k/Lib/test/test_cgi.py Wed Jul 1 01:06:06 2009
@@ -143,7 +143,7 @@
# test individual fields
for key in expect.keys():
expect_val = expect[key]
- self.assert_(key in fs)
+ self.assertTrue(key in fs)
if len(expect_val) > 1:
self.assertEqual(fs.getvalue(key), expect_val)
else:
@@ -194,7 +194,7 @@
# if we're not chunking properly, readline is only called twice
# (by read_binary); if we are chunking properly, it will be called 5 times
# as long as the chunksize is 1 << 16.
- self.assert_(f.numcalls > 2)
+ self.assertTrue(f.numcalls > 2)
def test_fieldstorage_multipart(self):
#Test basic FieldStorage multipart parsing
Modified: python/branches/py3k/Lib/test/test_cmath.py
==============================================================================
--- python/branches/py3k/Lib/test/test_cmath.py (original)
+++ python/branches/py3k/Lib/test/test_cmath.py Wed Jul 1 01:06:06 2009
@@ -412,7 +412,7 @@
# real or imaginary part NaN
for z in complex_nans:
- self.assert_(math.isnan(phase(z)))
+ self.assertTrue(math.isnan(phase(z)))
def test_abs(self):
# zeros
@@ -425,18 +425,18 @@
# real or imaginary part NaN
self.assertEqual(abs(complex(NAN, -INF)), INF)
- self.assert_(math.isnan(abs(complex(NAN, -2.3))))
- self.assert_(math.isnan(abs(complex(NAN, -0.0))))
- self.assert_(math.isnan(abs(complex(NAN, 0.0))))
- self.assert_(math.isnan(abs(complex(NAN, 2.3))))
+ self.assertTrue(math.isnan(abs(complex(NAN, -2.3))))
+ self.assertTrue(math.isnan(abs(complex(NAN, -0.0))))
+ self.assertTrue(math.isnan(abs(complex(NAN, 0.0))))
+ self.assertTrue(math.isnan(abs(complex(NAN, 2.3))))
self.assertEqual(abs(complex(NAN, INF)), INF)
self.assertEqual(abs(complex(-INF, NAN)), INF)
- self.assert_(math.isnan(abs(complex(-2.3, NAN))))
- self.assert_(math.isnan(abs(complex(-0.0, NAN))))
- self.assert_(math.isnan(abs(complex(0.0, NAN))))
- self.assert_(math.isnan(abs(complex(2.3, NAN))))
+ self.assertTrue(math.isnan(abs(complex(-2.3, NAN))))
+ self.assertTrue(math.isnan(abs(complex(-0.0, NAN))))
+ self.assertTrue(math.isnan(abs(complex(0.0, NAN))))
+ self.assertTrue(math.isnan(abs(complex(2.3, NAN))))
self.assertEqual(abs(complex(INF, NAN)), INF)
- self.assert_(math.isnan(abs(complex(NAN, NAN))))
+ self.assertTrue(math.isnan(abs(complex(NAN, NAN))))
# result overflows
if float.__getformat__("double").startswith("IEEE"):
@@ -455,26 +455,26 @@
self.assertCEqual(rect(1, -pi/2), (0, -1.))
def test_isnan(self):
- self.failIf(cmath.isnan(1))
- self.failIf(cmath.isnan(1j))
- self.failIf(cmath.isnan(INF))
- self.assert_(cmath.isnan(NAN))
- self.assert_(cmath.isnan(complex(NAN, 0)))
- self.assert_(cmath.isnan(complex(0, NAN)))
- self.assert_(cmath.isnan(complex(NAN, NAN)))
- self.assert_(cmath.isnan(complex(NAN, INF)))
- self.assert_(cmath.isnan(complex(INF, NAN)))
+ self.assertFalse(cmath.isnan(1))
+ self.assertFalse(cmath.isnan(1j))
+ self.assertFalse(cmath.isnan(INF))
+ self.assertTrue(cmath.isnan(NAN))
+ self.assertTrue(cmath.isnan(complex(NAN, 0)))
+ self.assertTrue(cmath.isnan(complex(0, NAN)))
+ self.assertTrue(cmath.isnan(complex(NAN, NAN)))
+ self.assertTrue(cmath.isnan(complex(NAN, INF)))
+ self.assertTrue(cmath.isnan(complex(INF, NAN)))
def test_isinf(self):
- self.failIf(cmath.isinf(1))
- self.failIf(cmath.isinf(1j))
- self.failIf(cmath.isinf(NAN))
- self.assert_(cmath.isinf(INF))
- self.assert_(cmath.isinf(complex(INF, 0)))
- self.assert_(cmath.isinf(complex(0, INF)))
- self.assert_(cmath.isinf(complex(INF, INF)))
- self.assert_(cmath.isinf(complex(NAN, INF)))
- self.assert_(cmath.isinf(complex(INF, NAN)))
+ self.assertFalse(cmath.isinf(1))
+ self.assertFalse(cmath.isinf(1j))
+ self.assertFalse(cmath.isinf(NAN))
+ self.assertTrue(cmath.isinf(INF))
+ self.assertTrue(cmath.isinf(complex(INF, 0)))
+ self.assertTrue(cmath.isinf(complex(0, INF)))
+ self.assertTrue(cmath.isinf(complex(INF, INF)))
+ self.assertTrue(cmath.isinf(complex(NAN, INF)))
+ self.assertTrue(cmath.isinf(complex(INF, NAN)))
def test_main():
Modified: python/branches/py3k/Lib/test/test_cmd_line.py
==============================================================================
--- python/branches/py3k/Lib/test/test_cmd_line.py (original)
+++ python/branches/py3k/Lib/test/test_cmd_line.py Wed Jul 1 01:06:06 2009
@@ -169,7 +169,7 @@
p.stdin.flush()
data, rc = _kill_python_and_exit_code(p)
self.assertEqual(rc, 0)
- self.assert_(data.startswith(b'x'), data)
+ self.assertTrue(data.startswith(b'x'), data)
def test_large_PYTHONPATH(self):
with test.support.EnvironmentVarGuard() as env:
@@ -178,8 +178,8 @@
env['PYTHONPATH'] = path1 + os.pathsep + path2
p = _spawn_python('-S', '-c', 'import sys; print(sys.path)')
stdout, _ = p.communicate()
- self.assert_(path1.encode('ascii') in stdout)
- self.assert_(path2.encode('ascii') in stdout)
+ self.assertTrue(path1.encode('ascii') in stdout)
+ self.assertTrue(path2.encode('ascii') in stdout)
def test_main():
Modified: python/branches/py3k/Lib/test/test_cmd_line_script.py
==============================================================================
--- python/branches/py3k/Lib/test/test_cmd_line_script.py (original)
+++ python/branches/py3k/Lib/test/test_cmd_line_script.py Wed Jul 1 01:06:06 2009
@@ -154,9 +154,9 @@
print(printed_file)
print(printed_package)
print(printed_argv0)
- self.assert_(printed_file in data)
- self.assert_(printed_package in data)
- self.assert_(printed_argv0 in data)
+ self.assertTrue(printed_file in data)
+ self.assertTrue(printed_package in data)
+ self.assertTrue(printed_argv0 in data)
def _check_import_error(self, script_name, expected_msg,
*cmd_line_switches):
@@ -166,7 +166,7 @@
print('Output from test script %r:' % script_name)
print(data)
print('Expected output: %r' % expected_msg)
- self.assert_(expected_msg in data)
+ self.assertTrue(expected_msg in data)
def test_basic_script(self):
with temp_dir() as script_dir:
Modified: python/branches/py3k/Lib/test/test_codecs.py
==============================================================================
--- python/branches/py3k/Lib/test/test_codecs.py (original)
+++ python/branches/py3k/Lib/test/test_codecs.py Wed Jul 1 01:06:06 2009
@@ -29,14 +29,14 @@
d = codecs.getincrementaldecoder(encoding)()
part1 = d.decode(s[:i])
state = d.getstate()
- self.assert_(isinstance(state[1], int))
+ self.assertTrue(isinstance(state[1], int))
# Check that the condition stated in the documentation for
# IncrementalDecoder.getstate() holds
if not state[1]:
# reset decoder to the default state without anything buffered
d.setstate((state[0][:0], 0))
# Feeding the previous input may not produce any output
- self.assert_(not d.decode(state[0]))
+ self.assertTrue(not d.decode(state[0]))
# The decoder must return to the same state
self.assertEqual(state, d.getstate())
# Create a new decoder and set it to the state
@@ -296,7 +296,7 @@
f.write("spam")
d = s.getvalue()
# check whether there is exactly one BOM in it
- self.assert_(d == self.spamle or d == self.spambe)
+ self.assertTrue(d == self.spamle or d == self.spambe)
# try to read it back
s = io.BytesIO(d)
f = reader(s)
@@ -429,7 +429,7 @@
f.write("spam")
d = s.getvalue()
# check whether there is exactly one BOM in it
- self.assert_(d == self.spamle or d == self.spambe)
+ self.assertTrue(d == self.spamle or d == self.spambe)
# try to read it back
s = io.BytesIO(d)
f = reader(s)
@@ -1335,7 +1335,7 @@
for c in s:
writer.write(c)
chunk = q.read()
- self.assert_(type(chunk) is bytes, type(chunk))
+ self.assertTrue(type(chunk) is bytes, type(chunk))
encodedresult += chunk
q = Queue(b"")
reader = codecs.getreader(encoding)(q)
Modified: python/branches/py3k/Lib/test/test_codeop.py
==============================================================================
--- python/branches/py3k/Lib/test/test_codeop.py (original)
+++ python/branches/py3k/Lib/test/test_codeop.py Wed Jul 1 01:06:06 2009
@@ -23,7 +23,7 @@
'''succeed iff str is a valid piece of code'''
if is_jython:
code = compile_command(str, "<input>", symbol)
- self.assert_(code)
+ self.assertTrue(code)
if symbol == "single":
d,r = {},{}
saved_stdout = sys.stdout
@@ -52,9 +52,9 @@
compile_command(str,symbol=symbol)
self.fail("No exception thrown for invalid code")
except SyntaxError:
- self.assert_(is_syntax)
+ self.assertTrue(is_syntax)
except OverflowError:
- self.assert_(not is_syntax)
+ self.assertTrue(not is_syntax)
def test_valid(self):
av = self.assertValid
Modified: python/branches/py3k/Lib/test/test_collections.py
==============================================================================
--- python/branches/py3k/Lib/test/test_collections.py (original)
+++ python/branches/py3k/Lib/test/test_collections.py Wed Jul 1 01:06:06 2009
@@ -44,9 +44,9 @@
namedtuple('_', 'a b c') # Test leading underscores in a typename
nt = namedtuple('nt', 'the quick brown fox') # check unicode input
- self.assert_("u'" not in repr(nt._fields))
+ self.assertTrue("u'" not in repr(nt._fields))
nt = namedtuple('nt', ('the', 'quick')) # check unicode input
- self.assert_("u'" not in repr(nt._fields))
+ self.assertTrue("u'" not in repr(nt._fields))
self.assertRaises(TypeError, Point._make, [11]) # catch too few args
self.assertRaises(TypeError, Point._make, [11, 22, 33]) # catch too many args
@@ -75,8 +75,8 @@
self.assertRaises(TypeError, eval, 'Point(XXX=1, y=2)', locals()) # wrong keyword argument
self.assertRaises(TypeError, eval, 'Point(x=1)', locals()) # missing keyword argument
self.assertEqual(repr(p), 'Point(x=11, y=22)')
- self.assert_('__dict__' not in dir(p)) # verify instance has no dict
- self.assert_('__weakref__' not in dir(p))
+ self.assertTrue('__dict__' not in dir(p)) # verify instance has no dict
+ self.assertTrue('__weakref__' not in dir(p))
self.assertEqual(p, Point._make([11, 22])) # test _make classmethod
self.assertEqual(p._fields, ('x', 'y')) # test _fields attribute
self.assertEqual(p._replace(x=1), (1, 22)) # test _replace method
@@ -103,7 +103,7 @@
Point = namedtuple('Point', 'x y')
p = Point(11, 22)
- self.assert_(isinstance(p, tuple))
+ self.assertTrue(isinstance(p, tuple))
self.assertEqual(p, (11, 22)) # matches a real tuple
self.assertEqual(tuple(p), (11, 22)) # coercable to a real tuple
self.assertEqual(list(p), [11, 22]) # coercable to a list
@@ -236,8 +236,8 @@
# Check some non-hashables
non_samples = [bytearray(), list(), set(), dict()]
for x in non_samples:
- self.failIf(isinstance(x, Hashable), repr(x))
- self.failIf(issubclass(type(x), Hashable), repr(type(x)))
+ self.assertFalse(isinstance(x, Hashable), repr(x))
+ self.assertFalse(issubclass(type(x), Hashable), repr(type(x)))
# Check some hashables
samples = [None,
int(), float(), complex(),
@@ -246,23 +246,23 @@
int, list, object, type, bytes()
]
for x in samples:
- self.failUnless(isinstance(x, Hashable), repr(x))
- self.failUnless(issubclass(type(x), Hashable), repr(type(x)))
+ self.assertTrue(isinstance(x, Hashable), repr(x))
+ self.assertTrue(issubclass(type(x), Hashable), repr(type(x)))
self.assertRaises(TypeError, Hashable)
# Check direct subclassing
class H(Hashable):
def __hash__(self):
return super().__hash__()
self.assertEqual(hash(H()), 0)
- self.failIf(issubclass(int, H))
+ self.assertFalse(issubclass(int, H))
self.validate_abstract_methods(Hashable, '__hash__')
def test_Iterable(self):
# Check some non-iterables
non_samples = [None, 42, 3.14, 1j]
for x in non_samples:
- self.failIf(isinstance(x, Iterable), repr(x))
- self.failIf(issubclass(type(x), Iterable), repr(type(x)))
+ self.assertFalse(isinstance(x, Iterable), repr(x))
+ self.assertFalse(issubclass(type(x), Iterable), repr(type(x)))
# Check some iterables
samples = [bytes(), str(),
tuple(), list(), set(), frozenset(), dict(),
@@ -271,21 +271,21 @@
(x for x in []),
]
for x in samples:
- self.failUnless(isinstance(x, Iterable), repr(x))
- self.failUnless(issubclass(type(x), Iterable), repr(type(x)))
+ self.assertTrue(isinstance(x, Iterable), repr(x))
+ self.assertTrue(issubclass(type(x), Iterable), repr(type(x)))
# Check direct subclassing
class I(Iterable):
def __iter__(self):
return super().__iter__()
self.assertEqual(list(I()), [])
- self.failIf(issubclass(str, I))
+ self.assertFalse(issubclass(str, I))
self.validate_abstract_methods(Iterable, '__iter__')
def test_Iterator(self):
non_samples = [None, 42, 3.14, 1j, b"", "", (), [], {}, set()]
for x in non_samples:
- self.failIf(isinstance(x, Iterator), repr(x))
- self.failIf(issubclass(type(x), Iterator), repr(type(x)))
+ self.assertFalse(isinstance(x, Iterator), repr(x))
+ self.assertFalse(issubclass(type(x), Iterator), repr(type(x)))
samples = [iter(bytes()), iter(str()),
iter(tuple()), iter(list()), iter(dict()),
iter(set()), iter(frozenset()),
@@ -295,8 +295,8 @@
(x for x in []),
]
for x in samples:
- self.failUnless(isinstance(x, Iterator), repr(x))
- self.failUnless(issubclass(type(x), Iterator), repr(type(x)))
+ self.assertTrue(isinstance(x, Iterator), repr(x))
+ self.assertTrue(issubclass(type(x), Iterator), repr(type(x)))
self.validate_abstract_methods(Iterator, '__next__')
def test_Sized(self):
@@ -305,15 +305,15 @@
(x for x in []),
]
for x in non_samples:
- self.failIf(isinstance(x, Sized), repr(x))
- self.failIf(issubclass(type(x), Sized), repr(type(x)))
+ self.assertFalse(isinstance(x, Sized), repr(x))
+ self.assertFalse(issubclass(type(x), Sized), repr(type(x)))
samples = [bytes(), str(),
tuple(), list(), set(), frozenset(), dict(),
dict().keys(), dict().items(), dict().values(),
]
for x in samples:
- self.failUnless(isinstance(x, Sized), repr(x))
- self.failUnless(issubclass(type(x), Sized), repr(type(x)))
+ self.assertTrue(isinstance(x, Sized), repr(x))
+ self.assertTrue(issubclass(type(x), Sized), repr(type(x)))
self.validate_abstract_methods(Sized, '__len__')
def test_Container(self):
@@ -322,15 +322,15 @@
(x for x in []),
]
for x in non_samples:
- self.failIf(isinstance(x, Container), repr(x))
- self.failIf(issubclass(type(x), Container), repr(type(x)))
+ self.assertFalse(isinstance(x, Container), repr(x))
+ self.assertFalse(issubclass(type(x), Container), repr(type(x)))
samples = [bytes(), str(),
tuple(), list(), set(), frozenset(), dict(),
dict().keys(), dict().items(),
]
for x in samples:
- self.failUnless(isinstance(x, Container), repr(x))
- self.failUnless(issubclass(type(x), Container), repr(type(x)))
+ self.assertTrue(isinstance(x, Container), repr(x))
+ self.assertTrue(issubclass(type(x), Container), repr(type(x)))
self.validate_abstract_methods(Container, '__contains__')
def test_Callable(self):
@@ -340,32 +340,32 @@
(x for x in []),
]
for x in non_samples:
- self.failIf(isinstance(x, Callable), repr(x))
- self.failIf(issubclass(type(x), Callable), repr(type(x)))
+ self.assertFalse(isinstance(x, Callable), repr(x))
+ self.assertFalse(issubclass(type(x), Callable), repr(type(x)))
samples = [lambda: None,
type, int, object,
len,
list.append, [].append,
]
for x in samples:
- self.failUnless(isinstance(x, Callable), repr(x))
- self.failUnless(issubclass(type(x), Callable), repr(type(x)))
+ self.assertTrue(isinstance(x, Callable), repr(x))
+ self.assertTrue(issubclass(type(x), Callable), repr(type(x)))
self.validate_abstract_methods(Callable, '__call__')
def test_direct_subclassing(self):
for B in Hashable, Iterable, Iterator, Sized, Container, Callable:
class C(B):
pass
- self.failUnless(issubclass(C, B))
- self.failIf(issubclass(int, C))
+ self.assertTrue(issubclass(C, B))
+ self.assertFalse(issubclass(int, C))
def test_registration(self):
for B in Hashable, Iterable, Iterator, Sized, Container, Callable:
class C:
__hash__ = None # Make sure it isn't hashable by default
- self.failIf(issubclass(C, B), B.__name__)
+ self.assertFalse(issubclass(C, B), B.__name__)
B.register(C)
- self.failUnless(issubclass(C, B))
+ self.assertTrue(issubclass(C, B))
class WithSet(MutableSet):
@@ -395,8 +395,8 @@
def test_Set(self):
for sample in [set, frozenset]:
- self.failUnless(isinstance(sample(), Set))
- self.failUnless(issubclass(sample, Set))
+ self.assertTrue(isinstance(sample(), Set))
+ self.assertTrue(issubclass(sample, Set))
self.validate_abstract_methods(Set, '__contains__', '__iter__', '__len__')
def test_hash_Set(self):
@@ -412,13 +412,13 @@
def __hash__(self):
return self._hash()
a, b = OneTwoThreeSet(), OneTwoThreeSet()
- self.failUnless(hash(a) == hash(b))
+ self.assertTrue(hash(a) == hash(b))
def test_MutableSet(self):
- self.failUnless(isinstance(set(), MutableSet))
- self.failUnless(issubclass(set, MutableSet))
- self.failIf(isinstance(frozenset(), MutableSet))
- self.failIf(issubclass(frozenset, MutableSet))
+ self.assertTrue(isinstance(set(), MutableSet))
+ self.assertTrue(issubclass(set, MutableSet))
+ self.assertFalse(isinstance(frozenset(), MutableSet))
+ self.assertFalse(issubclass(frozenset, MutableSet))
self.validate_abstract_methods(MutableSet, '__contains__', '__iter__', '__len__',
'add', 'discard')
@@ -457,46 +457,46 @@
def test_Mapping(self):
for sample in [dict]:
- self.failUnless(isinstance(sample(), Mapping))
- self.failUnless(issubclass(sample, Mapping))
+ self.assertTrue(isinstance(sample(), Mapping))
+ self.assertTrue(issubclass(sample, Mapping))
self.validate_abstract_methods(Mapping, '__contains__', '__iter__', '__len__',
'__getitem__')
def test_MutableMapping(self):
for sample in [dict]:
- self.failUnless(isinstance(sample(), MutableMapping))
- self.failUnless(issubclass(sample, MutableMapping))
+ self.assertTrue(isinstance(sample(), MutableMapping))
+ self.assertTrue(issubclass(sample, MutableMapping))
self.validate_abstract_methods(MutableMapping, '__contains__', '__iter__', '__len__',
'__getitem__', '__setitem__', '__delitem__')
def test_Sequence(self):
for sample in [tuple, list, bytes, str]:
- self.failUnless(isinstance(sample(), Sequence))
- self.failUnless(issubclass(sample, Sequence))
- self.failUnless(isinstance(range(10), Sequence))
- self.failUnless(issubclass(range, Sequence))
- self.failUnless(issubclass(str, Sequence))
+ self.assertTrue(isinstance(sample(), Sequence))
+ self.assertTrue(issubclass(sample, Sequence))
+ self.assertTrue(isinstance(range(10), Sequence))
+ self.assertTrue(issubclass(range, Sequence))
+ self.assertTrue(issubclass(str, Sequence))
self.validate_abstract_methods(Sequence, '__contains__', '__iter__', '__len__',
'__getitem__')
def test_ByteString(self):
for sample in [bytes, bytearray]:
- self.failUnless(isinstance(sample(), ByteString))
- self.failUnless(issubclass(sample, ByteString))
+ self.assertTrue(isinstance(sample(), ByteString))
+ self.assertTrue(issubclass(sample, ByteString))
for sample in [str, list, tuple]:
- self.failIf(isinstance(sample(), ByteString))
- self.failIf(issubclass(sample, ByteString))
- self.failIf(isinstance(memoryview(b""), ByteString))
- self.failIf(issubclass(memoryview, ByteString))
+ self.assertFalse(isinstance(sample(), ByteString))
+ self.assertFalse(issubclass(sample, ByteString))
+ self.assertFalse(isinstance(memoryview(b""), ByteString))
+ self.assertFalse(issubclass(memoryview, ByteString))
def test_MutableSequence(self):
for sample in [tuple, str, bytes]:
- self.failIf(isinstance(sample(), MutableSequence))
- self.failIf(issubclass(sample, MutableSequence))
+ self.assertFalse(isinstance(sample(), MutableSequence))
+ self.assertFalse(issubclass(sample, MutableSequence))
for sample in [list, bytearray]:
- self.failUnless(isinstance(sample(), MutableSequence))
- self.failUnless(issubclass(sample, MutableSequence))
- self.failIf(issubclass(str, MutableSequence))
+ self.assertTrue(isinstance(sample(), MutableSequence))
+ self.assertTrue(issubclass(sample, MutableSequence))
+ self.assertFalse(issubclass(str, MutableSequence))
self.validate_abstract_methods(MutableSequence, '__contains__', '__iter__',
'__len__', '__getitem__', '__setitem__', '__delitem__', 'insert')
@@ -506,10 +506,10 @@
c = Counter('abcaba')
self.assertEqual(c, Counter({'a':3 , 'b': 2, 'c': 1}))
self.assertEqual(c, Counter(a=3, b=2, c=1))
- self.assert_(isinstance(c, dict))
- self.assert_(isinstance(c, Mapping))
- self.assert_(issubclass(Counter, dict))
- self.assert_(issubclass(Counter, Mapping))
+ self.assertTrue(isinstance(c, dict))
+ self.assertTrue(isinstance(c, Mapping))
+ self.assertTrue(issubclass(Counter, dict))
+ self.assertTrue(issubclass(Counter, Mapping))
self.assertEqual(len(c), 3)
self.assertEqual(sum(c.values()), 6)
self.assertEqual(sorted(c.values()), [1, 2, 3])
@@ -581,7 +581,7 @@
Counter(words),
]):
msg = (i, dup, words)
- self.assert_(dup is not words)
+ self.assertTrue(dup is not words)
self.assertEquals(dup, words)
self.assertEquals(len(dup), len(words))
self.assertEquals(type(dup), type(words))
@@ -597,7 +597,7 @@
def test_invariant_for_the_in_operator(self):
c = Counter(a=10, b=-2, c=0)
for elem in c:
- self.assert_(elem in c)
+ self.assertTrue(elem in c)
def test_multiset_operations(self):
# Verify that adding a zero counter will strip zeros and negatives
@@ -622,7 +622,7 @@
self.assertEqual(numberop(p[x], q[x]), result[x],
(counterop, x, p, q))
# verify that results exclude non-positive counts
- self.assert_(x>0 for x in result.values())
+ self.assertTrue(x>0 for x in result.values())
elements = 'abcdef'
for i in range(100):
@@ -697,7 +697,7 @@
pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)]
od = OrderedDict(pairs)
del od['a']
- self.assert_('a' not in od)
+ self.assertTrue('a' not in od)
with self.assertRaises(KeyError):
del od['a']
self.assertEqual(list(od.items()), pairs[:2] + pairs[3:])
@@ -778,7 +778,7 @@
update_test,
OrderedDict(od),
]):
- self.assert_(dup is not od)
+ self.assertTrue(dup is not od)
self.assertEquals(dup, od)
self.assertEquals(list(dup.items()), list(od.items()))
self.assertEquals(len(dup), len(od))
@@ -791,7 +791,7 @@
od = OrderedDict(pairs)
# yaml.dump(od) -->
# '!!python/object/apply:__main__.OrderedDict\n- - [a, 1]\n - [b, 2]\n'
- self.assert_(all(type(pair)==list for pair in od.__reduce__()[1]))
+ self.assertTrue(all(type(pair)==list for pair in od.__reduce__()[1]))
def test_reduce_not_too_fat(self):
# do not save instance dictionary if not needed
Modified: python/branches/py3k/Lib/test/test_compile.py
==============================================================================
--- python/branches/py3k/Lib/test/test_compile.py (original)
+++ python/branches/py3k/Lib/test/test_compile.py Wed Jul 1 01:06:06 2009
@@ -376,10 +376,10 @@
import __mangled_mod
import __package__.module
- self.assert_("_A__mangled" in A.f.__code__.co_varnames)
- self.assert_("__not_mangled__" in A.f.__code__.co_varnames)
- self.assert_("_A__mangled_mod" in A.f.__code__.co_varnames)
- self.assert_("__package__" in A.f.__code__.co_varnames)
+ self.assertTrue("_A__mangled" in A.f.__code__.co_varnames)
+ self.assertTrue("__not_mangled__" in A.f.__code__.co_varnames)
+ self.assertTrue("_A__mangled_mod" in A.f.__code__.co_varnames)
+ self.assertTrue("__package__" in A.f.__code__.co_varnames)
def test_compile_ast(self):
fname = __file__
@@ -398,7 +398,7 @@
for fname, code in sample_code:
co1 = compile(code, '%s1' % fname, 'exec')
ast = compile(code, '%s2' % fname, 'exec', _ast.PyCF_ONLY_AST)
- self.assert_(type(ast) == _ast.Module)
+ self.assertTrue(type(ast) == _ast.Module)
co2 = compile(ast, '%s3' % fname, 'exec')
self.assertEqual(co1, co2)
# the code object's filename comes from the second compilation step
Modified: python/branches/py3k/Lib/test/test_complex.py
==============================================================================
--- python/branches/py3k/Lib/test/test_complex.py (original)
+++ python/branches/py3k/Lib/test/test_complex.py Wed Jul 1 01:06:06 2009
@@ -35,7 +35,7 @@
if x == 0:
return abs(y) < eps
# check that relative difference < eps
- self.assert_(abs((x-y)/y) < eps)
+ self.assertTrue(abs((x-y)/y) < eps)
def assertFloatsAreIdentical(self, x, y):
"""assert that floats x and y are identical, in the sense that:
@@ -66,7 +66,7 @@
self.assertCloseAbs(x.imag, y.imag, eps)
def assertIs(self, a, b):
- self.assert_(a is b)
+ self.assertTrue(a is b)
def check_div(self, x, y):
"""Compute complex z=x*y, and check that z/x==y and z/y==x."""
@@ -174,8 +174,8 @@
def test_boolcontext(self):
for i in range(100):
- self.assert_(complex(random() + 1e-6, random() + 1e-6))
- self.assert_(not complex(0.0, 0.0))
+ self.assertTrue(complex(random() + 1e-6, random() + 1e-6))
+ self.assertTrue(not complex(0.0, 0.0))
def test_conjugate(self):
self.assertClose(complex(5.3, 9.8).conjugate(), 5.3-9.8j)
@@ -257,7 +257,7 @@
self.assertEqual(split_zeros(complex(-0., 1.).real), split_zeros(-0.))
c = 3.14 + 1j
- self.assert_(complex(c) is c)
+ self.assertTrue(complex(c) is c)
del c
self.assertRaises(TypeError, complex, "1", "1")
Modified: python/branches/py3k/Lib/test/test_contains.py
==============================================================================
--- python/branches/py3k/Lib/test/test_contains.py (original)
+++ python/branches/py3k/Lib/test/test_contains.py Wed Jul 1 01:06:06 2009
@@ -20,19 +20,19 @@
a = base_set(1)
b = myset(1)
c = seq(1)
- self.assert_(1 in b)
- self.assert_(0 not in b)
- self.assert_(1 in c)
- self.assert_(0 not in c)
+ self.assertTrue(1 in b)
+ self.assertTrue(0 not in b)
+ self.assertTrue(1 in c)
+ self.assertTrue(0 not in c)
self.assertRaises(TypeError, lambda: 1 in a)
self.assertRaises(TypeError, lambda: 1 not in a)
# test char in string
- self.assert_('c' in 'abc')
- self.assert_('d' not in 'abc')
+ self.assertTrue('c' in 'abc')
+ self.assertTrue('d' not in 'abc')
- self.assert_('' in '')
- self.assert_('' in 'abc')
+ self.assertTrue('' in '')
+ self.assertTrue('' in 'abc')
self.assertRaises(TypeError, lambda: None in 'abc')
@@ -40,15 +40,15 @@
# a collection of tests on builtin sequence types
a = range(10)
for i in a:
- self.assert_(i in a)
- self.assert_(16 not in a)
- self.assert_(a not in a)
+ self.assertTrue(i in a)
+ self.assertTrue(16 not in a)
+ self.assertTrue(a not in a)
a = tuple(a)
for i in a:
- self.assert_(i in a)
- self.assert_(16 not in a)
- self.assert_(a not in a)
+ self.assertTrue(i in a)
+ self.assertTrue(16 not in a)
+ self.assertTrue(a not in a)
class Deviant1:
"""Behaves strangely when compared
@@ -64,7 +64,7 @@
self.aList.remove(14)
return 0
- self.assert_(Deviant1() not in Deviant1.aList)
+ self.assertTrue(Deviant1() not in Deviant1.aList)
def test_nonreflexive(self):
# containment and equality tests involving elements that are
@@ -81,9 +81,9 @@
for constructor in constructors:
container = constructor(values)
for elem in container:
- self.assert_(elem in container)
- self.assert_(container == constructor(values))
- self.assert_(container == container)
+ self.assertTrue(elem in container)
+ self.assertTrue(container == constructor(values))
+ self.assertTrue(container == container)
def test_main():
Modified: python/branches/py3k/Lib/test/test_contextlib.py
==============================================================================
--- python/branches/py3k/Lib/test/test_contextlib.py (original)
+++ python/branches/py3k/Lib/test/test_contextlib.py Wed Jul 1 01:06:06 2009
@@ -54,7 +54,7 @@
ctx = whee()
ctx.__enter__()
# Calling __exit__ should not result in an exception
- self.failIf(ctx.__exit__(TypeError, TypeError("foo"), None))
+ self.assertFalse(ctx.__exit__(TypeError, TypeError("foo"), None))
def test_contextmanager_trap_yield_after_throw(self):
@contextmanager
@@ -261,17 +261,17 @@
try:
f = None
with open(tfn, "w") as f:
- self.failIf(f.closed)
+ self.assertFalse(f.closed)
f.write("Booh\n")
- self.failUnless(f.closed)
+ self.assertTrue(f.closed)
f = None
try:
with open(tfn, "r") as f:
- self.failIf(f.closed)
+ self.assertFalse(f.closed)
self.assertEqual(f.read(), "Booh\n")
1/0
except ZeroDivisionError:
- self.failUnless(f.closed)
+ self.assertTrue(f.closed)
else:
self.fail("Didn't raise ZeroDivisionError")
finally:
@@ -283,16 +283,16 @@
class LockContextTestCase(unittest.TestCase):
def boilerPlate(self, lock, locked):
- self.failIf(locked())
+ self.assertFalse(locked())
with lock:
- self.failUnless(locked())
- self.failIf(locked())
+ self.assertTrue(locked())
+ self.assertFalse(locked())
try:
with lock:
- self.failUnless(locked())
+ self.assertTrue(locked())
1/0
except ZeroDivisionError:
- self.failIf(locked())
+ self.assertFalse(locked())
else:
self.fail("Didn't raise ZeroDivisionError")
Modified: python/branches/py3k/Lib/test/test_copy.py
==============================================================================
--- python/branches/py3k/Lib/test/test_copy.py (original)
+++ python/branches/py3k/Lib/test/test_copy.py Wed Jul 1 01:06:06 2009
@@ -17,8 +17,8 @@
# Attempt full line coverage of copy.py from top to bottom
def test_exceptions(self):
- self.assert_(copy.Error is copy.error)
- self.assert_(issubclass(copy.Error, Exception))
+ self.assertTrue(copy.Error is copy.error)
+ self.assertTrue(issubclass(copy.Error, Exception))
# The copy() method
@@ -59,7 +59,7 @@
raise support.TestFailed("shouldn't call this")
x = C()
y = copy.copy(x)
- self.assert_(y is x)
+ self.assertTrue(y is x)
def test_copy_reduce(self):
class C(object):
@@ -67,7 +67,7 @@
return ""
x = C()
y = copy.copy(x)
- self.assert_(y is x)
+ self.assertTrue(y is x)
def test_copy_cant(self):
class C(object):
@@ -91,7 +91,7 @@
"hello", "hello\u1234", f.__code__,
NewStyle, range(10), Classic, max]
for x in tests:
- self.assert_(copy.copy(x) is x, repr(x))
+ self.assertTrue(copy.copy(x) is x, repr(x))
def test_copy_list(self):
x = [1, 2, 3]
@@ -185,9 +185,9 @@
x = [x, x]
y = copy.deepcopy(x)
self.assertEqual(y, x)
- self.assert_(y is not x)
- self.assert_(y[0] is not x[0])
- self.assert_(y[0] is y[1])
+ self.assertTrue(y is not x)
+ self.assertTrue(y[0] is not x[0])
+ self.assertTrue(y[0] is y[1])
def test_deepcopy_issubclass(self):
# XXX Note: there's no way to test the TypeError coming out of
@@ -232,7 +232,7 @@
raise support.TestFailed("shouldn't call this")
x = C()
y = copy.deepcopy(x)
- self.assert_(y is x)
+ self.assertTrue(y is x)
def test_deepcopy_reduce(self):
class C(object):
@@ -240,7 +240,7 @@
return ""
x = C()
y = copy.deepcopy(x)
- self.assert_(y is x)
+ self.assertTrue(y is x)
def test_deepcopy_cant(self):
class C(object):
@@ -264,14 +264,14 @@
"hello", "hello\u1234", f.__code__,
NewStyle, range(10), Classic, max]
for x in tests:
- self.assert_(copy.deepcopy(x) is x, repr(x))
+ self.assertTrue(copy.deepcopy(x) is x, repr(x))
def test_deepcopy_list(self):
x = [[1, 2], 3]
y = copy.deepcopy(x)
self.assertEqual(y, x)
- self.assert_(x is not y)
- self.assert_(x[0] is not y[0])
+ self.assertTrue(x is not y)
+ self.assertTrue(x[0] is not y[0])
def test_deepcopy_reflexive_list(self):
x = []
@@ -279,16 +279,16 @@
y = copy.deepcopy(x)
for op in comparisons:
self.assertRaises(RuntimeError, op, y, x)
- self.assert_(y is not x)
- self.assert_(y[0] is y)
+ self.assertTrue(y is not x)
+ self.assertTrue(y[0] is y)
self.assertEqual(len(y), 1)
def test_deepcopy_tuple(self):
x = ([1, 2], 3)
y = copy.deepcopy(x)
self.assertEqual(y, x)
- self.assert_(x is not y)
- self.assert_(x[0] is not y[0])
+ self.assertTrue(x is not y)
+ self.assertTrue(x[0] is not y[0])
def test_deepcopy_reflexive_tuple(self):
x = ([],)
@@ -296,16 +296,16 @@
y = copy.deepcopy(x)
for op in comparisons:
self.assertRaises(RuntimeError, op, y, x)
- self.assert_(y is not x)
- self.assert_(y[0] is not x[0])
- self.assert_(y[0][0] is y)
+ self.assertTrue(y is not x)
+ self.assertTrue(y[0] is not x[0])
+ self.assertTrue(y[0][0] is y)
def test_deepcopy_dict(self):
x = {"foo": [1, 2], "bar": 3}
y = copy.deepcopy(x)
self.assertEqual(y, x)
- self.assert_(x is not y)
- self.assert_(x["foo"] is not y["foo"])
+ self.assertTrue(x is not y)
+ self.assertTrue(x["foo"] is not y["foo"])
def test_deepcopy_reflexive_dict(self):
x = {}
@@ -315,15 +315,15 @@
self.assertRaises(TypeError, op, y, x)
for op in equality_comparisons:
self.assertRaises(RuntimeError, op, y, x)
- self.assert_(y is not x)
- self.assert_(y['foo'] is y)
+ self.assertTrue(y is not x)
+ self.assertTrue(y['foo'] is y)
self.assertEqual(len(y), 1)
def test_deepcopy_keepalive(self):
memo = {}
x = 42
y = copy.deepcopy(x, memo)
- self.assert_(memo[id(x)] is x)
+ self.assertTrue(memo[id(x)] is x)
def test_deepcopy_inst_vanilla(self):
class C:
@@ -334,7 +334,7 @@
x = C([42])
y = copy.deepcopy(x)
self.assertEqual(y, x)
- self.assert_(y.foo is not x.foo)
+ self.assertTrue(y.foo is not x.foo)
def test_deepcopy_inst_deepcopy(self):
class C:
@@ -347,8 +347,8 @@
x = C([42])
y = copy.deepcopy(x)
self.assertEqual(y, x)
- self.assert_(y is not x)
- self.assert_(y.foo is not x.foo)
+ self.assertTrue(y is not x)
+ self.assertTrue(y.foo is not x.foo)
def test_deepcopy_inst_getinitargs(self):
class C:
@@ -361,8 +361,8 @@
x = C([42])
y = copy.deepcopy(x)
self.assertEqual(y, x)
- self.assert_(y is not x)
- self.assert_(y.foo is not x.foo)
+ self.assertTrue(y is not x)
+ self.assertTrue(y.foo is not x.foo)
def test_deepcopy_inst_getstate(self):
class C:
@@ -375,8 +375,8 @@
x = C([42])
y = copy.deepcopy(x)
self.assertEqual(y, x)
- self.assert_(y is not x)
- self.assert_(y.foo is not x.foo)
+ self.assertTrue(y is not x)
+ self.assertTrue(y.foo is not x.foo)
def test_deepcopy_inst_setstate(self):
class C:
@@ -389,8 +389,8 @@
x = C([42])
y = copy.deepcopy(x)
self.assertEqual(y, x)
- self.assert_(y is not x)
- self.assert_(y.foo is not x.foo)
+ self.assertTrue(y is not x)
+ self.assertTrue(y.foo is not x.foo)
def test_deepcopy_inst_getstate_setstate(self):
class C:
@@ -405,8 +405,8 @@
x = C([42])
y = copy.deepcopy(x)
self.assertEqual(y, x)
- self.assert_(y is not x)
- self.assert_(y.foo is not x.foo)
+ self.assertTrue(y is not x)
+ self.assertTrue(y.foo is not x.foo)
def test_deepcopy_reflexive_inst(self):
class C:
@@ -414,8 +414,8 @@
x = C()
x.foo = x
y = copy.deepcopy(x)
- self.assert_(y is not x)
- self.assert_(y.foo is y)
+ self.assertTrue(y is not x)
+ self.assertTrue(y.foo is y)
# _reconstruct()
@@ -425,9 +425,9 @@
return ""
x = C()
y = copy.copy(x)
- self.assert_(y is x)
+ self.assertTrue(y is x)
y = copy.deepcopy(x)
- self.assert_(y is x)
+ self.assertTrue(y is x)
def test_reconstruct_nostate(self):
class C(object):
@@ -436,9 +436,9 @@
x = C()
x.foo = 42
y = copy.copy(x)
- self.assert_(y.__class__ is x.__class__)
+ self.assertTrue(y.__class__ is x.__class__)
y = copy.deepcopy(x)
- self.assert_(y.__class__ is x.__class__)
+ self.assertTrue(y.__class__ is x.__class__)
def test_reconstruct_state(self):
class C(object):
@@ -452,7 +452,7 @@
self.assertEqual(y, x)
y = copy.deepcopy(x)
self.assertEqual(y, x)
- self.assert_(y.foo is not x.foo)
+ self.assertTrue(y.foo is not x.foo)
def test_reconstruct_state_setstate(self):
class C(object):
@@ -468,7 +468,7 @@
self.assertEqual(y, x)
y = copy.deepcopy(x)
self.assertEqual(y, x)
- self.assert_(y.foo is not x.foo)
+ self.assertTrue(y.foo is not x.foo)
def test_reconstruct_reflexive(self):
class C(object):
@@ -476,8 +476,8 @@
x = C()
x.foo = x
y = copy.deepcopy(x)
- self.assert_(y is not x)
- self.assert_(y.foo is y)
+ self.assertTrue(y is not x)
+ self.assertTrue(y.foo is y)
# Additions for Python 2.3 and pickle protocol 2
@@ -491,12 +491,12 @@
x = C([[1, 2], 3])
y = copy.copy(x)
self.assertEqual(x, y)
- self.assert_(x is not y)
- self.assert_(x[0] is y[0])
+ self.assertTrue(x is not y)
+ self.assertTrue(x[0] is y[0])
y = copy.deepcopy(x)
self.assertEqual(x, y)
- self.assert_(x is not y)
- self.assert_(x[0] is not y[0])
+ self.assertTrue(x is not y)
+ self.assertTrue(x[0] is not y[0])
def test_reduce_5tuple(self):
class C(dict):
@@ -508,12 +508,12 @@
x = C([("foo", [1, 2]), ("bar", 3)])
y = copy.copy(x)
self.assertEqual(x, y)
- self.assert_(x is not y)
- self.assert_(x["foo"] is y["foo"])
+ self.assertTrue(x is not y)
+ self.assertTrue(x["foo"] is y["foo"])
y = copy.deepcopy(x)
self.assertEqual(x, y)
- self.assert_(x is not y)
- self.assert_(x["foo"] is not y["foo"])
+ self.assertTrue(x is not y)
+ self.assertTrue(x["foo"] is not y["foo"])
def test_copy_slots(self):
class C(object):
@@ -521,7 +521,7 @@
x = C()
x.foo = [42]
y = copy.copy(x)
- self.assert_(x.foo is y.foo)
+ self.assertTrue(x.foo is y.foo)
def test_deepcopy_slots(self):
class C(object):
@@ -530,7 +530,7 @@
x.foo = [42]
y = copy.deepcopy(x)
self.assertEqual(x.foo, y.foo)
- self.assert_(x.foo is not y.foo)
+ self.assertTrue(x.foo is not y.foo)
def test_copy_list_subclass(self):
class C(list):
@@ -540,8 +540,8 @@
y = copy.copy(x)
self.assertEqual(list(x), list(y))
self.assertEqual(x.foo, y.foo)
- self.assert_(x[0] is y[0])
- self.assert_(x.foo is y.foo)
+ self.assertTrue(x[0] is y[0])
+ self.assertTrue(x.foo is y.foo)
def test_deepcopy_list_subclass(self):
class C(list):
@@ -551,8 +551,8 @@
y = copy.deepcopy(x)
self.assertEqual(list(x), list(y))
self.assertEqual(x.foo, y.foo)
- self.assert_(x[0] is not y[0])
- self.assert_(x.foo is not y.foo)
+ self.assertTrue(x[0] is not y[0])
+ self.assertTrue(x.foo is not y.foo)
def test_copy_tuple_subclass(self):
class C(tuple):
@@ -569,8 +569,8 @@
self.assertEqual(tuple(x), ([1, 2], 3))
y = copy.deepcopy(x)
self.assertEqual(tuple(y), ([1, 2], 3))
- self.assert_(x is not y)
- self.assert_(x[0] is not y[0])
+ self.assertTrue(x is not y)
+ self.assertTrue(x[0] is not y[0])
def test_getstate_exc(self):
class EvilState(object):
Modified: python/branches/py3k/Lib/test/test_copyreg.py
==============================================================================
--- python/branches/py3k/Lib/test/test_copyreg.py (original)
+++ python/branches/py3k/Lib/test/test_copyreg.py Wed Jul 1 01:06:06 2009
@@ -51,10 +51,10 @@
mod, func, code)
copyreg.add_extension(mod, func, code)
# Should be in the registry.
- self.assert_(copyreg._extension_registry[mod, func] == code)
- self.assert_(copyreg._inverted_registry[code] == (mod, func))
+ self.assertTrue(copyreg._extension_registry[mod, func] == code)
+ self.assertTrue(copyreg._inverted_registry[code] == (mod, func))
# Shouldn't be in the cache.
- self.assert_(code not in copyreg._extension_cache)
+ self.assertTrue(code not in copyreg._extension_cache)
# Redundant registration should be OK.
copyreg.add_extension(mod, func, code) # shouldn't blow up
# Conflicting code.
@@ -81,7 +81,7 @@
e.restore()
# Shouldn't be there anymore.
- self.assert_((mod, func) not in copyreg._extension_registry)
+ self.assertTrue((mod, func) not in copyreg._extension_registry)
# The code *may* be in copyreg._extension_registry, though, if
# we happened to pick on a registered code. So don't check for
# that.
Modified: python/branches/py3k/Lib/test/test_csv.py
==============================================================================
--- python/branches/py3k/Lib/test/test_csv.py (original)
+++ python/branches/py3k/Lib/test/test_csv.py Wed Jul 1 01:06:06 2009
@@ -315,7 +315,7 @@
expected_dialects.sort()
csv.register_dialect(name, myexceltsv)
try:
- self.failUnless(csv.get_dialect(name).delimiter, '\t')
+ self.assertTrue(csv.get_dialect(name).delimiter, '\t')
got_dialects = csv.list_dialects()
got_dialects.sort()
self.assertEqual(expected_dialects, got_dialects)
@@ -326,8 +326,8 @@
name = 'fedcba'
csv.register_dialect(name, delimiter=';')
try:
- self.failUnless(csv.get_dialect(name).delimiter, '\t')
- self.failUnless(list(csv.reader('X;Y;Z', name)), ['X', 'Y', 'Z'])
+ self.assertTrue(csv.get_dialect(name).delimiter, '\t')
+ self.assertTrue(list(csv.reader('X;Y;Z', name)), ['X', 'Y', 'Z'])
finally:
csv.unregister_dialect(name)
@@ -811,7 +811,7 @@
# given that all three lines in sample3 are equal,
# I think that any character could have been 'guessed' as the
# delimiter, depending on dictionary order
- self.assert_(dialect.delimiter in self.sample3)
+ self.assertTrue(dialect.delimiter in self.sample3)
dialect = sniffer.sniff(self.sample3, delimiters="?,")
self.assertEqual(dialect.delimiter, "?")
dialect = sniffer.sniff(self.sample3, delimiters="/,")
Modified: python/branches/py3k/Lib/test/test_datetime.py
==============================================================================
--- python/branches/py3k/Lib/test/test_datetime.py (original)
+++ python/branches/py3k/Lib/test/test_datetime.py Wed Jul 1 01:06:06 2009
@@ -77,9 +77,9 @@
def __init__(self, offset, name):
self.__offset = offset
self.__name = name
- self.failUnless(issubclass(NotEnough, tzinfo))
+ self.assertTrue(issubclass(NotEnough, tzinfo))
ne = NotEnough(3, "NotByALongShot")
- self.failUnless(isinstance(ne, tzinfo))
+ self.assertTrue(isinstance(ne, tzinfo))
dt = datetime.now()
self.assertRaises(NotImplementedError, ne.tzname, dt)
@@ -88,7 +88,7 @@
def test_normal(self):
fo = FixedOffset(3, "Three")
- self.failUnless(isinstance(fo, tzinfo))
+ self.assertTrue(isinstance(fo, tzinfo))
for dt in datetime.now(), None:
self.assertEqual(fo.utcoffset(dt), timedelta(minutes=3))
self.assertEqual(fo.tzname(dt), "Three")
@@ -99,25 +99,25 @@
# carry no data), but they need to be picklable anyway else
# concrete subclasses can't be pickled.
orig = tzinfo.__new__(tzinfo)
- self.failUnless(type(orig) is tzinfo)
+ self.assertTrue(type(orig) is tzinfo)
for pickler, unpickler, proto in pickle_choices:
green = pickler.dumps(orig, proto)
derived = unpickler.loads(green)
- self.failUnless(type(derived) is tzinfo)
+ self.assertTrue(type(derived) is tzinfo)
def test_pickling_subclass(self):
# Make sure we can pickle/unpickle an instance of a subclass.
offset = timedelta(minutes=-300)
orig = PicklableFixedOffset(offset, 'cookie')
- self.failUnless(isinstance(orig, tzinfo))
- self.failUnless(type(orig) is PicklableFixedOffset)
+ self.assertTrue(isinstance(orig, tzinfo))
+ self.assertTrue(type(orig) is PicklableFixedOffset)
self.assertEqual(orig.utcoffset(None), offset)
self.assertEqual(orig.tzname(None), 'cookie')
for pickler, unpickler, proto in pickle_choices:
green = pickler.dumps(orig, proto)
derived = unpickler.loads(green)
- self.failUnless(isinstance(derived, tzinfo))
- self.failUnless(type(derived) is PicklableFixedOffset)
+ self.assertTrue(isinstance(derived, tzinfo))
+ self.assertTrue(type(derived) is PicklableFixedOffset)
self.assertEqual(derived.utcoffset(None), offset)
self.assertEqual(derived.tzname(None), 'cookie')
@@ -134,16 +134,16 @@
def test_harmless_mixed_comparison(self):
me = self.theclass(1, 1, 1)
- self.failIf(me == ())
- self.failUnless(me != ())
- self.failIf(() == me)
- self.failUnless(() != me)
+ self.assertFalse(me == ())
+ self.assertTrue(me != ())
+ self.assertFalse(() == me)
+ self.assertTrue(() != me)
- self.failUnless(me in [1, 20, [], me])
- self.failIf(me not in [1, 20, [], me])
+ self.assertTrue(me in [1, 20, [], me])
+ self.assertFalse(me not in [1, 20, [], me])
- self.failUnless([] in [me, 1, 20, []])
- self.failIf([] not in [me, 1, 20, []])
+ self.assertTrue([] in [me, 1, 20, []])
+ self.assertFalse([] not in [me, 1, 20, []])
def test_harmful_mixed_comparison(self):
me = self.theclass(1, 1, 1)
@@ -303,26 +303,26 @@
t1 = timedelta(2, 3, 4)
t2 = timedelta(2, 3, 4)
self.assertEqual(t1, t2)
- self.failUnless(t1 <= t2)
- self.failUnless(t1 >= t2)
- self.failUnless(not t1 != t2)
- self.failUnless(not t1 < t2)
- self.failUnless(not t1 > t2)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t1 >= t2)
+ self.assertTrue(not t1 != t2)
+ self.assertTrue(not t1 < t2)
+ self.assertTrue(not t1 > t2)
for args in (3, 3, 3), (2, 4, 4), (2, 3, 5):
t2 = timedelta(*args) # this is larger than t1
- self.failUnless(t1 < t2)
- self.failUnless(t2 > t1)
- self.failUnless(t1 <= t2)
- self.failUnless(t2 >= t1)
- self.failUnless(t1 != t2)
- self.failUnless(t2 != t1)
- self.failUnless(not t1 == t2)
- self.failUnless(not t2 == t1)
- self.failUnless(not t1 > t2)
- self.failUnless(not t2 < t1)
- self.failUnless(not t1 >= t2)
- self.failUnless(not t2 <= t1)
+ self.assertTrue(t1 < t2)
+ self.assertTrue(t2 > t1)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t2 >= t1)
+ self.assertTrue(t1 != t2)
+ self.assertTrue(t2 != t1)
+ self.assertTrue(not t1 == t2)
+ self.assertTrue(not t2 == t1)
+ self.assertTrue(not t1 > t2)
+ self.assertTrue(not t2 < t1)
+ self.assertTrue(not t1 >= t2)
+ self.assertTrue(not t2 <= t1)
for badarg in OTHERSTUFF:
self.assertEqual(t1 == badarg, False)
@@ -368,7 +368,7 @@
# Verify td -> string -> td identity.
s = repr(td)
- self.failUnless(s.startswith('datetime.'))
+ self.assertTrue(s.startswith('datetime.'))
s = s[9:]
td2 = eval(s)
self.assertEqual(td, td2)
@@ -378,10 +378,10 @@
self.assertEqual(td, td2)
def test_resolution_info(self):
- self.assert_(isinstance(timedelta.min, timedelta))
- self.assert_(isinstance(timedelta.max, timedelta))
- self.assert_(isinstance(timedelta.resolution, timedelta))
- self.assert_(timedelta.max > timedelta.min)
+ self.assertTrue(isinstance(timedelta.min, timedelta))
+ self.assertTrue(isinstance(timedelta.max, timedelta))
+ self.assertTrue(isinstance(timedelta.resolution, timedelta))
+ self.assertTrue(timedelta.max > timedelta.min)
self.assertEqual(timedelta.min, timedelta(-999999999))
self.assertEqual(timedelta.max, timedelta(999999999, 24*3600-1, 1e6-1))
self.assertEqual(timedelta.resolution, timedelta(0, 0, 1))
@@ -428,11 +428,11 @@
(-1, 24*3600-1, 999999))
def test_bool(self):
- self.failUnless(timedelta(1))
- self.failUnless(timedelta(0, 1))
- self.failUnless(timedelta(0, 0, 1))
- self.failUnless(timedelta(microseconds=1))
- self.failUnless(not timedelta(0))
+ self.assertTrue(timedelta(1))
+ self.assertTrue(timedelta(0, 1))
+ self.assertTrue(timedelta(0, 0, 1))
+ self.assertTrue(timedelta(microseconds=1))
+ self.assertTrue(not timedelta(0))
def test_subclass_timedelta(self):
@@ -448,17 +448,17 @@
return round(sum)
t1 = T(days=1)
- self.assert_(type(t1) is T)
+ self.assertTrue(type(t1) is T)
self.assertEqual(t1.as_hours(), 24)
t2 = T(days=-1, seconds=-3600)
- self.assert_(type(t2) is T)
+ self.assertTrue(type(t2) is T)
self.assertEqual(t2.as_hours(), -25)
t3 = t1 + t2
- self.assert_(type(t3) is timedelta)
+ self.assertTrue(type(t3) is timedelta)
t4 = T.from_td(t3)
- self.assert_(type(t4) is T)
+ self.assertTrue(type(t4) is T)
self.assertEqual(t3.days, t4.days)
self.assertEqual(t3.seconds, t4.seconds)
self.assertEqual(t3.microseconds, t4.microseconds)
@@ -521,7 +521,7 @@
self.theclass.today()):
# Verify dt -> string -> date identity.
s = repr(dt)
- self.failUnless(s.startswith('datetime.'))
+ self.assertTrue(s.startswith('datetime.'))
s = s[9:]
dt2 = eval(s)
self.assertEqual(dt, dt2)
@@ -755,7 +755,7 @@
# It worked or it didn't. If it didn't, assume it's reason #2, and
# let the test pass if they're within half a second of each other.
- self.failUnless(today == todayagain or
+ self.assertTrue(today == todayagain or
abs(todayagain - today) < timedelta(seconds=0.5))
def test_weekday(self):
@@ -891,10 +891,10 @@
self.assertEqual(b.__format__(fmt), 'B')
def test_resolution_info(self):
- self.assert_(isinstance(self.theclass.min, self.theclass))
- self.assert_(isinstance(self.theclass.max, self.theclass))
- self.assert_(isinstance(self.theclass.resolution, timedelta))
- self.assert_(self.theclass.max > self.theclass.min)
+ self.assertTrue(isinstance(self.theclass.min, self.theclass))
+ self.assertTrue(isinstance(self.theclass.max, self.theclass))
+ self.assertTrue(isinstance(self.theclass.resolution, timedelta))
+ self.assertTrue(self.theclass.max > self.theclass.min)
def test_extreme_timedelta(self):
big = self.theclass.max - self.theclass.min
@@ -943,26 +943,26 @@
t1 = self.theclass(2, 3, 4)
t2 = self.theclass(2, 3, 4)
self.assertEqual(t1, t2)
- self.failUnless(t1 <= t2)
- self.failUnless(t1 >= t2)
- self.failUnless(not t1 != t2)
- self.failUnless(not t1 < t2)
- self.failUnless(not t1 > t2)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t1 >= t2)
+ self.assertTrue(not t1 != t2)
+ self.assertTrue(not t1 < t2)
+ self.assertTrue(not t1 > t2)
for args in (3, 3, 3), (2, 4, 4), (2, 3, 5):
t2 = self.theclass(*args) # this is larger than t1
- self.failUnless(t1 < t2)
- self.failUnless(t2 > t1)
- self.failUnless(t1 <= t2)
- self.failUnless(t2 >= t1)
- self.failUnless(t1 != t2)
- self.failUnless(t2 != t1)
- self.failUnless(not t1 == t2)
- self.failUnless(not t2 == t1)
- self.failUnless(not t1 > t2)
- self.failUnless(not t2 < t1)
- self.failUnless(not t1 >= t2)
- self.failUnless(not t2 <= t1)
+ self.assertTrue(t1 < t2)
+ self.assertTrue(t2 > t1)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t2 >= t1)
+ self.assertTrue(t1 != t2)
+ self.assertTrue(t2 != t1)
+ self.assertTrue(not t1 == t2)
+ self.assertTrue(not t2 == t1)
+ self.assertTrue(not t1 > t2)
+ self.assertTrue(not t2 < t1)
+ self.assertTrue(not t1 >= t2)
+ self.assertTrue(not t2 <= t1)
for badarg in OTHERSTUFF:
self.assertEqual(t1 == badarg, False)
@@ -1031,8 +1031,8 @@
def test_bool(self):
# All dates are considered true.
- self.failUnless(self.theclass.min)
- self.failUnless(self.theclass.max)
+ self.assertTrue(self.theclass.min)
+ self.assertTrue(self.theclass.max)
def test_strftime_out_of_range(self):
# For nasty technical reasons, we can't handle years before 1900.
@@ -1155,7 +1155,7 @@
self.theclass.now()):
# Verify dt -> string -> datetime identity.
s = repr(dt)
- self.failUnless(s.startswith('datetime.'))
+ self.assertTrue(s.startswith('datetime.'))
s = s[9:]
dt2 = eval(s)
self.assertEqual(dt, dt2)
@@ -1228,7 +1228,7 @@
dt2 = self.theclass(2002, 3, 1, 10, 0, 0)
dt3 = self.theclass(2002, 3, 1, 9, 0, 0)
self.assertEqual(dt1, dt3)
- self.assert_(dt2 > dt3)
+ self.assertTrue(dt2 > dt3)
# Make sure comparison doesn't forget microseconds, and isn't done
# via comparing a float timestamp (an IEEE double doesn't have enough
@@ -1239,7 +1239,7 @@
us = timedelta(microseconds=1)
dt2 = dt1 + us
self.assertEqual(dt2 - dt1, us)
- self.assert_(dt1 < dt2)
+ self.assertTrue(dt1 < dt2)
def test_strftime_with_bad_tzname_replace(self):
# verify ok if tzinfo.tzname().replace() returns a non-string
@@ -1420,28 +1420,28 @@
t1 = self.theclass(*args)
t2 = self.theclass(*args)
self.assertEqual(t1, t2)
- self.failUnless(t1 <= t2)
- self.failUnless(t1 >= t2)
- self.failUnless(not t1 != t2)
- self.failUnless(not t1 < t2)
- self.failUnless(not t1 > t2)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t1 >= t2)
+ self.assertTrue(not t1 != t2)
+ self.assertTrue(not t1 < t2)
+ self.assertTrue(not t1 > t2)
for i in range(len(args)):
newargs = args[:]
newargs[i] = args[i] + 1
t2 = self.theclass(*newargs) # this is larger than t1
- self.failUnless(t1 < t2)
- self.failUnless(t2 > t1)
- self.failUnless(t1 <= t2)
- self.failUnless(t2 >= t1)
- self.failUnless(t1 != t2)
- self.failUnless(t2 != t1)
- self.failUnless(not t1 == t2)
- self.failUnless(not t2 == t1)
- self.failUnless(not t1 > t2)
- self.failUnless(not t2 < t1)
- self.failUnless(not t1 >= t2)
- self.failUnless(not t2 <= t1)
+ self.assertTrue(t1 < t2)
+ self.assertTrue(t2 > t1)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t2 >= t1)
+ self.assertTrue(t1 != t2)
+ self.assertTrue(t2 != t1)
+ self.assertTrue(not t1 == t2)
+ self.assertTrue(not t2 == t1)
+ self.assertTrue(not t1 > t2)
+ self.assertTrue(not t2 < t1)
+ self.assertTrue(not t1 >= t2)
+ self.assertTrue(not t2 <= t1)
# A helper for timestamp constructor tests.
@@ -1520,7 +1520,7 @@
if abs(from_timestamp - from_now) <= tolerance:
break
# Else try again a few times.
- self.failUnless(abs(from_timestamp - from_now) <= tolerance)
+ self.assertTrue(abs(from_timestamp - from_now) <= tolerance)
def test_strptime(self):
import _strptime
@@ -1689,7 +1689,7 @@
# Verify t -> string -> time identity.
s = repr(t)
- self.failUnless(s.startswith('datetime.'))
+ self.assertTrue(s.startswith('datetime.'))
s = s[9:]
t2 = eval(s)
self.assertEqual(t, t2)
@@ -1704,28 +1704,28 @@
t1 = self.theclass(*args)
t2 = self.theclass(*args)
self.assertEqual(t1, t2)
- self.failUnless(t1 <= t2)
- self.failUnless(t1 >= t2)
- self.failUnless(not t1 != t2)
- self.failUnless(not t1 < t2)
- self.failUnless(not t1 > t2)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t1 >= t2)
+ self.assertTrue(not t1 != t2)
+ self.assertTrue(not t1 < t2)
+ self.assertTrue(not t1 > t2)
for i in range(len(args)):
newargs = args[:]
newargs[i] = args[i] + 1
t2 = self.theclass(*newargs) # this is larger than t1
- self.failUnless(t1 < t2)
- self.failUnless(t2 > t1)
- self.failUnless(t1 <= t2)
- self.failUnless(t2 >= t1)
- self.failUnless(t1 != t2)
- self.failUnless(t2 != t1)
- self.failUnless(not t1 == t2)
- self.failUnless(not t2 == t1)
- self.failUnless(not t1 > t2)
- self.failUnless(not t2 < t1)
- self.failUnless(not t1 >= t2)
- self.failUnless(not t2 <= t1)
+ self.assertTrue(t1 < t2)
+ self.assertTrue(t2 > t1)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t2 >= t1)
+ self.assertTrue(t1 != t2)
+ self.assertTrue(t2 != t1)
+ self.assertTrue(not t1 == t2)
+ self.assertTrue(not t2 == t1)
+ self.assertTrue(not t1 > t2)
+ self.assertTrue(not t2 < t1)
+ self.assertTrue(not t1 >= t2)
+ self.assertTrue(not t2 <= t1)
for badarg in OTHERSTUFF:
self.assertEqual(t1 == badarg, False)
@@ -1876,10 +1876,10 @@
"%s(23, 15)" % name)
def test_resolution_info(self):
- self.assert_(isinstance(self.theclass.min, self.theclass))
- self.assert_(isinstance(self.theclass.max, self.theclass))
- self.assert_(isinstance(self.theclass.resolution, timedelta))
- self.assert_(self.theclass.max > self.theclass.min)
+ self.assertTrue(isinstance(self.theclass.min, self.theclass))
+ self.assertTrue(isinstance(self.theclass.max, self.theclass))
+ self.assertTrue(isinstance(self.theclass.resolution, timedelta))
+ self.assertTrue(self.theclass.max > self.theclass.min)
def test_pickling(self):
args = 20, 59, 16, 64**2
@@ -1899,12 +1899,12 @@
def test_bool(self):
cls = self.theclass
- self.failUnless(cls(1))
- self.failUnless(cls(0, 1))
- self.failUnless(cls(0, 0, 1))
- self.failUnless(cls(0, 0, 0, 1))
- self.failUnless(not cls(0))
- self.failUnless(not cls())
+ self.assertTrue(cls(1))
+ self.assertTrue(cls(0, 1))
+ self.assertTrue(cls(0, 0, 1))
+ self.assertTrue(cls(0, 0, 0, 1))
+ self.assertTrue(not cls(0))
+ self.assertTrue(not cls())
def test_replace(self):
cls = self.theclass
@@ -2001,7 +2001,7 @@
def utcoffset(self, dt): pass
b = BetterTry()
t = cls(1, 1, 1, tzinfo=b)
- self.failUnless(t.tzinfo is b)
+ self.assertTrue(t.tzinfo is b)
def test_utc_offset_out_of_bounds(self):
class Edgy(tzinfo):
@@ -2040,9 +2040,9 @@
for t in (cls(1, 1, 1),
cls(1, 1, 1, tzinfo=None),
cls(1, 1, 1, tzinfo=C1())):
- self.failUnless(t.utcoffset() is None)
- self.failUnless(t.dst() is None)
- self.failUnless(t.tzname() is None)
+ self.assertTrue(t.utcoffset() is None)
+ self.assertTrue(t.dst() is None)
+ self.assertTrue(t.tzname() is None)
class C3(tzinfo):
def utcoffset(self, dt): return timedelta(minutes=-1439)
@@ -2137,7 +2137,7 @@
self.assertEqual(t.minute, 0)
self.assertEqual(t.second, 0)
self.assertEqual(t.microsecond, 0)
- self.failUnless(t.tzinfo is None)
+ self.assertTrue(t.tzinfo is None)
def test_zones(self):
est = FixedOffset(-300, "EST", 1)
@@ -2152,25 +2152,25 @@
self.assertEqual(t1.tzinfo, est)
self.assertEqual(t2.tzinfo, utc)
self.assertEqual(t3.tzinfo, met)
- self.failUnless(t4.tzinfo is None)
+ self.assertTrue(t4.tzinfo is None)
self.assertEqual(t5.tzinfo, utc)
self.assertEqual(t1.utcoffset(), timedelta(minutes=-300))
self.assertEqual(t2.utcoffset(), timedelta(minutes=0))
self.assertEqual(t3.utcoffset(), timedelta(minutes=60))
- self.failUnless(t4.utcoffset() is None)
+ self.assertTrue(t4.utcoffset() is None)
self.assertRaises(TypeError, t1.utcoffset, "no args")
self.assertEqual(t1.tzname(), "EST")
self.assertEqual(t2.tzname(), "UTC")
self.assertEqual(t3.tzname(), "MET")
- self.failUnless(t4.tzname() is None)
+ self.assertTrue(t4.tzname() is None)
self.assertRaises(TypeError, t1.tzname, "no args")
self.assertEqual(t1.dst(), timedelta(minutes=1))
self.assertEqual(t2.dst(), timedelta(minutes=-2))
self.assertEqual(t3.dst(), timedelta(minutes=3))
- self.failUnless(t4.dst() is None)
+ self.assertTrue(t4.dst() is None)
self.assertRaises(TypeError, t1.dst, "no args")
self.assertEqual(hash(t1), hash(t2))
@@ -2246,7 +2246,7 @@
green = pickler.dumps(orig, proto)
derived = unpickler.loads(green)
self.assertEqual(orig, derived)
- self.failUnless(isinstance(derived.tzinfo, PicklableFixedOffset))
+ self.assertTrue(isinstance(derived.tzinfo, PicklableFixedOffset))
self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
self.assertEqual(derived.tzname(), 'cookie')
@@ -2255,20 +2255,20 @@
cls = self.theclass
t = cls(0, tzinfo=FixedOffset(-300, ""))
- self.failUnless(t)
+ self.assertTrue(t)
t = cls(5, tzinfo=FixedOffset(-300, ""))
- self.failUnless(t)
+ self.assertTrue(t)
t = cls(5, tzinfo=FixedOffset(300, ""))
- self.failUnless(not t)
+ self.assertTrue(not t)
t = cls(23, 59, tzinfo=FixedOffset(23*60 + 59, ""))
- self.failUnless(not t)
+ self.assertTrue(not t)
# Mostly ensuring this doesn't overflow internally.
t = cls(0, tzinfo=FixedOffset(23*60 + 59, ""))
- self.failUnless(t)
+ self.assertTrue(t)
# But this should yield a value error -- the utcoffset is bogus.
t = cls(0, tzinfo=FixedOffset(24*60, ""))
@@ -2302,13 +2302,13 @@
# Ensure we can get rid of a tzinfo.
self.assertEqual(base.tzname(), "+100")
base2 = base.replace(tzinfo=None)
- self.failUnless(base2.tzinfo is None)
- self.failUnless(base2.tzname() is None)
+ self.assertTrue(base2.tzinfo is None)
+ self.assertTrue(base2.tzname() is None)
# Ensure we can add one.
base3 = base2.replace(tzinfo=z100)
self.assertEqual(base, base3)
- self.failUnless(base.tzinfo is base3.tzinfo)
+ self.assertTrue(base.tzinfo is base3.tzinfo)
# Out of bounds.
base = cls(1)
@@ -2345,7 +2345,7 @@
# But if they're not identical, it isn't ignored.
t2 = t2.replace(tzinfo=Varies())
- self.failUnless(t1 < t2) # t1's offset counter still going up
+ self.assertTrue(t1 < t2) # t1's offset counter still going up
def test_subclass_timetz(self):
@@ -2401,9 +2401,9 @@
tzinfo=FixedOffset(-1439, ""))
# Make sure those compare correctly, and w/o overflow.
- self.failUnless(t1 < t2)
- self.failUnless(t1 != t2)
- self.failUnless(t2 > t1)
+ self.assertTrue(t1 < t2)
+ self.assertTrue(t1 != t2)
+ self.assertTrue(t2 > t1)
self.assertEqual(t1, t1)
self.assertEqual(t2, t2)
@@ -2415,21 +2415,21 @@
# Change t1 not to subtract a minute, and t1 should be larger.
t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(0, ""))
- self.failUnless(t1 > t2)
+ self.assertTrue(t1 > t2)
# Change t1 to subtract 2 minutes, and t1 should be smaller.
t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(2, ""))
- self.failUnless(t1 < t2)
+ self.assertTrue(t1 < t2)
# Back to the original t1, but make seconds resolve it.
t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""),
second=1)
- self.failUnless(t1 > t2)
+ self.assertTrue(t1 > t2)
# Likewise, but make microseconds resolve it.
t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""),
microsecond=1)
- self.failUnless(t1 > t2)
+ self.assertTrue(t1 > t2)
# Make t2 naive and it should fail.
t2 = self.theclass.min
@@ -2473,7 +2473,7 @@
green = pickler.dumps(orig, proto)
derived = unpickler.loads(green)
self.assertEqual(orig, derived)
- self.failUnless(isinstance(derived.tzinfo,
+ self.assertTrue(isinstance(derived.tzinfo,
PicklableFixedOffset))
self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
self.assertEqual(derived.tzname(), 'cookie')
@@ -2544,7 +2544,7 @@
tz55 = FixedOffset(-330, "west 5:30")
timeaware = now.time().replace(tzinfo=tz55)
nowaware = self.theclass.combine(now.date(), timeaware)
- self.failUnless(nowaware.tzinfo is tz55)
+ self.assertTrue(nowaware.tzinfo is tz55)
self.assertEqual(nowaware.timetz(), timeaware)
# Can't mix aware and non-aware.
@@ -2563,15 +2563,15 @@
# Adding a delta should preserve tzinfo.
delta = timedelta(weeks=1, minutes=12, microseconds=5678)
nowawareplus = nowaware + delta
- self.failUnless(nowaware.tzinfo is tz55)
+ self.assertTrue(nowaware.tzinfo is tz55)
nowawareplus2 = delta + nowaware
- self.failUnless(nowawareplus2.tzinfo is tz55)
+ self.assertTrue(nowawareplus2.tzinfo is tz55)
self.assertEqual(nowawareplus, nowawareplus2)
# that - delta should be what we started with, and that - what we
# started with should be delta.
diff = nowawareplus - delta
- self.failUnless(diff.tzinfo is tz55)
+ self.assertTrue(diff.tzinfo is tz55)
self.assertEqual(nowaware, diff)
self.assertRaises(TypeError, lambda: delta - nowawareplus)
self.assertEqual(nowawareplus - nowaware, delta)
@@ -2580,7 +2580,7 @@
tzr = FixedOffset(random.randrange(-1439, 1440), "randomtimezone")
# Attach it to nowawareplus.
nowawareplus = nowawareplus.replace(tzinfo=tzr)
- self.failUnless(nowawareplus.tzinfo is tzr)
+ self.assertTrue(nowawareplus.tzinfo is tzr)
# Make sure the difference takes the timezone adjustments into account.
got = nowaware - nowawareplus
# Expected: (nowaware base - nowaware offset) -
@@ -2607,7 +2607,7 @@
off42 = FixedOffset(42, "42")
another = meth(off42)
again = meth(tz=off42)
- self.failUnless(another.tzinfo is again.tzinfo)
+ self.assertTrue(another.tzinfo is again.tzinfo)
self.assertEqual(another.utcoffset(), timedelta(minutes=42))
# Bad argument with and w/o naming the keyword.
self.assertRaises(TypeError, meth, 16)
@@ -2624,7 +2624,7 @@
utc = FixedOffset(0, "utc", 0)
for dummy in range(3):
now = datetime.now(weirdtz)
- self.failUnless(now.tzinfo is weirdtz)
+ self.assertTrue(now.tzinfo is weirdtz)
utcnow = datetime.utcnow().replace(tzinfo=utc)
now2 = utcnow.astimezone(weirdtz)
if abs(now - now2) < timedelta(seconds=30):
@@ -2645,7 +2645,7 @@
off42 = FixedOffset(42, "42")
another = meth(ts, off42)
again = meth(ts, tz=off42)
- self.failUnless(another.tzinfo is again.tzinfo)
+ self.assertTrue(another.tzinfo is again.tzinfo)
self.assertEqual(another.utcoffset(), timedelta(minutes=42))
# Bad argument with and w/o naming the keyword.
self.assertRaises(TypeError, meth, ts, 16)
@@ -2840,13 +2840,13 @@
# Ensure we can get rid of a tzinfo.
self.assertEqual(base.tzname(), "+100")
base2 = base.replace(tzinfo=None)
- self.failUnless(base2.tzinfo is None)
- self.failUnless(base2.tzname() is None)
+ self.assertTrue(base2.tzinfo is None)
+ self.assertTrue(base2.tzname() is None)
# Ensure we can add one.
base3 = base2.replace(tzinfo=z100)
self.assertEqual(base, base3)
- self.failUnless(base.tzinfo is base3.tzinfo)
+ self.assertTrue(base.tzinfo is base3.tzinfo)
# Out of bounds.
base = cls(2000, 2, 29)
@@ -2859,20 +2859,20 @@
fm5h = FixedOffset(-timedelta(hours=5), "m300")
dt = self.theclass.now(tz=f44m)
- self.failUnless(dt.tzinfo is f44m)
+ self.assertTrue(dt.tzinfo is f44m)
# Replacing with degenerate tzinfo raises an exception.
self.assertRaises(ValueError, dt.astimezone, fnone)
# Ditto with None tz.
self.assertRaises(TypeError, dt.astimezone, None)
# Replacing with same tzinfo makes no change.
x = dt.astimezone(dt.tzinfo)
- self.failUnless(x.tzinfo is f44m)
+ self.assertTrue(x.tzinfo is f44m)
self.assertEqual(x.date(), dt.date())
self.assertEqual(x.time(), dt.time())
# Replacing with different tzinfo does adjust.
got = dt.astimezone(fm5h)
- self.failUnless(got.tzinfo is fm5h)
+ self.assertTrue(got.tzinfo is fm5h)
self.assertEqual(got.utcoffset(), timedelta(hours=-5))
expected = dt - dt.utcoffset() # in effect, convert to UTC
expected += fm5h.utcoffset(dt) # and from there to local time
@@ -2880,7 +2880,7 @@
self.assertEqual(got.date(), expected.date())
self.assertEqual(got.time(), expected.time())
self.assertEqual(got.timetz(), expected.timetz())
- self.failUnless(got.tzinfo is expected.tzinfo)
+ self.assertTrue(got.tzinfo is expected.tzinfo)
self.assertEqual(got, expected)
def test_aware_subtract(self):
@@ -2955,7 +2955,7 @@
# But if they're not identical, it isn't ignored.
t2 = t2.replace(tzinfo=Varies())
- self.failUnless(t1 < t2) # t1's offset counter still going up
+ self.assertTrue(t1 < t2) # t1's offset counter still going up
def test_subclass_datetimetz(self):
@@ -3306,10 +3306,10 @@
# type comparison, despite that datetime is a subclass of date.
as_date = date.today()
as_datetime = datetime.combine(as_date, time())
- self.assert_(as_date != as_datetime)
- self.assert_(as_datetime != as_date)
- self.assert_(not as_date == as_datetime)
- self.assert_(not as_datetime == as_date)
+ self.assertTrue(as_date != as_datetime)
+ self.assertTrue(as_datetime != as_date)
+ self.assertTrue(not as_date == as_datetime)
+ self.assertTrue(not as_datetime == as_date)
self.assertRaises(TypeError, lambda: as_date < as_datetime)
self.assertRaises(TypeError, lambda: as_datetime < as_date)
self.assertRaises(TypeError, lambda: as_date <= as_datetime)
Modified: python/branches/py3k/Lib/test/test_dbm.py
==============================================================================
--- python/branches/py3k/Lib/test/test_dbm.py (original)
+++ python/branches/py3k/Lib/test/test_dbm.py Wed Jul 1 01:06:06 2009
@@ -57,7 +57,7 @@
return keys
def test_error(self):
- self.assert_(issubclass(self.module.error, IOError))
+ self.assertTrue(issubclass(self.module.error, IOError))
def test_anydbm_not_existing(self):
self.assertRaises(dbm.error, dbm.open, _fname)
@@ -154,9 +154,9 @@
self.d[k] = v
self.assertEqual(sorted(self.d.keys()), sorted(k for (k, v) in a))
for k, v in a:
- self.assert_(k in self.d)
+ self.assertTrue(k in self.d)
self.assertEqual(self.d[k], v)
- self.assert_(b'xxx' not in self.d)
+ self.assertTrue(b'xxx' not in self.d)
self.assertRaises(KeyError, lambda: self.d[b'xxx'])
self.d.close()
Modified: python/branches/py3k/Lib/test/test_dbm_dumb.py
==============================================================================
--- python/branches/py3k/Lib/test/test_dbm_dumb.py (original)
+++ python/branches/py3k/Lib/test/test_dbm_dumb.py Wed Jul 1 01:06:06 2009
@@ -118,7 +118,7 @@
f['1'] = 'a'
f.close()
f = dumbdbm.open(_fname, 'r')
- self.assert_('\u00fc' in f)
+ self.assertTrue('\u00fc' in f)
self.assertEqual(f['\u00fc'.encode('utf-8')],
self._dict['\u00fc'.encode('utf-8')])
self.assertEqual(f[b'1'], b'a')
Modified: python/branches/py3k/Lib/test/test_dbm_gnu.py
==============================================================================
--- python/branches/py3k/Lib/test/test_dbm_gnu.py (original)
+++ python/branches/py3k/Lib/test/test_dbm_gnu.py Wed Jul 1 01:06:06 2009
@@ -24,11 +24,11 @@
self.g[b'bytes'] = b'data'
key_set = set(self.g.keys())
self.assertEqual(key_set, set([b'a', b'bytes', b'12345678910']))
- self.assert_(b'a' in self.g)
+ self.assertTrue(b'a' in self.g)
self.assertEqual(self.g[b'bytes'], b'data')
key = self.g.firstkey()
while key:
- self.assert_(key in key_set)
+ self.assertTrue(key in key_set)
key_set.remove(key)
key = self.g.nextkey(key)
self.assertRaises(KeyError, lambda: self.g['xxx'])
@@ -66,7 +66,7 @@
self.g['x'] = 'x' * 10000
size1 = os.path.getsize(filename)
- self.assert_(size0 < size1)
+ self.assertTrue(size0 < size1)
del self.g['x']
# 'size' is supposed to be the same even after deleting an entry.
@@ -74,7 +74,7 @@
self.g.reorganize()
size2 = os.path.getsize(filename)
- self.assert_(size1 > size2 >= size0)
+ self.assertTrue(size1 > size2 >= size0)
def test_main():
Modified: python/branches/py3k/Lib/test/test_dbm_ndbm.py
==============================================================================
--- python/branches/py3k/Lib/test/test_dbm_ndbm.py (original)
+++ python/branches/py3k/Lib/test/test_dbm_ndbm.py Wed Jul 1 01:06:06 2009
@@ -19,12 +19,12 @@
def test_keys(self):
self.d = dbm.ndbm.open(self.filename, 'c')
- self.assert_(self.d.keys() == [])
+ self.assertTrue(self.d.keys() == [])
self.d['a'] = 'b'
self.d[b'bytes'] = b'data'
self.d['12345678910'] = '019237410982340912840198242'
self.d.keys()
- self.assert_(b'a' in self.d)
+ self.assertTrue(b'a' in self.d)
self.assertEqual(self.d[b'bytes'], b'data')
self.d.close()
Modified: python/branches/py3k/Lib/test/test_decimal.py
==============================================================================
--- python/branches/py3k/Lib/test/test_decimal.py (original)
+++ python/branches/py3k/Lib/test/test_decimal.py Wed Jul 1 01:06:06 2009
@@ -507,7 +507,7 @@
# from int
d = nc.create_decimal(456)
- self.failUnless(isinstance(d, Decimal))
+ self.assertTrue(isinstance(d, Decimal))
self.assertEqual(nc.create_decimal(45678),
nc.create_decimal('457E+2'))
@@ -1050,12 +1050,12 @@
f = Decimal('2')
for x, y in [(n, n), (n, i), (i, n), (n, f), (f, n),
(s, n), (n, s), (s, i), (i, s), (s, f), (f, s), (s, s)]:
- self.assert_(x != y)
- self.assert_(not (x == y))
- self.assert_(not (x < y))
- self.assert_(not (x <= y))
- self.assert_(not (x > y))
- self.assert_(not (x >= y))
+ self.assertTrue(x != y)
+ self.assertTrue(not (x == y))
+ self.assertTrue(not (x < y))
+ self.assertTrue(not (x <= y))
+ self.assertTrue(not (x > y))
+ self.assertTrue(not (x >= y))
# The following are two functions used to test threading in the next class
@@ -1128,18 +1128,18 @@
dc = Decimal('45')
#two Decimals
- self.failUnless(dc > da)
- self.failUnless(dc >= da)
- self.failUnless(da < dc)
- self.failUnless(da <= dc)
+ self.assertTrue(dc > da)
+ self.assertTrue(dc >= da)
+ self.assertTrue(da < dc)
+ self.assertTrue(da <= dc)
self.assertEqual(da, db)
- self.failUnless(da != dc)
- self.failUnless(da <= db)
- self.failUnless(da >= db)
+ self.assertTrue(da != dc)
+ self.assertTrue(da <= db)
+ self.assertTrue(da >= db)
#a Decimal and an int
- self.failUnless(dc > 23)
- self.failUnless(23 < dc)
+ self.assertTrue(dc > 23)
+ self.assertTrue(23 < dc)
self.assertEqual(dc, 45)
#a Decimal and uncomparable
@@ -1200,8 +1200,8 @@
#the same hash that to an int
self.assertEqual(hash(Decimal(23)), hash(23))
self.assertRaises(TypeError, hash, Decimal('NaN'))
- self.assert_(hash(Decimal('Inf')))
- self.assert_(hash(Decimal('-Inf')))
+ self.assertTrue(hash(Decimal('Inf')))
+ self.assertTrue(hash(Decimal('-Inf')))
# check that the value of the hash doesn't depend on the
# current context (issue #1757)
@@ -1228,22 +1228,22 @@
l2 = 28
#between Decimals
- self.failUnless(min(d1,d2) is d1)
- self.failUnless(min(d2,d1) is d1)
- self.failUnless(max(d1,d2) is d2)
- self.failUnless(max(d2,d1) is d2)
+ self.assertTrue(min(d1,d2) is d1)
+ self.assertTrue(min(d2,d1) is d1)
+ self.assertTrue(max(d1,d2) is d2)
+ self.assertTrue(max(d2,d1) is d2)
#between Decimal and long
- self.failUnless(min(d1,l2) is d1)
- self.failUnless(min(l2,d1) is d1)
- self.failUnless(max(l1,d2) is d2)
- self.failUnless(max(d2,l1) is d2)
+ self.assertTrue(min(d1,l2) is d1)
+ self.assertTrue(min(l2,d1) is d1)
+ self.assertTrue(max(l1,d2) is d2)
+ self.assertTrue(max(d2,l1) is d2)
def test_as_nonzero(self):
#as false
- self.failIf(Decimal(0))
+ self.assertFalse(Decimal(0))
#as true
- self.failUnless(Decimal('0.372'))
+ self.assertTrue(Decimal('0.372'))
def test_tostring_methods(self):
#Test str and repr methods.
@@ -1513,10 +1513,10 @@
class DecimalPythonAPItests(unittest.TestCase):
def test_abc(self):
- self.assert_(issubclass(Decimal, numbers.Number))
- self.assert_(not issubclass(Decimal, numbers.Real))
- self.assert_(isinstance(Decimal(0), numbers.Number))
- self.assert_(not isinstance(Decimal(0), numbers.Real))
+ self.assertTrue(issubclass(Decimal, numbers.Number))
+ self.assertTrue(not issubclass(Decimal, numbers.Real))
+ self.assertTrue(isinstance(Decimal(0), numbers.Number))
+ self.assertTrue(not isinstance(Decimal(0), numbers.Real))
def test_pickle(self):
d = Decimal('-3.141590000')
@@ -1555,9 +1555,9 @@
'0.1000000000000000055511151231257827021181583404541015625')
bigint = 12345678901234567890123456789
self.assertEqual(MyDecimal.from_float(bigint), MyDecimal(bigint))
- self.assert_(MyDecimal.from_float(float('nan')).is_qnan())
- self.assert_(MyDecimal.from_float(float('inf')).is_infinite())
- self.assert_(MyDecimal.from_float(float('-inf')).is_infinite())
+ self.assertTrue(MyDecimal.from_float(float('nan')).is_qnan())
+ self.assertTrue(MyDecimal.from_float(float('inf')).is_infinite())
+ self.assertTrue(MyDecimal.from_float(float('-inf')).is_infinite())
self.assertEqual(str(MyDecimal.from_float(float('nan'))),
str(Decimal('NaN')))
self.assertEqual(str(MyDecimal.from_float(float('inf'))),
@@ -1604,8 +1604,8 @@
self.assertEqual(v1, v2)
def test_equality_with_other_types(self):
- self.assert_(Decimal(10) in ['a', 1.0, Decimal(10), (1,2), {}])
- self.assert_(Decimal(10) not in ['a', 1.0, (1,2), {}])
+ self.assertTrue(Decimal(10) in ['a', 1.0, Decimal(10), (1,2), {}])
+ self.assertTrue(Decimal(10) not in ['a', 1.0, (1,2), {}])
def test_copy(self):
# All copies should be deep
@@ -1625,9 +1625,9 @@
with localcontext() as enter_ctx:
set_ctx = getcontext()
final_ctx = getcontext()
- self.assert_(orig_ctx is final_ctx, 'did not restore context correctly')
- self.assert_(orig_ctx is not set_ctx, 'did not copy the context')
- self.assert_(set_ctx is enter_ctx, '__enter__ returned wrong context')
+ self.assertTrue(orig_ctx is final_ctx, 'did not restore context correctly')
+ self.assertTrue(orig_ctx is not set_ctx, 'did not copy the context')
+ self.assertTrue(set_ctx is enter_ctx, '__enter__ returned wrong context')
def test_localcontextarg(self):
# Use a copy of the supplied context in the block
@@ -1636,10 +1636,10 @@
with localcontext(new_ctx) as enter_ctx:
set_ctx = getcontext()
final_ctx = getcontext()
- self.assert_(orig_ctx is final_ctx, 'did not restore context correctly')
- self.assert_(set_ctx.prec == new_ctx.prec, 'did not set correct context')
- self.assert_(new_ctx is not set_ctx, 'did not copy the context')
- self.assert_(set_ctx is enter_ctx, '__enter__ returned wrong context')
+ self.assertTrue(orig_ctx is final_ctx, 'did not restore context correctly')
+ self.assertTrue(set_ctx.prec == new_ctx.prec, 'did not set correct context')
+ self.assertTrue(new_ctx is not set_ctx, 'did not copy the context')
+ self.assertTrue(set_ctx is enter_ctx, '__enter__ returned wrong context')
class ContextFlags(unittest.TestCase):
def test_flags_irrelevant(self):
Modified: python/branches/py3k/Lib/test/test_defaultdict.py
==============================================================================
--- python/branches/py3k/Lib/test/test_defaultdict.py (original)
+++ python/branches/py3k/Lib/test/test_defaultdict.py Wed Jul 1 01:06:06 2009
@@ -25,21 +25,21 @@
d1[13]
d1[14]
self.assertEqual(d1, {12: [42, 24], 13: [], 14: []})
- self.assert_(d1[12] is not d1[13] is not d1[14])
+ self.assertTrue(d1[12] is not d1[13] is not d1[14])
d2 = defaultdict(list, foo=1, bar=2)
self.assertEqual(d2.default_factory, list)
self.assertEqual(d2, {"foo": 1, "bar": 2})
self.assertEqual(d2["foo"], 1)
self.assertEqual(d2["bar"], 2)
self.assertEqual(d2[42], [])
- self.assert_("foo" in d2)
- self.assert_("foo" in d2.keys())
- self.assert_("bar" in d2)
- self.assert_("bar" in d2.keys())
- self.assert_(42 in d2)
- self.assert_(42 in d2.keys())
- self.assert_(12 not in d2)
- self.assert_(12 not in d2.keys())
+ self.assertTrue("foo" in d2)
+ self.assertTrue("foo" in d2.keys())
+ self.assertTrue("bar" in d2)
+ self.assertTrue("bar" in d2.keys())
+ self.assertTrue(42 in d2)
+ self.assertTrue(42 in d2.keys())
+ self.assertTrue(12 not in d2)
+ self.assertTrue(12 not in d2.keys())
d2.default_factory = None
self.assertEqual(d2.default_factory, None)
try:
@@ -68,7 +68,7 @@
self.assertEqual(repr(d2), "defaultdict(<class 'int'>, {12: 42})")
def foo(): return 43
d3 = defaultdict(foo)
- self.assert_(d3.default_factory is foo)
+ self.assertTrue(d3.default_factory is foo)
d3[13]
self.assertEqual(repr(d3), "defaultdict(%s, {13: 43})" % repr(foo))
@@ -127,7 +127,7 @@
d2 = copy.deepcopy(d1)
self.assertEqual(d2.default_factory, foobar)
self.assertEqual(d2, d1)
- self.assert_(d1[1] is not d2[1])
+ self.assertTrue(d1[1] is not d2[1])
d1.default_factory = list
d2 = copy.deepcopy(d1)
self.assertEqual(d2.default_factory, list)
@@ -150,7 +150,7 @@
def _factory(self):
return []
d = sub()
- self.assert_(repr(d).startswith(
+ self.assertTrue(repr(d).startswith(
"defaultdict(<bound method sub._factory of defaultdict(..."))
# NOTE: printing a subclass of a builtin type does not call its
Modified: python/branches/py3k/Lib/test/test_deque.py
==============================================================================
--- python/branches/py3k/Lib/test/test_deque.py (original)
+++ python/branches/py3k/Lib/test/test_deque.py Wed Jul 1 01:06:06 2009
@@ -188,9 +188,9 @@
self.assertEqual(len(d), n-i)
j = random.randrange(-len(d), len(d))
val = d[j]
- self.assert_(val in d)
+ self.assertTrue(val in d)
del d[j]
- self.assert_(val not in d)
+ self.assertTrue(val not in d)
self.assertEqual(len(d), 0)
def test_rotate(self):
@@ -291,7 +291,7 @@
self.assertRaises(RuntimeError, d.remove, 'c')
for x, y in zip(d, e):
# verify that original order and values are retained.
- self.assert_(x is y)
+ self.assertTrue(x is y)
# Handle evil mutator
for match in (True, False):
@@ -305,7 +305,7 @@
e = eval(repr(d))
self.assertEqual(list(d), list(e))
d.append(d)
- self.assert_('...' in repr(d))
+ self.assertTrue('...' in repr(d))
def test_print(self):
d = deque(range(200))
@@ -461,7 +461,7 @@
obj.x = iter(container)
del obj, container
gc.collect()
- self.assert_(ref() is None, "Cycle was not collected")
+ self.assertTrue(ref() is None, "Cycle was not collected")
class TestVariousIteratorArgs(unittest.TestCase):
Modified: python/branches/py3k/Lib/test/test_descr.py
==============================================================================
--- python/branches/py3k/Lib/test/test_descr.py (original)
+++ python/branches/py3k/Lib/test/test_descr.py Wed Jul 1 01:06:06 2009
@@ -387,12 +387,12 @@
def test_python_dicts(self):
# Testing Python subclass of dict...
- self.assert_(issubclass(dict, dict))
- self.assert_(isinstance({}, dict))
+ self.assertTrue(issubclass(dict, dict))
+ self.assertTrue(isinstance({}, dict))
d = dict()
self.assertEqual(d, {})
- self.assert_(d.__class__ is dict)
- self.assert_(isinstance(d, dict))
+ self.assertTrue(d.__class__ is dict)
+ self.assertTrue(isinstance(d, dict))
class C(dict):
state = -1
def __init__(self_local, *a, **kw):
@@ -405,13 +405,13 @@
def __getitem__(self, key):
return self.get(key, 0)
def __setitem__(self_local, key, value):
- self.assert_(isinstance(key, type(0)))
+ self.assertTrue(isinstance(key, type(0)))
dict.__setitem__(self_local, key, value)
def setstate(self, state):
self.state = state
def getstate(self):
return self.state
- self.assert_(issubclass(C, dict))
+ self.assertTrue(issubclass(C, dict))
a1 = C(12)
self.assertEqual(a1.state, 12)
a2 = C(foo=1, bar=2)
@@ -504,7 +504,7 @@
return 42
self.assertEqual(C.name, 'C')
self.assertEqual(C.bases, ())
- self.assert_('spam' in C.dict)
+ self.assertTrue('spam' in C.dict)
c = C()
self.assertEqual(c.spam(), 42)
@@ -569,7 +569,7 @@
def _set_x(self, x):
self.__x = -x
a = A()
- self.assert_(not hasattr(a, "x"))
+ self.assertTrue(not hasattr(a, "x"))
a.x = 12
self.assertEqual(a.x, 12)
self.assertEqual(a._A__x, -12)
@@ -960,7 +960,7 @@
x = C()
x.foo = 5
self.assertEqual(x.foo, 5)
- self.assert_(type(slots[0]) is str)
+ self.assertTrue(type(slots[0]) is str)
# this used to leak references
try:
class C(object):
@@ -1049,7 +1049,7 @@
class D(object):
__slots__ = ["__dict__"]
a = D()
- self.assert_(hasattr(a, "__dict__"))
+ self.assertTrue(hasattr(a, "__dict__"))
self.assertFalse(hasattr(a, "__weakref__"))
a.foo = 42
self.assertEqual(a.__dict__, {"foo": 42})
@@ -1057,7 +1057,7 @@
class W(object):
__slots__ = ["__weakref__"]
a = W()
- self.assert_(hasattr(a, "__weakref__"))
+ self.assertTrue(hasattr(a, "__weakref__"))
self.assertFalse(hasattr(a, "__dict__"))
try:
a.foo = 42
@@ -1069,16 +1069,16 @@
class C1(W, D):
__slots__ = []
a = C1()
- self.assert_(hasattr(a, "__dict__"))
- self.assert_(hasattr(a, "__weakref__"))
+ self.assertTrue(hasattr(a, "__dict__"))
+ self.assertTrue(hasattr(a, "__weakref__"))
a.foo = 42
self.assertEqual(a.__dict__, {"foo": 42})
class C2(D, W):
__slots__ = []
a = C2()
- self.assert_(hasattr(a, "__dict__"))
- self.assert_(hasattr(a, "__weakref__"))
+ self.assertTrue(hasattr(a, "__dict__"))
+ self.assertTrue(hasattr(a, "__weakref__"))
a.foo = 42
self.assertEqual(a.__dict__, {"foo": 42})
@@ -1094,7 +1094,7 @@
MyABC.register(Unrelated)
u = Unrelated()
- self.assert_(isinstance(u, MyABC))
+ self.assertTrue(isinstance(u, MyABC))
# This used to crash
self.assertRaises(TypeError, MyABC.a.__set__, u, 3)
@@ -1350,7 +1350,7 @@
class E: # *not* subclassing from C
foo = C.foo
self.assertEqual(E().foo.__func__, C.foo) # i.e., unbound
- self.assert_(repr(C.foo.__get__(C())).startswith("<bound method "))
+ self.assertTrue(repr(C.foo.__get__(C())).startswith("<bound method "))
def test_compattr(self):
# Testing computed attributes...
@@ -1537,7 +1537,7 @@
class E(object):
foo = C.foo
self.assertEqual(E().foo.__func__, C.foo) # i.e., unbound
- self.assert_(repr(C.foo.__get__(C(1))).startswith("<bound method "))
+ self.assertTrue(repr(C.foo.__get__(C(1))).startswith("<bound method "))
def test_special_method_lookup(self):
# The lookup of special methods bypasses __getattr__ and
@@ -1648,21 +1648,21 @@
raise IndexError
c1 = C()
c2 = C()
- self.assert_(not not c1) # What?
+ self.assertTrue(not not c1) # What?
self.assertNotEqual(id(c1), id(c2))
hash(c1)
hash(c2)
self.assertEqual(c1, c1)
- self.assert_(c1 != c2)
- self.assert_(not c1 != c1)
- self.assert_(not c1 == c2)
+ self.assertTrue(c1 != c2)
+ self.assertTrue(not c1 != c1)
+ self.assertTrue(not c1 == c2)
# Note that the module name appears in str/repr, and that varies
# depending on whether this test is run standalone or from a framework.
- self.assert_(str(c1).find('C object at ') >= 0)
+ self.assertTrue(str(c1).find('C object at ') >= 0)
self.assertEqual(str(c1), repr(c1))
- self.assert_(-1 not in c1)
+ self.assertTrue(-1 not in c1)
for i in range(10):
- self.assert_(i in c1)
+ self.assertTrue(i in c1)
self.assertFalse(10 in c1)
# Test the default behavior for dynamic classes
class D(object):
@@ -1671,21 +1671,21 @@
raise IndexError
d1 = D()
d2 = D()
- self.assert_(not not d1)
+ self.assertTrue(not not d1)
self.assertNotEqual(id(d1), id(d2))
hash(d1)
hash(d2)
self.assertEqual(d1, d1)
self.assertNotEqual(d1, d2)
- self.assert_(not d1 != d1)
- self.assert_(not d1 == d2)
+ self.assertTrue(not d1 != d1)
+ self.assertTrue(not d1 == d2)
# Note that the module name appears in str/repr, and that varies
# depending on whether this test is run standalone or from a framework.
- self.assert_(str(d1).find('D object at ') >= 0)
+ self.assertTrue(str(d1).find('D object at ') >= 0)
self.assertEqual(str(d1), repr(d1))
- self.assert_(-1 not in d1)
+ self.assertTrue(-1 not in d1)
for i in range(10):
- self.assert_(i in d1)
+ self.assertTrue(i in d1)
self.assertFalse(10 in d1)
# Test overridden behavior
class Proxy(object):
@@ -1717,22 +1717,22 @@
p1 = Proxy(1)
p_1 = Proxy(-1)
self.assertFalse(p0)
- self.assert_(not not p1)
+ self.assertTrue(not not p1)
self.assertEqual(hash(p0), hash(0))
self.assertEqual(p0, p0)
self.assertNotEqual(p0, p1)
- self.assert_(not p0 != p0)
+ self.assertTrue(not p0 != p0)
self.assertEqual(not p0, p1)
- self.assert_(p0 < p1)
- self.assert_(p0 <= p1)
- self.assert_(p1 > p0)
- self.assert_(p1 >= p0)
+ self.assertTrue(p0 < p1)
+ self.assertTrue(p0 <= p1)
+ self.assertTrue(p1 > p0)
+ self.assertTrue(p1 >= p0)
self.assertEqual(str(p0), "Proxy:0")
self.assertEqual(repr(p0), "Proxy(0)")
p10 = Proxy(range(10))
self.assertFalse(-1 in p10)
for i in range(10):
- self.assert_(i in p10)
+ self.assertTrue(i in p10)
self.assertFalse(10 in p10)
def test_weakrefs(self):
@@ -1753,7 +1753,7 @@
try:
weakref.ref(no)
except TypeError as msg:
- self.assert_(str(msg).find("weak reference") >= 0)
+ self.assertTrue(str(msg).find("weak reference") >= 0)
else:
self.fail("weakref.ref(no) should be illegal")
class Weak(object):
@@ -1790,18 +1790,18 @@
self.assertFalse(hasattr(a, "x"))
raw = C.__dict__['x']
- self.assert_(isinstance(raw, property))
+ self.assertTrue(isinstance(raw, property))
attrs = dir(raw)
- self.assert_("__doc__" in attrs)
- self.assert_("fget" in attrs)
- self.assert_("fset" in attrs)
- self.assert_("fdel" in attrs)
+ self.assertTrue("__doc__" in attrs)
+ self.assertTrue("fget" in attrs)
+ self.assertTrue("fset" in attrs)
+ self.assertTrue("fdel" in attrs)
self.assertEqual(raw.__doc__, "I'm the x property.")
- self.assert_(raw.fget is C.__dict__['getx'])
- self.assert_(raw.fset is C.__dict__['setx'])
- self.assert_(raw.fdel is C.__dict__['delx'])
+ self.assertTrue(raw.fget is C.__dict__['getx'])
+ self.assertTrue(raw.fset is C.__dict__['setx'])
+ self.assertTrue(raw.fdel is C.__dict__['delx'])
for attr in "__doc__", "fget", "fset", "fdel":
try:
@@ -1863,7 +1863,7 @@
self.assertEqual(C.foo.__doc__, "hello")
self.assertFalse(hasattr(c, "foo"))
c.foo = -42
- self.assert_(hasattr(c, '_foo'))
+ self.assertTrue(hasattr(c, '_foo'))
self.assertEqual(c._foo, 42)
self.assertEqual(c.foo, 42)
del c.foo
@@ -2021,12 +2021,12 @@
c = C()
self.assertEqual(interesting(dir(c)), cstuff)
- ## self.assert_('__self__' in dir(C.Cmethod))
+ ## self.assertTrue('__self__' in dir(C.Cmethod))
c.cdata = 2
c.cmethod = lambda self: 0
self.assertEqual(interesting(dir(c)), cstuff + ['cdata', 'cmethod'])
- ## self.assert_('__self__' in dir(c.Cmethod))
+ ## self.assertTrue('__self__' in dir(c.Cmethod))
class A(C):
Adata = 1
@@ -2034,13 +2034,13 @@
astuff = ['Adata', 'Amethod'] + cstuff
self.assertEqual(interesting(dir(A)), astuff)
- ## self.assert_('__self__' in dir(A.Amethod))
+ ## self.assertTrue('__self__' in dir(A.Amethod))
a = A()
self.assertEqual(interesting(dir(a)), astuff)
a.adata = 42
a.amethod = lambda self: 3
self.assertEqual(interesting(dir(a)), astuff + ['adata', 'amethod'])
- ## self.assert_('__self__' in dir(a.Amethod))
+ ## self.assertTrue('__self__' in dir(a.Amethod))
# Try a module subclass.
import sys
@@ -2224,13 +2224,13 @@
a = hexint(12345)
self.assertEqual(a, 12345)
self.assertEqual(int(a), 12345)
- self.assert_(int(a).__class__ is int)
+ self.assertTrue(int(a).__class__ is int)
self.assertEqual(hash(a), hash(12345))
- self.assert_((+a).__class__ is int)
- self.assert_((a >> 0).__class__ is int)
- self.assert_((a << 0).__class__ is int)
- self.assert_((hexint(0) << 12).__class__ is int)
- self.assert_((hexint(0) >> 12).__class__ is int)
+ self.assertTrue((+a).__class__ is int)
+ self.assertTrue((a >> 0).__class__ is int)
+ self.assertTrue((a << 0).__class__ is int)
+ self.assertTrue((hexint(0) << 12).__class__ is int)
+ self.assertTrue((hexint(0) >> 12).__class__ is int)
class octlong(int):
__slots__ = []
@@ -2250,36 +2250,36 @@
self.assertEqual(a, 12345)
self.assertEqual(int(a), 12345)
self.assertEqual(hash(a), hash(12345))
- self.assert_(int(a).__class__ is int)
- self.assert_((+a).__class__ is int)
- self.assert_((-a).__class__ is int)
- self.assert_((-octlong(0)).__class__ is int)
- self.assert_((a >> 0).__class__ is int)
- self.assert_((a << 0).__class__ is int)
- self.assert_((a - 0).__class__ is int)
- self.assert_((a * 1).__class__ is int)
- self.assert_((a ** 1).__class__ is int)
- self.assert_((a // 1).__class__ is int)
- self.assert_((1 * a).__class__ is int)
- self.assert_((a | 0).__class__ is int)
- self.assert_((a ^ 0).__class__ is int)
- self.assert_((a & -1).__class__ is int)
- self.assert_((octlong(0) << 12).__class__ is int)
- self.assert_((octlong(0) >> 12).__class__ is int)
- self.assert_(abs(octlong(0)).__class__ is int)
+ self.assertTrue(int(a).__class__ is int)
+ self.assertTrue((+a).__class__ is int)
+ self.assertTrue((-a).__class__ is int)
+ self.assertTrue((-octlong(0)).__class__ is int)
+ self.assertTrue((a >> 0).__class__ is int)
+ self.assertTrue((a << 0).__class__ is int)
+ self.assertTrue((a - 0).__class__ is int)
+ self.assertTrue((a * 1).__class__ is int)
+ self.assertTrue((a ** 1).__class__ is int)
+ self.assertTrue((a // 1).__class__ is int)
+ self.assertTrue((1 * a).__class__ is int)
+ self.assertTrue((a | 0).__class__ is int)
+ self.assertTrue((a ^ 0).__class__ is int)
+ self.assertTrue((a & -1).__class__ is int)
+ self.assertTrue((octlong(0) << 12).__class__ is int)
+ self.assertTrue((octlong(0) >> 12).__class__ is int)
+ self.assertTrue(abs(octlong(0)).__class__ is int)
# Because octlong overrides __add__, we can't check the absence of +0
# optimizations using octlong.
class longclone(int):
pass
a = longclone(1)
- self.assert_((a + 0).__class__ is int)
- self.assert_((0 + a).__class__ is int)
+ self.assertTrue((a + 0).__class__ is int)
+ self.assertTrue((0 + a).__class__ is int)
# Check that negative clones don't segfault
a = longclone(-1)
self.assertEqual(a.__dict__, {})
- self.assertEqual(int(a), -1) # self.assert_ PyNumber_Long() copies the sign bit
+ self.assertEqual(int(a), -1) # self.assertTrue PyNumber_Long() copies the sign bit
class precfloat(float):
__slots__ = ['prec']
@@ -2291,9 +2291,9 @@
a = precfloat(12345)
self.assertEqual(a, 12345.0)
self.assertEqual(float(a), 12345.0)
- self.assert_(float(a).__class__ is float)
+ self.assertTrue(float(a).__class__ is float)
self.assertEqual(hash(a), hash(12345.0))
- self.assert_((+a).__class__ is float)
+ self.assertTrue((+a).__class__ is float)
class madcomplex(complex):
def __repr__(self):
@@ -2341,20 +2341,20 @@
self.assertEqual(v, t)
a = madtuple((1,2,3,4,5))
self.assertEqual(tuple(a), (1,2,3,4,5))
- self.assert_(tuple(a).__class__ is tuple)
+ self.assertTrue(tuple(a).__class__ is tuple)
self.assertEqual(hash(a), hash((1,2,3,4,5)))
- self.assert_(a[:].__class__ is tuple)
- self.assert_((a * 1).__class__ is tuple)
- self.assert_((a * 0).__class__ is tuple)
- self.assert_((a + ()).__class__ is tuple)
+ self.assertTrue(a[:].__class__ is tuple)
+ self.assertTrue((a * 1).__class__ is tuple)
+ self.assertTrue((a * 0).__class__ is tuple)
+ self.assertTrue((a + ()).__class__ is tuple)
a = madtuple(())
self.assertEqual(tuple(a), ())
- self.assert_(tuple(a).__class__ is tuple)
- self.assert_((a + a).__class__ is tuple)
- self.assert_((a * 0).__class__ is tuple)
- self.assert_((a * 1).__class__ is tuple)
- self.assert_((a * 2).__class__ is tuple)
- self.assert_(a[:].__class__ is tuple)
+ self.assertTrue(tuple(a).__class__ is tuple)
+ self.assertTrue((a + a).__class__ is tuple)
+ self.assertTrue((a * 0).__class__ is tuple)
+ self.assertTrue((a * 1).__class__ is tuple)
+ self.assertTrue((a * 2).__class__ is tuple)
+ self.assertTrue(a[:].__class__ is tuple)
class madstring(str):
_rev = None
@@ -2376,48 +2376,48 @@
self.assertEqual(u, s)
s = madstring("12345")
self.assertEqual(str(s), "12345")
- self.assert_(str(s).__class__ is str)
+ self.assertTrue(str(s).__class__ is str)
base = "\x00" * 5
s = madstring(base)
self.assertEqual(s, base)
self.assertEqual(str(s), base)
- self.assert_(str(s).__class__ is str)
+ self.assertTrue(str(s).__class__ is str)
self.assertEqual(hash(s), hash(base))
self.assertEqual({s: 1}[base], 1)
self.assertEqual({base: 1}[s], 1)
- self.assert_((s + "").__class__ is str)
+ self.assertTrue((s + "").__class__ is str)
self.assertEqual(s + "", base)
- self.assert_(("" + s).__class__ is str)
+ self.assertTrue(("" + s).__class__ is str)
self.assertEqual("" + s, base)
- self.assert_((s * 0).__class__ is str)
+ self.assertTrue((s * 0).__class__ is str)
self.assertEqual(s * 0, "")
- self.assert_((s * 1).__class__ is str)
+ self.assertTrue((s * 1).__class__ is str)
self.assertEqual(s * 1, base)
- self.assert_((s * 2).__class__ is str)
+ self.assertTrue((s * 2).__class__ is str)
self.assertEqual(s * 2, base + base)
- self.assert_(s[:].__class__ is str)
+ self.assertTrue(s[:].__class__ is str)
self.assertEqual(s[:], base)
- self.assert_(s[0:0].__class__ is str)
+ self.assertTrue(s[0:0].__class__ is str)
self.assertEqual(s[0:0], "")
- self.assert_(s.strip().__class__ is str)
+ self.assertTrue(s.strip().__class__ is str)
self.assertEqual(s.strip(), base)
- self.assert_(s.lstrip().__class__ is str)
+ self.assertTrue(s.lstrip().__class__ is str)
self.assertEqual(s.lstrip(), base)
- self.assert_(s.rstrip().__class__ is str)
+ self.assertTrue(s.rstrip().__class__ is str)
self.assertEqual(s.rstrip(), base)
identitytab = {}
- self.assert_(s.translate(identitytab).__class__ is str)
+ self.assertTrue(s.translate(identitytab).__class__ is str)
self.assertEqual(s.translate(identitytab), base)
- self.assert_(s.replace("x", "x").__class__ is str)
+ self.assertTrue(s.replace("x", "x").__class__ is str)
self.assertEqual(s.replace("x", "x"), base)
- self.assert_(s.ljust(len(s)).__class__ is str)
+ self.assertTrue(s.ljust(len(s)).__class__ is str)
self.assertEqual(s.ljust(len(s)), base)
- self.assert_(s.rjust(len(s)).__class__ is str)
+ self.assertTrue(s.rjust(len(s)).__class__ is str)
self.assertEqual(s.rjust(len(s)), base)
- self.assert_(s.center(len(s)).__class__ is str)
+ self.assertTrue(s.center(len(s)).__class__ is str)
self.assertEqual(s.center(len(s)), base)
- self.assert_(s.lower().__class__ is str)
+ self.assertTrue(s.lower().__class__ is str)
self.assertEqual(s.lower(), base)
class madunicode(str):
@@ -2436,47 +2436,47 @@
base = "12345"
u = madunicode(base)
self.assertEqual(str(u), base)
- self.assert_(str(u).__class__ is str)
+ self.assertTrue(str(u).__class__ is str)
self.assertEqual(hash(u), hash(base))
self.assertEqual({u: 1}[base], 1)
self.assertEqual({base: 1}[u], 1)
- self.assert_(u.strip().__class__ is str)
+ self.assertTrue(u.strip().__class__ is str)
self.assertEqual(u.strip(), base)
- self.assert_(u.lstrip().__class__ is str)
+ self.assertTrue(u.lstrip().__class__ is str)
self.assertEqual(u.lstrip(), base)
- self.assert_(u.rstrip().__class__ is str)
+ self.assertTrue(u.rstrip().__class__ is str)
self.assertEqual(u.rstrip(), base)
- self.assert_(u.replace("x", "x").__class__ is str)
+ self.assertTrue(u.replace("x", "x").__class__ is str)
self.assertEqual(u.replace("x", "x"), base)
- self.assert_(u.replace("xy", "xy").__class__ is str)
+ self.assertTrue(u.replace("xy", "xy").__class__ is str)
self.assertEqual(u.replace("xy", "xy"), base)
- self.assert_(u.center(len(u)).__class__ is str)
+ self.assertTrue(u.center(len(u)).__class__ is str)
self.assertEqual(u.center(len(u)), base)
- self.assert_(u.ljust(len(u)).__class__ is str)
+ self.assertTrue(u.ljust(len(u)).__class__ is str)
self.assertEqual(u.ljust(len(u)), base)
- self.assert_(u.rjust(len(u)).__class__ is str)
+ self.assertTrue(u.rjust(len(u)).__class__ is str)
self.assertEqual(u.rjust(len(u)), base)
- self.assert_(u.lower().__class__ is str)
+ self.assertTrue(u.lower().__class__ is str)
self.assertEqual(u.lower(), base)
- self.assert_(u.upper().__class__ is str)
+ self.assertTrue(u.upper().__class__ is str)
self.assertEqual(u.upper(), base)
- self.assert_(u.capitalize().__class__ is str)
+ self.assertTrue(u.capitalize().__class__ is str)
self.assertEqual(u.capitalize(), base)
- self.assert_(u.title().__class__ is str)
+ self.assertTrue(u.title().__class__ is str)
self.assertEqual(u.title(), base)
- self.assert_((u + "").__class__ is str)
+ self.assertTrue((u + "").__class__ is str)
self.assertEqual(u + "", base)
- self.assert_(("" + u).__class__ is str)
+ self.assertTrue(("" + u).__class__ is str)
self.assertEqual("" + u, base)
- self.assert_((u * 0).__class__ is str)
+ self.assertTrue((u * 0).__class__ is str)
self.assertEqual(u * 0, "")
- self.assert_((u * 1).__class__ is str)
+ self.assertTrue((u * 1).__class__ is str)
self.assertEqual(u * 1, base)
- self.assert_((u * 2).__class__ is str)
+ self.assertTrue((u * 2).__class__ is str)
self.assertEqual(u * 2, base + base)
- self.assert_(u[:].__class__ is str)
+ self.assertTrue(u[:].__class__ is str)
self.assertEqual(u[:], base)
- self.assert_(u[0:0].__class__ is str)
+ self.assertTrue(u[0:0].__class__ is str)
self.assertEqual(u[0:0], "")
class sublist(list):
@@ -2595,7 +2595,7 @@
self.assertEqual(d[cistr('one')], 1)
self.assertEqual(d[cistr('tWo')], 2)
self.assertEqual(d[cistr('THrEE')], 3)
- self.assert_(cistr('ONe') in d)
+ self.assertTrue(cistr('ONe') in d)
self.assertEqual(d.get(cistr('thrEE')), 3)
def test_classic_comparisons(self):
@@ -2652,13 +2652,13 @@
for x in 1, 2, 3:
for y in 1, 2, 3:
for op in "<", "<=", "==", "!=", ">", ">=":
- self.assert_(eval("c[x] %s c[y]" % op) ==
+ self.assertTrue(eval("c[x] %s c[y]" % op) ==
eval("x %s y" % op),
"x=%d, y=%d" % (x, y))
- self.assert_(eval("c[x] %s y" % op) ==
+ self.assertTrue(eval("c[x] %s y" % op) ==
eval("x %s y" % op),
"x=%d, y=%d" % (x, y))
- self.assert_(eval("x %s c[y]" % op) ==
+ self.assertTrue(eval("x %s c[y]" % op) ==
eval("x %s y" % op),
"x=%d, y=%d" % (x, y))
@@ -2731,11 +2731,11 @@
for x in 1, 2, 3:
for y in 1, 2, 3:
for op in "<", "<=", "==", "!=", ">", ">=":
- self.assert_(eval("c[x] %s c[y]" % op) == eval("x %s y" % op),
+ self.assertTrue(eval("c[x] %s c[y]" % op) == eval("x %s y" % op),
"x=%d, y=%d" % (x, y))
- self.assert_(eval("c[x] %s y" % op) == eval("x %s y" % op),
+ self.assertTrue(eval("c[x] %s y" % op) == eval("x %s y" % op),
"x=%d, y=%d" % (x, y))
- self.assert_(eval("x %s c[y]" % op) == eval("x %s y" % op),
+ self.assertTrue(eval("x %s c[y]" % op) == eval("x %s y" % op),
"x=%d, y=%d" % (x, y))
def test_descrdoc(self):
@@ -2775,9 +2775,9 @@
for cls2 in C, D, E, F:
x = cls()
x.__class__ = cls2
- self.assert_(x.__class__ is cls2)
+ self.assertTrue(x.__class__ is cls2)
x.__class__ = cls
- self.assert_(x.__class__ is cls)
+ self.assertTrue(x.__class__ is cls)
def cant(x, C):
try:
x.__class__ = C
@@ -2833,11 +2833,11 @@
x = cls()
x.a = 1
x.__class__ = cls2
- self.assert_(x.__class__ is cls2,
+ self.assertTrue(x.__class__ is cls2,
"assigning %r as __class__ for %r silently failed" % (cls2, x))
self.assertEqual(x.a, 1)
x.__class__ = cls
- self.assert_(x.__class__ is cls,
+ self.assertTrue(x.__class__ is cls,
"assigning %r as __class__ for %r silently failed" % (cls, x))
self.assertEqual(x.a, 1)
for cls in G, J, K, L, M, N, P, R, list, Int:
@@ -3006,7 +3006,7 @@
for cls in C, C1, C2:
s = pickle.dumps(cls, bin)
cls2 = pickle.loads(s)
- self.assert_(cls2 is cls)
+ self.assertTrue(cls2 is cls)
a = C1(1, 2); a.append(42); a.append(24)
b = C2("hello", "world", 42)
@@ -3036,7 +3036,7 @@
import copy
for cls in C, C1, C2:
cls2 = copy.deepcopy(cls)
- self.assert_(cls2 is cls)
+ self.assertTrue(cls2 is cls)
a = C1(1, 2); a.append(42); a.append(24)
b = C2("hello", "world", 42)
@@ -3579,8 +3579,8 @@
__slots__=()
if support.check_impl_detail():
self.assertEqual(C.__basicsize__, B.__basicsize__)
- self.assert_(hasattr(C, '__dict__'))
- self.assert_(hasattr(C, '__weakref__'))
+ self.assertTrue(hasattr(C, '__dict__'))
+ self.assertTrue(hasattr(C, '__weakref__'))
C().x = 2
def test_rmul(self):
@@ -3914,29 +3914,29 @@
pass
a = C()
pa = Proxy(a)
- self.assert_(isinstance(a, C)) # Baseline
- self.assert_(isinstance(pa, C)) # Test
+ self.assertTrue(isinstance(a, C)) # Baseline
+ self.assertTrue(isinstance(pa, C)) # Test
# Test with a classic subclass
class D(C):
pass
a = D()
pa = Proxy(a)
- self.assert_(isinstance(a, C)) # Baseline
- self.assert_(isinstance(pa, C)) # Test
+ self.assertTrue(isinstance(a, C)) # Baseline
+ self.assertTrue(isinstance(pa, C)) # Test
# Test with a new-style class
class C(object):
pass
a = C()
pa = Proxy(a)
- self.assert_(isinstance(a, C)) # Baseline
- self.assert_(isinstance(pa, C)) # Test
+ self.assertTrue(isinstance(a, C)) # Baseline
+ self.assertTrue(isinstance(pa, C)) # Test
# Test with a new-style subclass
class D(C):
pass
a = D()
pa = Proxy(a)
- self.assert_(isinstance(a, C)) # Baseline
- self.assert_(isinstance(pa, C)) # Test
+ self.assertTrue(isinstance(a, C)) # Baseline
+ self.assertTrue(isinstance(pa, C)) # Test
def test_proxy_super(self):
# Testing super() for a proxy object...
@@ -4065,17 +4065,17 @@
l = []
self.assertEqual(l.__add__, l.__add__)
self.assertEqual(l.__add__, [].__add__)
- self.assert_(l.__add__ != [5].__add__)
- self.assert_(l.__add__ != l.__mul__)
- self.assert_(l.__add__.__name__ == '__add__')
+ self.assertTrue(l.__add__ != [5].__add__)
+ self.assertTrue(l.__add__ != l.__mul__)
+ self.assertTrue(l.__add__.__name__ == '__add__')
if hasattr(l.__add__, '__self__'):
# CPython
- self.assert_(l.__add__.__self__ is l)
- self.assert_(l.__add__.__objclass__ is list)
+ self.assertTrue(l.__add__.__self__ is l)
+ self.assertTrue(l.__add__.__objclass__ is list)
else:
# Python implementations where [].__add__ is a normal bound method
- self.assert_(l.__add__.im_self is l)
- self.assert_(l.__add__.im_class is list)
+ self.assertTrue(l.__add__.im_self is l)
+ self.assertTrue(l.__add__.im_class is list)
self.assertEqual(l.__add__.__doc__, list.__add__.__doc__)
try:
hash(l.__add__)
Modified: python/branches/py3k/Lib/test/test_dict.py
==============================================================================
--- python/branches/py3k/Lib/test/test_dict.py (original)
+++ python/branches/py3k/Lib/test/test_dict.py Wed Jul 1 01:06:06 2009
@@ -10,7 +10,7 @@
def test_constructor(self):
# calling built-in types without argument must return empty
self.assertEqual(dict(), {})
- self.assert_(dict() is not {})
+ self.assertTrue(dict() is not {})
def test_literal_constructor(self):
# check literal constructor for different sized dicts (to exercise the BUILD_MAP oparg
@@ -24,18 +24,18 @@
self.assertEqual(eval(dictliteral), dict(items))
def test_bool(self):
- self.assert_(not {})
- self.assert_({1: 2})
- self.assert_(bool({}) is False)
- self.assert_(bool({1: 2}) is True)
+ self.assertTrue(not {})
+ self.assertTrue({1: 2})
+ self.assertTrue(bool({}) is False)
+ self.assertTrue(bool({1: 2}) is True)
def test_keys(self):
d = {}
self.assertEqual(set(d.keys()), set())
d = {'a': 1, 'b': 2}
k = d.keys()
- self.assert_('a' in d)
- self.assert_('b' in d)
+ self.assertTrue('a' in d)
+ self.assertTrue('b' in d)
self.assertRaises(TypeError, d.keys, None)
self.assertEqual(repr(dict(a=1).keys()), "dict_keys(['a'])")
@@ -58,12 +58,12 @@
def test_contains(self):
d = {}
- self.assert_(not ('a' in d))
- self.assert_('a' not in d)
+ self.assertTrue(not ('a' in d))
+ self.assertTrue('a' not in d)
d = {'a': 1, 'b': 2}
- self.assert_('a' in d)
- self.assert_('b' in d)
- self.assert_('c' not in d)
+ self.assertTrue('a' in d)
+ self.assertTrue('b' in d)
+ self.assertTrue('c' not in d)
self.assertRaises(TypeError, d.__contains__)
@@ -197,7 +197,7 @@
def test_fromkeys(self):
self.assertEqual(dict.fromkeys('abc'), {'a':None, 'b':None, 'c':None})
d = {}
- self.assert_(not(d.fromkeys('abc') is d))
+ self.assertTrue(not(d.fromkeys('abc') is d))
self.assertEqual(d.fromkeys('abc'), {'a':None, 'b':None, 'c':None})
self.assertEqual(d.fromkeys((4,5),0), {4:0, 5:0})
self.assertEqual(d.fromkeys([]), {})
@@ -208,14 +208,14 @@
class dictlike(dict): pass
self.assertEqual(dictlike.fromkeys('a'), {'a':None})
self.assertEqual(dictlike().fromkeys('a'), {'a':None})
- self.assert_(type(dictlike.fromkeys('a')) is dictlike)
- self.assert_(type(dictlike().fromkeys('a')) is dictlike)
+ self.assertTrue(type(dictlike.fromkeys('a')) is dictlike)
+ self.assertTrue(type(dictlike().fromkeys('a')) is dictlike)
class mydict(dict):
def __new__(cls):
return collections.UserDict()
ud = mydict.fromkeys('ab')
self.assertEqual(ud, {'a':None, 'b':None})
- self.assert_(isinstance(ud, collections.UserDict))
+ self.assertTrue(isinstance(ud, collections.UserDict))
self.assertRaises(TypeError, dict.fromkeys)
class Exc(Exception): pass
@@ -252,10 +252,10 @@
def test_get(self):
d = {}
- self.assert_(d.get('c') is None)
+ self.assertTrue(d.get('c') is None)
self.assertEqual(d.get('c', 3), 3)
d = {'a' : 1, 'b' : 2}
- self.assert_(d.get('c') is None)
+ self.assertTrue(d.get('c') is None)
self.assertEqual(d.get('c', 3), 3)
self.assertEqual(d.get('a'), 1)
self.assertEqual(d.get('a', 3), 1)
@@ -265,9 +265,9 @@
def test_setdefault(self):
# dict.setdefault()
d = {}
- self.assert_(d.setdefault('key0') is None)
+ self.assertTrue(d.setdefault('key0') is None)
d.setdefault('key0', [])
- self.assert_(d.setdefault('key0') is None)
+ self.assertTrue(d.setdefault('key0') is None)
d.setdefault('key', []).append(3)
self.assertEqual(d['key'][0], 3)
d.setdefault('key', []).append(4)
@@ -309,9 +309,9 @@
self.assertEqual(va, int(ka))
kb, vb = tb = b.popitem()
self.assertEqual(vb, int(kb))
- self.assert_(not(copymode < 0 and ta != tb))
- self.assert_(not a)
- self.assert_(not b)
+ self.assertTrue(not(copymode < 0 and ta != tb))
+ self.assertTrue(not a)
+ self.assertTrue(not b)
d = {}
self.assertRaises(KeyError, d.popitem)
@@ -525,8 +525,8 @@
d = D({1: 2, 3: 4})
self.assertEqual(d[1], 2)
self.assertEqual(d[3], 4)
- self.assert_(2 not in d)
- self.assert_(2 not in d.keys())
+ self.assertTrue(2 not in d)
+ self.assertTrue(2 not in d.keys())
self.assertEqual(d[2], 42)
class E(dict):
def __missing__(self, key):
@@ -663,7 +663,7 @@
obj.x = iter(obj.v)
del obj, container
gc.collect()
- self.assert_(ref() is None, "Cycle was not collected")
+ self.assertTrue(ref() is None, "Cycle was not collected")
def _not_tracked(self, t):
# Nested containers can take several collections to untrack
Modified: python/branches/py3k/Lib/test/test_dictviews.py
==============================================================================
--- python/branches/py3k/Lib/test/test_dictviews.py (original)
+++ python/branches/py3k/Lib/test/test_dictviews.py Wed Jul 1 01:06:06 2009
@@ -24,10 +24,10 @@
self.assertNotEqual(keys, {1, "b"})
self.assertNotEqual(keys, {1})
self.assertNotEqual(keys, 42)
- self.assert_(1 in keys)
- self.assert_("a" in keys)
- self.assert_(10 not in keys)
- self.assert_("Z" not in keys)
+ self.assertTrue(1 in keys)
+ self.assertTrue("a" in keys)
+ self.assertTrue(10 not in keys)
+ self.assertTrue("Z" not in keys)
self.assertEqual(d.keys(), d.keys())
e = {1: 11, "a": "def"}
self.assertEqual(d.keys(), e.keys())
@@ -44,13 +44,13 @@
self.assertNotEqual(items, {(1, 10), ("a", "def")})
self.assertNotEqual(items, {(1, 10)})
self.assertNotEqual(items, 42)
- self.assert_((1, 10) in items)
- self.assert_(("a", "ABC") in items)
- self.assert_((1, 11) not in items)
- self.assert_(1 not in items)
- self.assert_(() not in items)
- self.assert_((1,) not in items)
- self.assert_((1, 2, 3) not in items)
+ self.assertTrue((1, 10) in items)
+ self.assertTrue(("a", "ABC") in items)
+ self.assertTrue((1, 11) not in items)
+ self.assertTrue(1 not in items)
+ self.assertTrue(() not in items)
+ self.assertTrue((1,) not in items)
+ self.assertTrue((1, 2, 3) not in items)
self.assertEqual(d.items(), d.items())
e = d.copy()
self.assertEqual(d.items(), e.items())
Modified: python/branches/py3k/Lib/test/test_docxmlrpc.py
==============================================================================
--- python/branches/py3k/Lib/test/test_docxmlrpc.py (original)
+++ python/branches/py3k/Lib/test/test_docxmlrpc.py Wed Jul 1 01:06:06 2009
@@ -104,7 +104,7 @@
self.client.request("GET", "/")
response = self.client.getresponse()
- self.assert_(
+ self.assertTrue(
b"""<dl><dt><a name="-<lambda>"><strong><lambda></strong></a>(x, y)</dt></dl>"""
in response.read())
@@ -118,7 +118,7 @@
self.client.request("GET", "/")
response = self.client.getresponse().read()
- self.assert_( # This is ugly ... how can it be made better?
+ self.assertTrue( # This is ugly ... how can it be made better?
b"""<dl><dt><a name="-add"><strong>add</strong></a>(x, y)</dt><dd><tt>Add two instances together. This follows <a href="http://www.python.org/dev/peps/pep-0008/">PEP008</a>, but has nothing<br>\nto do with <a href="http://www.rfc-editor.org/rfc/rfc1952.txt">RFC1952</a>. Case should matter: pEp008 and rFC1952. Things<br>\nthat start with http and ftp should be auto-linked, too:<br>\n<a href="http://google.com">http://google.com</a>.</tt></dd></dl>"""
in response, response)
@@ -131,7 +131,7 @@
self.client.request("GET", "/")
response = self.client.getresponse().read()
- self.assert_(
+ self.assertTrue(
b"""<dl><dt><a name="-system.methodHelp"><strong>system.methodHelp</strong></a>(method_name)</dt><dd><tt><a href="#-system.methodHelp">system.methodHelp</a>(\'add\') => "Adds two integers together"<br>\n <br>\nReturns a string containing documentation for the specified method.</tt></dd></dl>\n<dl><dt><a name="-system.methodSignature"><strong>system.methodSignature</strong></a>(method_name)</dt><dd><tt><a href="#-system.methodSignature">system.methodSignature</a>(\'add\') => [double, int, int]<br>\n <br>\nReturns a list describing the signature of the method. In the<br>\nabove example, the add method takes two integers as arguments<br>\nand returns a double result.<br>\n <br>\nThis server does NOT support system.methodSignature.</tt></dd></dl>\n<dl><dt><a name="-test_method"><strong>test_method</strong></a>(arg)</dt><dd><tt>Test method\'s docs. This method truly does very little.</tt></dd></dl>""" in response)
def test_autolink_dotted_methods(self):
@@ -140,7 +140,7 @@
self.client.request("GET", "/")
response = self.client.getresponse()
- self.assert_(b"""Try self.<strong>add</strong>, too.""" in
+ self.assertTrue(b"""Try self.<strong>add</strong>, too.""" in
response.read())
def test_main():
Modified: python/branches/py3k/Lib/test/test_dummy_thread.py
==============================================================================
--- python/branches/py3k/Lib/test/test_dummy_thread.py (original)
+++ python/branches/py3k/Lib/test/test_dummy_thread.py Wed Jul 1 01:06:06 2009
@@ -24,43 +24,43 @@
def test_initlock(self):
#Make sure locks start locked
- self.failUnless(not self.lock.locked(),
+ self.assertTrue(not self.lock.locked(),
"Lock object is not initialized unlocked.")
def test_release(self):
# Test self.lock.release()
self.lock.acquire()
self.lock.release()
- self.failUnless(not self.lock.locked(),
+ self.assertTrue(not self.lock.locked(),
"Lock object did not release properly.")
def test_improper_release(self):
#Make sure release of an unlocked thread raises _thread.error
- self.failUnlessRaises(_thread.error, self.lock.release)
+ self.assertRaises(_thread.error, self.lock.release)
def test_cond_acquire_success(self):
#Make sure the conditional acquiring of the lock works.
- self.failUnless(self.lock.acquire(0),
+ self.assertTrue(self.lock.acquire(0),
"Conditional acquiring of the lock failed.")
def test_cond_acquire_fail(self):
#Test acquiring locked lock returns False
self.lock.acquire(0)
- self.failUnless(not self.lock.acquire(0),
+ self.assertTrue(not self.lock.acquire(0),
"Conditional acquiring of a locked lock incorrectly "
"succeeded.")
def test_uncond_acquire_success(self):
#Make sure unconditional acquiring of a lock works.
self.lock.acquire()
- self.failUnless(self.lock.locked(),
+ self.assertTrue(self.lock.locked(),
"Uncondional locking failed.")
def test_uncond_acquire_return_val(self):
#Make sure that an unconditional locking returns True.
- self.failUnless(self.lock.acquire(1) is True,
+ self.assertTrue(self.lock.acquire(1) is True,
"Unconditional locking did not return True.")
- self.failUnless(self.lock.acquire() is True)
+ self.assertTrue(self.lock.acquire() is True)
def test_uncond_acquire_blocking(self):
#Make sure that unconditional acquiring of a locked lock blocks.
@@ -80,7 +80,7 @@
end_time = int(time.time())
if support.verbose:
print("done")
- self.failUnless((end_time - start_time) >= DELAY,
+ self.assertTrue((end_time - start_time) >= DELAY,
"Blocking by unconditional acquiring failed.")
class MiscTests(unittest.TestCase):
@@ -88,18 +88,18 @@
def test_exit(self):
#Make sure _thread.exit() raises SystemExit
- self.failUnlessRaises(SystemExit, _thread.exit)
+ self.assertRaises(SystemExit, _thread.exit)
def test_ident(self):
#Test sanity of _thread.get_ident()
- self.failUnless(isinstance(_thread.get_ident(), int),
+ self.assertTrue(isinstance(_thread.get_ident(), int),
"_thread.get_ident() returned a non-integer")
- self.failUnless(_thread.get_ident() != 0,
+ self.assertTrue(_thread.get_ident() != 0,
"_thread.get_ident() returned 0")
def test_LockType(self):
#Make sure _thread.LockType is the same type as _thread.allocate_locke()
- self.failUnless(isinstance(_thread.allocate_lock(), _thread.LockType),
+ self.assertTrue(isinstance(_thread.allocate_lock(), _thread.LockType),
"_thread.LockType is not an instance of what is "
"returned by _thread.allocate_lock()")
@@ -108,13 +108,13 @@
# should raise KeyboardInterrupt upon completion.
def call_interrupt():
_thread.interrupt_main()
- self.failUnlessRaises(KeyboardInterrupt, _thread.start_new_thread,
+ self.assertRaises(KeyboardInterrupt, _thread.start_new_thread,
call_interrupt, tuple())
def test_interrupt_in_main(self):
# Make sure that if interrupt_main is called in main threat that
# KeyboardInterrupt is raised instantly.
- self.failUnlessRaises(KeyboardInterrupt, _thread.interrupt_main)
+ self.assertRaises(KeyboardInterrupt, _thread.interrupt_main)
class ThreadTests(unittest.TestCase):
"""Test thread creation."""
@@ -128,16 +128,16 @@
testing_queue = queue.Queue(1)
_thread.start_new_thread(arg_tester, (testing_queue, True, True))
result = testing_queue.get()
- self.failUnless(result[0] and result[1],
+ self.assertTrue(result[0] and result[1],
"Argument passing for thread creation using tuple failed")
_thread.start_new_thread(arg_tester, tuple(), {'queue':testing_queue,
'arg1':True, 'arg2':True})
result = testing_queue.get()
- self.failUnless(result[0] and result[1],
+ self.assertTrue(result[0] and result[1],
"Argument passing for thread creation using kwargs failed")
_thread.start_new_thread(arg_tester, (testing_queue, True), {'arg2':True})
result = testing_queue.get()
- self.failUnless(result[0] and result[1],
+ self.assertTrue(result[0] and result[1],
"Argument passing for thread creation using both tuple"
" and kwargs failed")
@@ -164,7 +164,7 @@
time.sleep(DELAY)
if support.verbose:
print('done')
- self.failUnless(testing_queue.qsize() == thread_count,
+ self.assertTrue(testing_queue.qsize() == thread_count,
"Not all %s threads executed properly after %s sec." %
(thread_count, DELAY))
Modified: python/branches/py3k/Lib/test/test_epoll.py
==============================================================================
--- python/branches/py3k/Lib/test/test_epoll.py (original)
+++ python/branches/py3k/Lib/test/test_epoll.py Wed Jul 1 01:06:06 2009
@@ -71,10 +71,10 @@
ep = select.epoll(16)
except OSError as e:
raise AssertionError(str(e))
- self.assert_(ep.fileno() > 0, ep.fileno())
- self.assert_(not ep.closed)
+ self.assertTrue(ep.fileno() > 0, ep.fileno())
+ self.assertTrue(not ep.closed)
ep.close()
- self.assert_(ep.closed)
+ self.assertTrue(ep.closed)
self.assertRaises(ValueError, ep.fileno)
def test_badcreate(self):
@@ -141,7 +141,7 @@
try:
ep2.poll(1, 4)
except IOError as e:
- self.failUnlessEqual(e.args[0], errno.EBADF, e)
+ self.assertEqual(e.args[0], errno.EBADF, e)
else:
self.fail("epoll on closed fd didn't raise EBADF")
@@ -157,7 +157,7 @@
now = time.time()
events = ep.poll(1, 4)
then = time.time()
- self.failIf(then - now > 0.1, then - now)
+ self.assertFalse(then - now > 0.1, then - now)
events.sort()
expected = [(client.fileno(), select.EPOLLOUT),
@@ -165,12 +165,12 @@
expected.sort()
self.assertEquals(events, expected)
- self.failIf(then - now > 0.01, then - now)
+ self.assertFalse(then - now > 0.01, then - now)
now = time.time()
events = ep.poll(timeout=2.1, maxevents=4)
then = time.time()
- self.failIf(events)
+ self.assertFalse(events)
client.send(b"Hello!")
server.send(b"world!!!")
@@ -178,7 +178,7 @@
now = time.time()
events = ep.poll(1, 4)
then = time.time()
- self.failIf(then - now > 0.01)
+ self.assertFalse(then - now > 0.01)
events.sort()
expected = [(client.fileno(), select.EPOLLIN | select.EPOLLOUT),
@@ -192,7 +192,7 @@
now = time.time()
events = ep.poll(1, 4)
then = time.time()
- self.failIf(then - now > 0.01)
+ self.assertFalse(then - now > 0.01)
expected = [(server.fileno(), select.EPOLLOUT)]
self.assertEquals(events, expected)
@@ -211,7 +211,7 @@
now = time.time()
events = ep.poll(1, 4)
then = time.time()
- self.failIf(then - now > 0.01)
+ self.assertFalse(then - now > 0.01)
server.close()
ep.unregister(fd)
Modified: python/branches/py3k/Lib/test/test_errno.py
==============================================================================
--- python/branches/py3k/Lib/test/test_errno.py (original)
+++ python/branches/py3k/Lib/test/test_errno.py Wed Jul 1 01:06:06 2009
@@ -14,13 +14,13 @@
def test_for_improper_attributes(self):
# No unexpected attributes should be on the module.
for error_code in std_c_errors:
- self.assert_(hasattr(errno, error_code),
+ self.assertTrue(hasattr(errno, error_code),
"errno is missing %s" % error_code)
def test_using_errorcode(self):
# Every key value in errno.errorcode should be on the module.
for value in errno.errorcode.values():
- self.assert_(hasattr(errno, value), 'no %s attr in errno' % value)
+ self.assertTrue(hasattr(errno, value), 'no %s attr in errno' % value)
class ErrorcodeTests(unittest.TestCase):
@@ -28,7 +28,7 @@
def test_attributes_in_errorcode(self):
for attribute in errno.__dict__.keys():
if attribute.isupper():
- self.assert_(getattr(errno, attribute) in errno.errorcode,
+ self.assertTrue(getattr(errno, attribute) in errno.errorcode,
'no %s attr in errno.errorcode' % attribute)
Modified: python/branches/py3k/Lib/test/test_exceptions.py
==============================================================================
--- python/branches/py3k/Lib/test/test_exceptions.py (original)
+++ python/branches/py3k/Lib/test/test_exceptions.py Wed Jul 1 01:06:06 2009
@@ -155,7 +155,7 @@
exc, err, tb = sys.exc_info()
co = tb.tb_frame.f_code
self.assertEquals(co.co_name, "test_capi1")
- self.assert_(co.co_filename.endswith('test_exceptions.py'))
+ self.assertTrue(co.co_filename.endswith('test_exceptions.py'))
else:
self.fail("Expected exception")
@@ -167,7 +167,7 @@
exc, err, tb = sys.exc_info()
co = tb.tb_frame.f_code
self.assertEquals(co.co_name, "__init__")
- self.assert_(co.co_filename.endswith('test_exceptions.py'))
+ self.assertTrue(co.co_filename.endswith('test_exceptions.py'))
co2 = tb.tb_frame.f_back.f_code
self.assertEquals(co2.co_name, "test_capi2")
else:
@@ -189,12 +189,12 @@
except NameError:
pass
else:
- self.failUnlessEqual(str(WindowsError(1001)),
+ self.assertEqual(str(WindowsError(1001)),
"1001")
- self.failUnlessEqual(str(WindowsError(1001, "message")),
+ self.assertEqual(str(WindowsError(1001, "message")),
"[Error 1001] message")
- self.failUnlessEqual(WindowsError(1001, "message").errno, 22)
- self.failUnlessEqual(WindowsError(1001, "message").winerror, 1001)
+ self.assertEqual(WindowsError(1001, "message").errno, 22)
+ self.assertEqual(WindowsError(1001, "message").winerror, 1001)
def testAttributes(self):
# test that exception attributes are happy
@@ -319,25 +319,25 @@
tb = sys.exc_info()[2]
e = BaseException().with_traceback(tb)
- self.failUnless(isinstance(e, BaseException))
+ self.assertTrue(isinstance(e, BaseException))
self.assertEqual(e.__traceback__, tb)
e = IndexError(5).with_traceback(tb)
- self.failUnless(isinstance(e, IndexError))
+ self.assertTrue(isinstance(e, IndexError))
self.assertEqual(e.__traceback__, tb)
class MyException(Exception):
pass
e = MyException().with_traceback(tb)
- self.failUnless(isinstance(e, MyException))
+ self.assertTrue(isinstance(e, MyException))
self.assertEqual(e.__traceback__, tb)
def testInvalidTraceback(self):
try:
Exception().__traceback__ = 5
except TypeError as e:
- self.failUnless("__traceback__ must be a traceback" in str(e))
+ self.assertTrue("__traceback__ must be a traceback" in str(e))
else:
self.fail("No exception raised")
@@ -402,10 +402,10 @@
def testUnicodeStrUsage(self):
# Make sure both instances and classes have a str and unicode
# representation.
- self.failUnless(str(Exception))
- self.failUnless(str(Exception))
- self.failUnless(str(Exception('a')))
- self.failUnless(str(Exception('a')))
+ self.assertTrue(str(Exception))
+ self.assertTrue(str(Exception))
+ self.assertTrue(str(Exception('a')))
+ self.assertTrue(str(Exception('a')))
def testExceptionCleanupNames(self):
# Make sure the local variable bound to the exception instance by
@@ -413,9 +413,9 @@
try:
raise Exception()
except Exception as e:
- self.failUnless(e)
+ self.assertTrue(e)
del e
- self.failIf('e' in locals())
+ self.assertFalse('e' in locals())
def testExceptionCleanupState(self):
# Make sure exception state is cleaned up as soon as the except
@@ -441,7 +441,7 @@
pass
obj = None
obj = wr()
- self.failUnless(obj is None, "%s" % obj)
+ self.assertTrue(obj is None, "%s" % obj)
# Qualified "except" without "as"
obj = MyObj()
@@ -452,7 +452,7 @@
pass
obj = None
obj = wr()
- self.failUnless(obj is None, "%s" % obj)
+ self.assertTrue(obj is None, "%s" % obj)
# Bare "except"
obj = MyObj()
@@ -463,7 +463,7 @@
pass
obj = None
obj = wr()
- self.failUnless(obj is None, "%s" % obj)
+ self.assertTrue(obj is None, "%s" % obj)
# "except" with premature block leave
obj = MyObj()
@@ -475,7 +475,7 @@
break
obj = None
obj = wr()
- self.failUnless(obj is None, "%s" % obj)
+ self.assertTrue(obj is None, "%s" % obj)
# "except" block raising another exception
obj = MyObj()
@@ -493,7 +493,7 @@
e.__context__ = None
obj = None
obj = wr()
- self.failUnless(obj is None, "%s" % obj)
+ self.assertTrue(obj is None, "%s" % obj)
# Some complicated construct
obj = MyObj()
@@ -510,7 +510,7 @@
pass
obj = None
obj = wr()
- self.failUnless(obj is None, "%s" % obj)
+ self.assertTrue(obj is None, "%s" % obj)
# Inside an exception-silencing "with" block
class Context:
@@ -524,7 +524,7 @@
inner_raising_func()
obj = None
obj = wr()
- self.failUnless(obj is None, "%s" % obj)
+ self.assertTrue(obj is None, "%s" % obj)
def test_generator_leaking(self):
# Test that generator exception state doesn't leak into the calling
@@ -598,8 +598,8 @@
except RuntimeError:
return sys.exc_info()
e, v, tb = g()
- self.assert_(isinstance(v, RuntimeError), type(v))
- self.assert_("maximum recursion depth exceeded" in str(v), str(v))
+ self.assertTrue(isinstance(v, RuntimeError), type(v))
+ self.assertTrue("maximum recursion depth exceeded" in str(v), str(v))
def test_MemoryError(self):
Modified: python/branches/py3k/Lib/test/test_file.py
==============================================================================
--- python/branches/py3k/Lib/test/test_file.py (original)
+++ python/branches/py3k/Lib/test/test_file.py Wed Jul 1 01:06:06 2009
@@ -83,13 +83,13 @@
def testErrors(self):
f = self.f
self.assertEquals(f.name, TESTFN)
- self.assert_(not f.isatty())
- self.assert_(not f.closed)
+ self.assertTrue(not f.isatty())
+ self.assertTrue(not f.closed)
if hasattr(f, "readinto"):
self.assertRaises((IOError, TypeError), f.readinto, "")
f.close()
- self.assert_(f.closed)
+ self.assertTrue(f.closed)
def testMethods(self):
methods = [('fileno', ()),
@@ -111,7 +111,7 @@
# __exit__ should close the file
self.f.__exit__(None, None, None)
- self.assert_(self.f.closed)
+ self.assertTrue(self.f.closed)
for methodname, args in methods:
method = getattr(self.f, methodname)
Modified: python/branches/py3k/Lib/test/test_filecmp.py
==============================================================================
--- python/branches/py3k/Lib/test/test_filecmp.py (original)
+++ python/branches/py3k/Lib/test/test_filecmp.py Wed Jul 1 01:06:06 2009
@@ -25,19 +25,19 @@
os.unlink(self.name_diff)
def test_matching(self):
- self.failUnless(filecmp.cmp(self.name, self.name_same),
+ self.assertTrue(filecmp.cmp(self.name, self.name_same),
"Comparing file to itself fails")
- self.failUnless(filecmp.cmp(self.name, self.name_same, shallow=False),
+ self.assertTrue(filecmp.cmp(self.name, self.name_same, shallow=False),
"Comparing file to itself fails")
- self.failUnless(filecmp.cmp(self.name, self.name, shallow=False),
+ self.assertTrue(filecmp.cmp(self.name, self.name, shallow=False),
"Comparing file to identical file fails")
- self.failUnless(filecmp.cmp(self.name, self.name),
+ self.assertTrue(filecmp.cmp(self.name, self.name),
"Comparing file to identical file fails")
def test_different(self):
- self.failIf(filecmp.cmp(self.name, self.name_diff),
+ self.assertFalse(filecmp.cmp(self.name, self.name_diff),
"Mismatched files compare as equal")
- self.failIf(filecmp.cmp(self.name, self.dir),
+ self.assertFalse(filecmp.cmp(self.name, self.dir),
"File and directory compare as equal")
class DirCompareTestCase(unittest.TestCase):
@@ -69,19 +69,19 @@
shutil.rmtree(self.dir_diff)
def test_cmpfiles(self):
- self.failUnless(filecmp.cmpfiles(self.dir, self.dir, ['file']) ==
+ self.assertTrue(filecmp.cmpfiles(self.dir, self.dir, ['file']) ==
(['file'], [], []),
"Comparing directory to itself fails")
- self.failUnless(filecmp.cmpfiles(self.dir, self.dir_same, ['file']) ==
+ self.assertTrue(filecmp.cmpfiles(self.dir, self.dir_same, ['file']) ==
(['file'], [], []),
"Comparing directory to same fails")
# Try it with shallow=False
- self.failUnless(filecmp.cmpfiles(self.dir, self.dir, ['file'],
+ self.assertTrue(filecmp.cmpfiles(self.dir, self.dir, ['file'],
shallow=False) ==
(['file'], [], []),
"Comparing directory to itself fails")
- self.failUnless(filecmp.cmpfiles(self.dir, self.dir_same, ['file'],
+ self.assertTrue(filecmp.cmpfiles(self.dir, self.dir_same, ['file'],
shallow=False),
"Comparing directory to same fails")
@@ -90,7 +90,7 @@
output.write('Different contents.\n')
output.close()
- self.failIf(filecmp.cmpfiles(self.dir, self.dir_same,
+ self.assertFalse(filecmp.cmpfiles(self.dir, self.dir_same,
['file', 'file2']) ==
(['file'], ['file2'], []),
"Comparing mismatched directories fails")
@@ -104,14 +104,14 @@
else:
self.assertEqual([d.left_list, d.right_list],[['file'], ['file']])
self.assertEqual(d.common, ['file'])
- self.failUnless(d.left_only == d.right_only == [])
+ self.assertTrue(d.left_only == d.right_only == [])
self.assertEqual(d.same_files, ['file'])
self.assertEqual(d.diff_files, [])
# Check attributes for comparison of two different directories
d = filecmp.dircmp(self.dir, self.dir_diff)
self.assertEqual(d.left_list, ['file'])
- self.failUnless(d.right_list == ['file', 'file2'])
+ self.assertTrue(d.right_list == ['file', 'file2'])
self.assertEqual(d.common, ['file'])
self.assertEqual(d.left_only, [])
self.assertEqual(d.right_only, ['file2'])
Modified: python/branches/py3k/Lib/test/test_fileinput.py
==============================================================================
--- python/branches/py3k/Lib/test/test_fileinput.py (original)
+++ python/branches/py3k/Lib/test/test_fileinput.py Wed Jul 1 01:06:06 2009
@@ -68,8 +68,8 @@
self.assertEqual(fi.filename(), t2)
self.assertEqual(fi.lineno(), 21)
self.assertEqual(fi.filelineno(), 6)
- self.failIf(fi.isfirstline())
- self.failIf(fi.isstdin())
+ self.assertFalse(fi.isfirstline())
+ self.assertFalse(fi.isstdin())
if verbose:
print('%s. Nextfile (bs=%s)' % (start+2, bs))
@@ -138,7 +138,7 @@
self.assertEqual(fi.filename(), t3)
line = fi.readline()
- self.failIf(line)
+ self.assertFalse(line)
self.assertEqual(fi.lineno(), 1)
self.assertEqual(fi.filelineno(), 0)
self.assertEqual(fi.filename(), t4)
Modified: python/branches/py3k/Lib/test/test_fileio.py
==============================================================================
--- python/branches/py3k/Lib/test/test_fileio.py (original)
+++ python/branches/py3k/Lib/test/test_fileio.py Wed Jul 1 01:06:06 2009
@@ -80,17 +80,17 @@
def testErrors(self):
f = self.f
- self.assert_(not f.isatty())
- self.assert_(not f.closed)
+ self.assertTrue(not f.isatty())
+ self.assertTrue(not f.closed)
#self.assertEquals(f.name, TESTFN)
self.assertRaises(ValueError, f.read, 10) # Open for reading
f.close()
- self.assert_(f.closed)
+ self.assertTrue(f.closed)
f = _FileIO(TESTFN, 'r')
self.assertRaises(TypeError, f.readinto, "")
- self.assert_(not f.closed)
+ self.assertTrue(not f.closed)
f.close()
- self.assert_(f.closed)
+ self.assertTrue(f.closed)
def testMethods(self):
methods = ['fileno', 'isatty', 'read', 'readinto',
@@ -100,7 +100,7 @@
methods.remove('truncate')
self.f.close()
- self.assert_(self.f.closed)
+ self.assertTrue(self.f.closed)
for methodname in methods:
method = getattr(self.f, methodname)
Modified: python/branches/py3k/Lib/test/test_float.py
==============================================================================
--- python/branches/py3k/Lib/test/test_float.py (original)
+++ python/branches/py3k/Lib/test/test_float.py Wed Jul 1 01:06:06 2009
@@ -136,27 +136,27 @@
def test_float_containment(self):
floats = (INF, -INF, 0.0, 1.0, NAN)
for f in floats:
- self.assert_(f in [f], "'%r' not in []" % f)
- self.assert_(f in (f,), "'%r' not in ()" % f)
- self.assert_(f in {f}, "'%r' not in set()" % f)
- self.assert_(f in {f: None}, "'%r' not in {}" % f)
+ self.assertTrue(f in [f], "'%r' not in []" % f)
+ self.assertTrue(f in (f,), "'%r' not in ()" % f)
+ self.assertTrue(f in {f}, "'%r' not in set()" % f)
+ self.assertTrue(f in {f: None}, "'%r' not in {}" % f)
self.assertEqual([f].count(f), 1, "[].count('%r') != 1" % f)
- self.assert_(f in floats, "'%r' not in container" % f)
+ self.assertTrue(f in floats, "'%r' not in container" % f)
for f in floats:
# nonidentical containers, same type, same contents
- self.assert_([f] == [f], "[%r] != [%r]" % (f, f))
- self.assert_((f,) == (f,), "(%r,) != (%r,)" % (f, f))
- self.assert_({f} == {f}, "{%r} != {%r}" % (f, f))
- self.assert_({f : None} == {f: None}, "{%r : None} != "
+ self.assertTrue([f] == [f], "[%r] != [%r]" % (f, f))
+ self.assertTrue((f,) == (f,), "(%r,) != (%r,)" % (f, f))
+ self.assertTrue({f} == {f}, "{%r} != {%r}" % (f, f))
+ self.assertTrue({f : None} == {f: None}, "{%r : None} != "
"{%r : None}" % (f, f))
# identical containers
l, t, s, d = [f], (f,), {f}, {f: None}
- self.assert_(l == l, "[%r] not equal to itself" % f)
- self.assert_(t == t, "(%r,) not equal to itself" % f)
- self.assert_(s == s, "{%r} not equal to itself" % f)
- self.assert_(d == d, "{%r : None} not equal to itself" % f)
+ self.assertTrue(l == l, "[%r] not equal to itself" % f)
+ self.assertTrue(t == t, "(%r,) not equal to itself" % f)
+ self.assertTrue(s == s, "{%r} not equal to itself" % f)
+ self.assertTrue(d == d, "{%r : None} not equal to itself" % f)
@@ -171,9 +171,9 @@
float.__setformat__('float', self.save_formats['float'])
def test_getformat(self):
- self.assert_(float.__getformat__('double') in
+ self.assertTrue(float.__getformat__('double') in
['unknown', 'IEEE, big-endian', 'IEEE, little-endian'])
- self.assert_(float.__getformat__('float') in
+ self.assertTrue(float.__getformat__('float') in
['unknown', 'IEEE, big-endian', 'IEEE, little-endian'])
self.assertRaises(ValueError, float.__getformat__, 'chicken')
self.assertRaises(TypeError, float.__getformat__, 1)
@@ -493,12 +493,12 @@
# ways to create and represent inf and nan
class InfNanTest(unittest.TestCase):
def test_inf_from_str(self):
- self.assert_(isinf(float("inf")))
- self.assert_(isinf(float("+inf")))
- self.assert_(isinf(float("-inf")))
- self.assert_(isinf(float("infinity")))
- self.assert_(isinf(float("+infinity")))
- self.assert_(isinf(float("-infinity")))
+ self.assertTrue(isinf(float("inf")))
+ self.assertTrue(isinf(float("+inf")))
+ self.assertTrue(isinf(float("-inf")))
+ self.assertTrue(isinf(float("infinity")))
+ self.assertTrue(isinf(float("+infinity")))
+ self.assertTrue(isinf(float("-infinity")))
self.assertEqual(repr(float("inf")), "inf")
self.assertEqual(repr(float("+inf")), "inf")
@@ -545,9 +545,9 @@
self.assertEqual(str(-1e300 * 1e300), "-inf")
def test_nan_from_str(self):
- self.assert_(isnan(float("nan")))
- self.assert_(isnan(float("+nan")))
- self.assert_(isnan(float("-nan")))
+ self.assertTrue(isnan(float("nan")))
+ self.assertTrue(isnan(float("+nan")))
+ self.assertTrue(isnan(float("-nan")))
self.assertEqual(repr(float("nan")), "nan")
self.assertEqual(repr(float("+nan")), "nan")
@@ -581,14 +581,14 @@
self.assertEqual(str(-1e300 * 1e300 * 0), "nan")
def notest_float_nan(self):
- self.assert_(NAN.is_nan())
- self.failIf(INF.is_nan())
- self.failIf((0.).is_nan())
+ self.assertTrue(NAN.is_nan())
+ self.assertFalse(INF.is_nan())
+ self.assertFalse((0.).is_nan())
def notest_float_inf(self):
- self.assert_(INF.is_inf())
- self.failIf(NAN.is_inf())
- self.failIf((0.).is_inf())
+ self.assertTrue(INF.is_inf())
+ self.assertFalse(NAN.is_inf())
+ self.assertFalse((0.).is_inf())
fromHex = float.fromhex
toHex = float.hex
Modified: python/branches/py3k/Lib/test/test_fnmatch.py
==============================================================================
--- python/branches/py3k/Lib/test/test_fnmatch.py (original)
+++ python/branches/py3k/Lib/test/test_fnmatch.py Wed Jul 1 01:06:06 2009
@@ -9,11 +9,11 @@
class FnmatchTestCase(unittest.TestCase):
def check_match(self, filename, pattern, should_match=1):
if should_match:
- self.assert_(fnmatch(filename, pattern),
+ self.assertTrue(fnmatch(filename, pattern),
"expected %r to match pattern %r"
% (filename, pattern))
else:
- self.assert_(not fnmatch(filename, pattern),
+ self.assertTrue(not fnmatch(filename, pattern),
"expected %r not to match pattern %r"
% (filename, pattern))
Modified: python/branches/py3k/Lib/test/test_ftplib.py
==============================================================================
--- python/branches/py3k/Lib/test/test_ftplib.py (original)
+++ python/branches/py3k/Lib/test/test_ftplib.py Wed Jul 1 01:06:06 2009
@@ -444,7 +444,7 @@
def testTimeoutDefault(self):
# default -- use global socket timeout
- self.assert_(socket.getdefaulttimeout() is None)
+ self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
try:
ftp = ftplib.FTP("localhost")
@@ -456,7 +456,7 @@
def testTimeoutNone(self):
# no timeout -- do not use global socket timeout
- self.assert_(socket.getdefaulttimeout() is None)
+ self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
try:
ftp = ftplib.FTP("localhost", timeout=None)
Modified: python/branches/py3k/Lib/test/test_funcattrs.py
==============================================================================
--- python/branches/py3k/Lib/test/test_funcattrs.py (original)
+++ python/branches/py3k/Lib/test/test_funcattrs.py Wed Jul 1 01:06:06 2009
@@ -35,11 +35,11 @@
def test_dir_includes_correct_attrs(self):
self.b.known_attr = 7
- self.assert_('known_attr' in dir(self.b),
+ self.assertTrue('known_attr' in dir(self.b),
"set attributes not in dir listing of method")
# Test on underlying function object of method
self.F.a.known_attr = 7
- self.assert_('known_attr' in dir(self.fi.a), "set attribute on function "
+ self.assertTrue('known_attr' in dir(self.fi.a), "set attribute on function "
"implementations, should show up in next dir")
def test_duplicate_function_equality(self):
@@ -248,11 +248,11 @@
# their presence should not be interpreted as providing any
# guarantees about the semantics (or even existence) of cell
# comparisons in future versions of CPython.
- self.assert_(cell(2) < cell(3))
- self.assert_(empty_cell() < cell('saturday'))
- self.assert_(empty_cell() == empty_cell())
- self.assert_(cell(-36) == cell(-36.0))
- self.assert_(cell(True) > empty_cell())
+ self.assertTrue(cell(2) < cell(3))
+ self.assertTrue(empty_cell() < cell('saturday'))
+ self.assertTrue(empty_cell() == empty_cell())
+ self.assertTrue(cell(-36) == cell(-36.0))
+ self.assertTrue(cell(True) > empty_cell())
class StaticMethodAttrsTest(unittest.TestCase):
def test_func_attribute(self):
@@ -260,10 +260,10 @@
pass
c = classmethod(f)
- self.assert_(c.__func__ is f)
+ self.assertTrue(c.__func__ is f)
s = staticmethod(f)
- self.assert_(s.__func__ is f)
+ self.assertTrue(s.__func__ is f)
def test_main():
Modified: python/branches/py3k/Lib/test/test_functools.py
==============================================================================
--- python/branches/py3k/Lib/test/test_functools.py (original)
+++ python/branches/py3k/Lib/test/test_functools.py Wed Jul 1 01:06:06 2009
@@ -96,7 +96,7 @@
p = self.thetype(capture, *args)
expected = args + ('x',)
got, empty = p('x')
- self.failUnless(expected == got and empty == {})
+ self.assertTrue(expected == got and empty == {})
def test_keyword(self):
# make sure keyword arguments are captured correctly
@@ -104,15 +104,15 @@
p = self.thetype(capture, a=a)
expected = {'a':a,'x':None}
empty, got = p(x=None)
- self.failUnless(expected == got and empty == ())
+ self.assertTrue(expected == got and empty == ())
def test_no_side_effects(self):
# make sure there are no side effects that affect subsequent calls
p = self.thetype(capture, 0, a=1)
args1, kw1 = p(1, b=2)
- self.failUnless(args1 == (0,1) and kw1 == {'a':1,'b':2})
+ self.assertTrue(args1 == (0,1) and kw1 == {'a':1,'b':2})
args2, kw2 = p()
- self.failUnless(args2 == (0,) and kw2 == {'a':1})
+ self.assertTrue(args2 == (0,) and kw2 == {'a':1})
def test_error_propagation(self):
def f(x, y):
@@ -172,13 +172,13 @@
updated=functools.WRAPPER_UPDATES):
# Check attributes were assigned
for name in assigned:
- self.failUnless(getattr(wrapper, name) is getattr(wrapped, name))
+ self.assertTrue(getattr(wrapper, name) is getattr(wrapped, name))
# Check attributes were updated
for name in updated:
wrapper_attr = getattr(wrapper, name)
wrapped_attr = getattr(wrapped, name)
for key in wrapped_attr:
- self.failUnless(wrapped_attr[key] is wrapper_attr[key])
+ self.assertTrue(wrapped_attr[key] is wrapper_attr[key])
def test_default_update(self):
def f():
@@ -204,7 +204,7 @@
self.check_wrapper(wrapper, f, (), ())
self.assertEqual(wrapper.__name__, 'wrapper')
self.assertEqual(wrapper.__doc__, None)
- self.failIf(hasattr(wrapper, 'attr'))
+ self.assertFalse(hasattr(wrapper, 'attr'))
def test_selective_update(self):
def f():
@@ -229,7 +229,7 @@
pass
functools.update_wrapper(wrapper, max)
self.assertEqual(wrapper.__name__, 'max')
- self.assert_(wrapper.__doc__.startswith('max('))
+ self.assertTrue(wrapper.__doc__.startswith('max('))
class TestWraps(TestUpdateWrapper):
@@ -257,7 +257,7 @@
self.check_wrapper(wrapper, f, (), ())
self.assertEqual(wrapper.__name__, 'wrapper')
self.assertEqual(wrapper.__doc__, None)
- self.failIf(hasattr(wrapper, 'attr'))
+ self.assertFalse(hasattr(wrapper, 'attr'))
def test_selective_update(self):
def f():
Modified: python/branches/py3k/Lib/test/test_genericpath.py
==============================================================================
--- python/branches/py3k/Lib/test/test_genericpath.py (original)
+++ python/branches/py3k/Lib/test/test_genericpath.py Wed Jul 1 01:06:06 2009
@@ -6,7 +6,7 @@
class AllCommonTest(unittest.TestCase):
def assertIs(self, a, b):
- self.assert_(a is b)
+ self.assertTrue(a is b)
def test_commonprefix(self):
self.assertEqual(
@@ -50,7 +50,7 @@
f.close()
self.assertEqual(d, b"foobar")
- self.assert_(
+ self.assertTrue(
genericpath.getctime(support.TESTFN) <=
genericpath.getmtime(support.TESTFN)
)
Modified: python/branches/py3k/Lib/test/test_getargs2.py
==============================================================================
--- python/branches/py3k/Lib/test/test_getargs2.py (original)
+++ python/branches/py3k/Lib/test/test_getargs2.py Wed Jul 1 01:06:06 2009
@@ -68,68 +68,68 @@
from _testcapi import getargs_b
# b returns 'unsigned char', and does range checking (0 ... UCHAR_MAX)
self.assertRaises(TypeError, getargs_b, 3.14)
- self.failUnlessEqual(99, getargs_b(Long()))
- self.failUnlessEqual(99, getargs_b(Int()))
+ self.assertEqual(99, getargs_b(Long()))
+ self.assertEqual(99, getargs_b(Int()))
self.assertRaises(OverflowError, getargs_b, -1)
- self.failUnlessEqual(0, getargs_b(0))
- self.failUnlessEqual(UCHAR_MAX, getargs_b(UCHAR_MAX))
+ self.assertEqual(0, getargs_b(0))
+ self.assertEqual(UCHAR_MAX, getargs_b(UCHAR_MAX))
self.assertRaises(OverflowError, getargs_b, UCHAR_MAX + 1)
- self.failUnlessEqual(42, getargs_b(42))
- self.failUnlessEqual(42, getargs_b(42))
+ self.assertEqual(42, getargs_b(42))
+ self.assertEqual(42, getargs_b(42))
self.assertRaises(OverflowError, getargs_b, VERY_LARGE)
def test_B(self):
from _testcapi import getargs_B
# B returns 'unsigned char', no range checking
self.assertRaises(TypeError, getargs_B, 3.14)
- self.failUnlessEqual(99, getargs_B(Long()))
- self.failUnlessEqual(99, getargs_B(Int()))
+ self.assertEqual(99, getargs_B(Long()))
+ self.assertEqual(99, getargs_B(Int()))
- self.failUnlessEqual(UCHAR_MAX, getargs_B(-1))
- self.failUnlessEqual(UCHAR_MAX, getargs_B(-1))
- self.failUnlessEqual(0, getargs_B(0))
- self.failUnlessEqual(UCHAR_MAX, getargs_B(UCHAR_MAX))
- self.failUnlessEqual(0, getargs_B(UCHAR_MAX+1))
-
- self.failUnlessEqual(42, getargs_B(42))
- self.failUnlessEqual(42, getargs_B(42))
- self.failUnlessEqual(UCHAR_MAX & VERY_LARGE, getargs_B(VERY_LARGE))
+ self.assertEqual(UCHAR_MAX, getargs_B(-1))
+ self.assertEqual(UCHAR_MAX, getargs_B(-1))
+ self.assertEqual(0, getargs_B(0))
+ self.assertEqual(UCHAR_MAX, getargs_B(UCHAR_MAX))
+ self.assertEqual(0, getargs_B(UCHAR_MAX+1))
+
+ self.assertEqual(42, getargs_B(42))
+ self.assertEqual(42, getargs_B(42))
+ self.assertEqual(UCHAR_MAX & VERY_LARGE, getargs_B(VERY_LARGE))
def test_H(self):
from _testcapi import getargs_H
# H returns 'unsigned short', no range checking
self.assertRaises(TypeError, getargs_H, 3.14)
- self.failUnlessEqual(99, getargs_H(Long()))
- self.failUnlessEqual(99, getargs_H(Int()))
+ self.assertEqual(99, getargs_H(Long()))
+ self.assertEqual(99, getargs_H(Int()))
- self.failUnlessEqual(USHRT_MAX, getargs_H(-1))
- self.failUnlessEqual(0, getargs_H(0))
- self.failUnlessEqual(USHRT_MAX, getargs_H(USHRT_MAX))
- self.failUnlessEqual(0, getargs_H(USHRT_MAX+1))
+ self.assertEqual(USHRT_MAX, getargs_H(-1))
+ self.assertEqual(0, getargs_H(0))
+ self.assertEqual(USHRT_MAX, getargs_H(USHRT_MAX))
+ self.assertEqual(0, getargs_H(USHRT_MAX+1))
- self.failUnlessEqual(42, getargs_H(42))
- self.failUnlessEqual(42, getargs_H(42))
+ self.assertEqual(42, getargs_H(42))
+ self.assertEqual(42, getargs_H(42))
- self.failUnlessEqual(VERY_LARGE & USHRT_MAX, getargs_H(VERY_LARGE))
+ self.assertEqual(VERY_LARGE & USHRT_MAX, getargs_H(VERY_LARGE))
def test_I(self):
from _testcapi import getargs_I
# I returns 'unsigned int', no range checking
self.assertRaises(TypeError, getargs_I, 3.14)
- self.failUnlessEqual(99, getargs_I(Long()))
- self.failUnlessEqual(99, getargs_I(Int()))
+ self.assertEqual(99, getargs_I(Long()))
+ self.assertEqual(99, getargs_I(Int()))
- self.failUnlessEqual(UINT_MAX, getargs_I(-1))
- self.failUnlessEqual(0, getargs_I(0))
- self.failUnlessEqual(UINT_MAX, getargs_I(UINT_MAX))
- self.failUnlessEqual(0, getargs_I(UINT_MAX+1))
+ self.assertEqual(UINT_MAX, getargs_I(-1))
+ self.assertEqual(0, getargs_I(0))
+ self.assertEqual(UINT_MAX, getargs_I(UINT_MAX))
+ self.assertEqual(0, getargs_I(UINT_MAX+1))
- self.failUnlessEqual(42, getargs_I(42))
- self.failUnlessEqual(42, getargs_I(42))
+ self.assertEqual(42, getargs_I(42))
+ self.assertEqual(42, getargs_I(42))
- self.failUnlessEqual(VERY_LARGE & UINT_MAX, getargs_I(VERY_LARGE))
+ self.assertEqual(VERY_LARGE & UINT_MAX, getargs_I(VERY_LARGE))
def test_k(self):
from _testcapi import getargs_k
@@ -139,47 +139,47 @@
self.assertRaises(TypeError, getargs_k, Long())
self.assertRaises(TypeError, getargs_k, Int())
- self.failUnlessEqual(ULONG_MAX, getargs_k(-1))
- self.failUnlessEqual(0, getargs_k(0))
- self.failUnlessEqual(ULONG_MAX, getargs_k(ULONG_MAX))
- self.failUnlessEqual(0, getargs_k(ULONG_MAX+1))
+ self.assertEqual(ULONG_MAX, getargs_k(-1))
+ self.assertEqual(0, getargs_k(0))
+ self.assertEqual(ULONG_MAX, getargs_k(ULONG_MAX))
+ self.assertEqual(0, getargs_k(ULONG_MAX+1))
- self.failUnlessEqual(42, getargs_k(42))
- self.failUnlessEqual(42, getargs_k(42))
+ self.assertEqual(42, getargs_k(42))
+ self.assertEqual(42, getargs_k(42))
- self.failUnlessEqual(VERY_LARGE & ULONG_MAX, getargs_k(VERY_LARGE))
+ self.assertEqual(VERY_LARGE & ULONG_MAX, getargs_k(VERY_LARGE))
class Signed_TestCase(unittest.TestCase):
def test_i(self):
from _testcapi import getargs_i
# i returns 'int', and does range checking (INT_MIN ... INT_MAX)
self.assertRaises(TypeError, getargs_i, 3.14)
- self.failUnlessEqual(99, getargs_i(Long()))
- self.failUnlessEqual(99, getargs_i(Int()))
+ self.assertEqual(99, getargs_i(Long()))
+ self.assertEqual(99, getargs_i(Int()))
self.assertRaises(OverflowError, getargs_i, INT_MIN-1)
- self.failUnlessEqual(INT_MIN, getargs_i(INT_MIN))
- self.failUnlessEqual(INT_MAX, getargs_i(INT_MAX))
+ self.assertEqual(INT_MIN, getargs_i(INT_MIN))
+ self.assertEqual(INT_MAX, getargs_i(INT_MAX))
self.assertRaises(OverflowError, getargs_i, INT_MAX+1)
- self.failUnlessEqual(42, getargs_i(42))
- self.failUnlessEqual(42, getargs_i(42))
+ self.assertEqual(42, getargs_i(42))
+ self.assertEqual(42, getargs_i(42))
self.assertRaises(OverflowError, getargs_i, VERY_LARGE)
def test_l(self):
from _testcapi import getargs_l
# l returns 'long', and does range checking (LONG_MIN ... LONG_MAX)
self.assertRaises(TypeError, getargs_l, 3.14)
- self.failUnlessEqual(99, getargs_l(Long()))
- self.failUnlessEqual(99, getargs_l(Int()))
+ self.assertEqual(99, getargs_l(Long()))
+ self.assertEqual(99, getargs_l(Int()))
self.assertRaises(OverflowError, getargs_l, LONG_MIN-1)
- self.failUnlessEqual(LONG_MIN, getargs_l(LONG_MIN))
- self.failUnlessEqual(LONG_MAX, getargs_l(LONG_MAX))
+ self.assertEqual(LONG_MIN, getargs_l(LONG_MIN))
+ self.assertEqual(LONG_MAX, getargs_l(LONG_MAX))
self.assertRaises(OverflowError, getargs_l, LONG_MAX+1)
- self.failUnlessEqual(42, getargs_l(42))
- self.failUnlessEqual(42, getargs_l(42))
+ self.assertEqual(42, getargs_l(42))
+ self.assertEqual(42, getargs_l(42))
self.assertRaises(OverflowError, getargs_l, VERY_LARGE)
def test_n(self):
@@ -191,12 +191,12 @@
self.assertRaises(TypeError, getargs_n, Int())
self.assertRaises(OverflowError, getargs_n, PY_SSIZE_T_MIN-1)
- self.failUnlessEqual(PY_SSIZE_T_MIN, getargs_n(PY_SSIZE_T_MIN))
- self.failUnlessEqual(PY_SSIZE_T_MAX, getargs_n(PY_SSIZE_T_MAX))
+ self.assertEqual(PY_SSIZE_T_MIN, getargs_n(PY_SSIZE_T_MIN))
+ self.assertEqual(PY_SSIZE_T_MAX, getargs_n(PY_SSIZE_T_MAX))
self.assertRaises(OverflowError, getargs_n, PY_SSIZE_T_MAX+1)
- self.failUnlessEqual(42, getargs_n(42))
- self.failUnlessEqual(42, getargs_n(42))
+ self.assertEqual(42, getargs_n(42))
+ self.assertEqual(42, getargs_n(42))
self.assertRaises(OverflowError, getargs_n, VERY_LARGE)
@@ -204,18 +204,18 @@
def test_L(self):
from _testcapi import getargs_L
# L returns 'long long', and does range checking (LLONG_MIN ... LLONG_MAX)
- self.failUnlessRaises(TypeError, getargs_L, "Hello")
- self.failUnlessEqual(3, getargs_L(3.14))
- self.failUnlessEqual(99, getargs_L(Long()))
- self.failUnlessEqual(99, getargs_L(Int()))
+ self.assertRaises(TypeError, getargs_L, "Hello")
+ self.assertEqual(3, getargs_L(3.14))
+ self.assertEqual(99, getargs_L(Long()))
+ self.assertEqual(99, getargs_L(Int()))
self.assertRaises(OverflowError, getargs_L, LLONG_MIN-1)
- self.failUnlessEqual(LLONG_MIN, getargs_L(LLONG_MIN))
- self.failUnlessEqual(LLONG_MAX, getargs_L(LLONG_MAX))
+ self.assertEqual(LLONG_MIN, getargs_L(LLONG_MIN))
+ self.assertEqual(LLONG_MAX, getargs_L(LLONG_MAX))
self.assertRaises(OverflowError, getargs_L, LLONG_MAX+1)
- self.failUnlessEqual(42, getargs_L(42))
- self.failUnlessEqual(42, getargs_L(42))
+ self.assertEqual(42, getargs_L(42))
+ self.assertEqual(42, getargs_L(42))
self.assertRaises(OverflowError, getargs_L, VERY_LARGE)
def test_K(self):
@@ -224,14 +224,14 @@
self.assertRaises(TypeError, getargs_K, 3.14)
self.assertRaises(TypeError, getargs_K, Long())
self.assertRaises(TypeError, getargs_K, Int())
- self.failUnlessEqual(ULLONG_MAX, getargs_K(ULLONG_MAX))
- self.failUnlessEqual(0, getargs_K(0))
- self.failUnlessEqual(0, getargs_K(ULLONG_MAX+1))
+ self.assertEqual(ULLONG_MAX, getargs_K(ULLONG_MAX))
+ self.assertEqual(0, getargs_K(0))
+ self.assertEqual(0, getargs_K(ULLONG_MAX+1))
- self.failUnlessEqual(42, getargs_K(42))
- self.failUnlessEqual(42, getargs_K(42))
+ self.assertEqual(42, getargs_K(42))
+ self.assertEqual(42, getargs_K(42))
- self.failUnlessEqual(VERY_LARGE & ULLONG_MAX, getargs_K(VERY_LARGE))
+ self.assertEqual(VERY_LARGE & ULLONG_MAX, getargs_K(VERY_LARGE))
class Tuple_TestCase(unittest.TestCase):
Modified: python/branches/py3k/Lib/test/test_getopt.py
==============================================================================
--- python/branches/py3k/Lib/test/test_getopt.py (original)
+++ python/branches/py3k/Lib/test/test_getopt.py Wed Jul 1 01:06:06 2009
@@ -23,21 +23,21 @@
self.assertRaises(getopt.GetoptError, *args, **kwargs)
def test_short_has_arg(self):
- self.failUnless(getopt.short_has_arg('a', 'a:'))
- self.failIf(getopt.short_has_arg('a', 'a'))
+ self.assertTrue(getopt.short_has_arg('a', 'a:'))
+ self.assertFalse(getopt.short_has_arg('a', 'a'))
self.assertError(getopt.short_has_arg, 'a', 'b')
def test_long_has_args(self):
has_arg, option = getopt.long_has_args('abc', ['abc='])
- self.failUnless(has_arg)
+ self.assertTrue(has_arg)
self.assertEqual(option, 'abc')
has_arg, option = getopt.long_has_args('abc', ['abc'])
- self.failIf(has_arg)
+ self.assertFalse(has_arg)
self.assertEqual(option, 'abc')
has_arg, option = getopt.long_has_args('abc', ['abcd'])
- self.failIf(has_arg)
+ self.assertFalse(has_arg)
self.assertEqual(option, 'abcd')
self.assertError(getopt.long_has_args, 'abc', ['def'])
Modified: python/branches/py3k/Lib/test/test_gettext.py
==============================================================================
--- python/branches/py3k/Lib/test/test_gettext.py (original)
+++ python/branches/py3k/Lib/test/test_gettext.py Wed Jul 1 01:06:06 2009
@@ -306,7 +306,7 @@
self._ = self.t.gettext
def test_unicode_msgid(self):
- unless = self.failUnless
+ unless = self.assertTrue
unless(isinstance(self._(''), str))
unless(isinstance(self._(''), str))
Modified: python/branches/py3k/Lib/test/test_grammar.py
==============================================================================
--- python/branches/py3k/Lib/test/test_grammar.py (original)
+++ python/branches/py3k/Lib/test/test_grammar.py Wed Jul 1 01:06:06 2009
@@ -38,9 +38,9 @@
if maxsize == 2147483647:
self.assertEquals(-2147483647-1, -0o20000000000)
# XXX -2147483648
- self.assert_(0o37777777777 > 0)
- self.assert_(0xffffffff > 0)
- self.assert_(0b1111111111111111111111111111111 > 0)
+ self.assertTrue(0o37777777777 > 0)
+ self.assertTrue(0xffffffff > 0)
+ self.assertTrue(0b1111111111111111111111111111111 > 0)
for s in ('2147483648', '0o40000000000', '0x100000000',
'0b10000000000000000000000000000000'):
try:
@@ -49,9 +49,9 @@
self.fail("OverflowError on huge integer literal %r" % s)
elif maxsize == 9223372036854775807:
self.assertEquals(-9223372036854775807-1, -0o1000000000000000000000)
- self.assert_(0o1777777777777777777777 > 0)
- self.assert_(0xffffffffffffffff > 0)
- self.assert_(0b11111111111111111111111111111111111111111111111111111111111111 > 0)
+ self.assertTrue(0o1777777777777777777777 > 0)
+ self.assertTrue(0xffffffffffffffff > 0)
+ self.assertTrue(0b11111111111111111111111111111111111111111111111111111111111111 > 0)
for s in '9223372036854775808', '0o2000000000000000000000', \
'0x10000000000000000', \
'0b100000000000000000000000000000000000000000000000000000000000000':
@@ -87,15 +87,15 @@
x = 3.1e4
def testStringLiterals(self):
- x = ''; y = ""; self.assert_(len(x) == 0 and x == y)
- x = '\''; y = "'"; self.assert_(len(x) == 1 and x == y and ord(x) == 39)
- x = '"'; y = "\""; self.assert_(len(x) == 1 and x == y and ord(x) == 34)
+ x = ''; y = ""; self.assertTrue(len(x) == 0 and x == y)
+ x = '\''; y = "'"; self.assertTrue(len(x) == 1 and x == y and ord(x) == 39)
+ x = '"'; y = "\""; self.assertTrue(len(x) == 1 and x == y and ord(x) == 34)
x = "doesn't \"shrink\" does it"
y = 'doesn\'t "shrink" does it'
- self.assert_(len(x) == 24 and x == y)
+ self.assertTrue(len(x) == 24 and x == y)
x = "does \"shrink\" doesn't it"
y = 'does "shrink" doesn\'t it'
- self.assert_(len(x) == 24 and x == y)
+ self.assertTrue(len(x) == 24 and x == y)
x = """
The "quick"
brown fox
@@ -128,7 +128,7 @@
def testEllipsis(self):
x = ...
- self.assert_(x is Ellipsis)
+ self.assertTrue(x is Ellipsis)
self.assertRaises(SyntaxError, eval, ".. .")
class GrammarTests(unittest.TestCase):
@@ -494,7 +494,7 @@
nonlocal x, y
def testAssert(self):
- # assert_stmt: 'assert' test [',' test]
+ # assertTruestmt: 'assert' test [',' test]
assert 1
assert 1, 1
assert lambda x:x
Modified: python/branches/py3k/Lib/test/test_grp.py
==============================================================================
--- python/branches/py3k/Lib/test/test_grp.py (original)
+++ python/branches/py3k/Lib/test/test_grp.py Wed Jul 1 01:06:06 2009
@@ -12,13 +12,13 @@
# attributes promised by the docs
self.assertEqual(len(value), 4)
self.assertEqual(value[0], value.gr_name)
- self.assert_(isinstance(value.gr_name, str))
+ self.assertTrue(isinstance(value.gr_name, str))
self.assertEqual(value[1], value.gr_passwd)
- self.assert_(isinstance(value.gr_passwd, str))
+ self.assertTrue(isinstance(value.gr_passwd, str))
self.assertEqual(value[2], value.gr_gid)
- self.assert_(isinstance(value.gr_gid, int))
+ self.assertTrue(isinstance(value.gr_gid, int))
self.assertEqual(value[3], value.gr_mem)
- self.assert_(isinstance(value.gr_mem, list))
+ self.assertTrue(isinstance(value.gr_mem, list))
def test_values(self):
entries = grp.getgrall()
Modified: python/branches/py3k/Lib/test/test_gzip.py
==============================================================================
--- python/branches/py3k/Lib/test/test_gzip.py (original)
+++ python/branches/py3k/Lib/test/test_gzip.py Wed Jul 1 01:06:06 2009
@@ -91,7 +91,7 @@
while 1:
L = f.readline(line_length)
if not L and line_length != 0: break
- self.assert_(len(L) <= line_length)
+ self.assertTrue(len(L) <= line_length)
line_length = (line_length + 1) % 50
f.close()
@@ -157,7 +157,7 @@
def test_1647484(self):
for mode in ('wb', 'rb'):
f = gzip.GzipFile(self.filename, mode)
- self.assert_(hasattr(f, "name"))
+ self.assertTrue(hasattr(f, "name"))
self.assertEqual(f.name, self.filename)
f.close()
@@ -169,7 +169,7 @@
fRead = gzip.GzipFile(self.filename)
dataRead = fRead.read()
self.assertEqual(dataRead, data1)
- self.assert_(hasattr(fRead, 'mtime'))
+ self.assertTrue(hasattr(fRead, 'mtime'))
self.assertEqual(fRead.mtime, mtime)
fRead.close()
Modified: python/branches/py3k/Lib/test/test_hash.py
==============================================================================
--- python/branches/py3k/Lib/test/test_hash.py (original)
+++ python/branches/py3k/Lib/test/test_hash.py Wed Jul 1 01:06:06 2009
@@ -91,7 +91,7 @@
objects = (self.default_expected +
self.fixed_expected)
for obj in objects:
- self.assert_(isinstance(obj, Hashable), repr(obj))
+ self.assertTrue(isinstance(obj, Hashable), repr(obj))
def test_not_hashable(self):
for obj in self.error_expected:
Modified: python/branches/py3k/Lib/test/test_hashlib.py
==============================================================================
--- python/branches/py3k/Lib/test/test_hashlib.py (original)
+++ python/branches/py3k/Lib/test/test_hashlib.py Wed Jul 1 01:06:06 2009
@@ -36,7 +36,7 @@
except ValueError:
pass
else:
- self.assert_(0 == "hashlib didn't reject bogus hash name")
+ self.assertTrue(0 == "hashlib didn't reject bogus hash name")
def test_hexdigest(self):
for name in self.supported_hash_names:
Modified: python/branches/py3k/Lib/test/test_heapq.py
==============================================================================
--- python/branches/py3k/Lib/test/test_heapq.py (original)
+++ python/branches/py3k/Lib/test/test_heapq.py Wed Jul 1 01:06:06 2009
@@ -46,7 +46,7 @@
for pos, item in enumerate(heap):
if pos: # pos 0 has no parent
parentpos = (pos-1) >> 1
- self.assert_(heap[parentpos] <= item)
+ self.assertTrue(heap[parentpos] <= item)
def test_heapify(self):
for size in range(30):
Modified: python/branches/py3k/Lib/test/test_hmac.py
==============================================================================
--- python/branches/py3k/Lib/test/test_hmac.py (original)
+++ python/branches/py3k/Lib/test/test_hmac.py Wed Jul 1 01:06:06 2009
@@ -280,7 +280,7 @@
# Testing if attributes are of same type.
h1 = hmac.HMAC(b"key")
h2 = h1.copy()
- self.failUnless(h1.digest_cons == h2.digest_cons,
+ self.assertTrue(h1.digest_cons == h2.digest_cons,
"digest constructors don't match.")
self.assertEqual(type(h1.inner), type(h2.inner),
"Types of inner don't match.")
@@ -292,10 +292,10 @@
h1 = hmac.HMAC(b"key")
h2 = h1.copy()
# Using id() in case somebody has overridden __eq__/__ne__.
- self.failUnless(id(h1) != id(h2), "No real copy of the HMAC instance.")
- self.failUnless(id(h1.inner) != id(h2.inner),
+ self.assertTrue(id(h1) != id(h2), "No real copy of the HMAC instance.")
+ self.assertTrue(id(h1.inner) != id(h2.inner),
"No real copy of the attribute 'inner'.")
- self.failUnless(id(h1.outer) != id(h2.outer),
+ self.assertTrue(id(h1.outer) != id(h2.outer),
"No real copy of the attribute 'outer'.")
def test_equality(self):
Modified: python/branches/py3k/Lib/test/test_http_cookiejar.py
==============================================================================
--- python/branches/py3k/Lib/test/test_http_cookiejar.py (original)
+++ python/branches/py3k/Lib/test/test_http_cookiejar.py Wed Jul 1 01:06:06 2009
@@ -25,7 +25,7 @@
az = time2isoz()
bz = time2isoz(500000)
for text in (az, bz):
- self.assert_(re.search(r"^\d{4}-\d\d-\d\d \d\d:\d\d:\d\dZ$", text),
+ self.assertTrue(re.search(r"^\d{4}-\d\d-\d\d \d\d:\d\d:\d\dZ$", text),
"bad time2isoz format: %s %s" % (az, bz))
def test_http2time(self):
@@ -74,7 +74,7 @@
t2 = http2time(s.lower())
t3 = http2time(s.upper())
- self.assert_(t == t2 == t3 == test_t,
+ self.assertTrue(t == t2 == t3 == test_t,
"'%s' => %s, %s, %s (%s)" % (s, t, t2, t3, test_t))
def test_http2time_garbage(self):
@@ -90,7 +90,7 @@
'01-01-1980 00:61:00',
'01-01-1980 00:00:62',
]:
- self.assert_(http2time(test) is None,
+ self.assertTrue(http2time(test) is None,
"http2time(%s) is not None\n"
"http2time(test) %s" % (test, http2time(test))
)
@@ -332,8 +332,8 @@
]:
request = urllib.request.Request(url)
r = pol.domain_return_ok(domain, request)
- if ok: self.assert_(r)
- else: self.assert_(not r)
+ if ok: self.assertTrue(r)
+ else: self.assertTrue(not r)
def test_missing_value(self):
# missing = sign in Cookie: header is regarded by Mozilla as a missing
@@ -343,10 +343,10 @@
interact_netscape(c, "http://www.acme.com/", 'eggs')
interact_netscape(c, "http://www.acme.com/", '"spam"; path=/foo/')
cookie = c._cookies["www.acme.com"]["/"]["eggs"]
- self.assert_(cookie.value is None)
+ self.assertTrue(cookie.value is None)
self.assertEquals(cookie.name, "eggs")
cookie = c._cookies["www.acme.com"]['/foo/']['"spam"']
- self.assert_(cookie.value is None)
+ self.assertTrue(cookie.value is None)
self.assertEquals(cookie.name, '"spam"')
self.assertEquals(lwp_cookie_str(cookie), (
r'"spam"; path="/foo/"; domain="www.acme.com"; '
@@ -388,7 +388,7 @@
try:
cookie = c._cookies["www.example.com"]["/"]["ni"]
except KeyError:
- self.assert_(version is None) # didn't expect a stored cookie
+ self.assertTrue(version is None) # didn't expect a stored cookie
else:
self.assertEqual(cookie.version, version)
# 2965 cookies are unaffected
@@ -410,28 +410,28 @@
cookie = c._cookies[".acme.com"]["/"]["spam"]
self.assertEquals(cookie.domain, ".acme.com")
- self.assert_(cookie.domain_specified)
+ self.assertTrue(cookie.domain_specified)
self.assertEquals(cookie.port, DEFAULT_HTTP_PORT)
- self.assert_(not cookie.port_specified)
+ self.assertTrue(not cookie.port_specified)
# case is preserved
- self.assert_(cookie.has_nonstandard_attr("blArgh") and
+ self.assertTrue(cookie.has_nonstandard_attr("blArgh") and
not cookie.has_nonstandard_attr("blargh"))
cookie = c._cookies["www.acme.com"]["/"]["ni"]
self.assertEquals(cookie.domain, "www.acme.com")
- self.assert_(not cookie.domain_specified)
+ self.assertTrue(not cookie.domain_specified)
self.assertEquals(cookie.port, "80,8080")
- self.assert_(cookie.port_specified)
+ self.assertTrue(cookie.port_specified)
cookie = c._cookies["www.acme.com"]["/"]["nini"]
- self.assert_(cookie.port is None)
- self.assert_(not cookie.port_specified)
+ self.assertTrue(cookie.port is None)
+ self.assertTrue(not cookie.port_specified)
# invalid expires should not cause cookie to be dropped
foo = c._cookies["www.acme.com"]["/"]["foo"]
spam = c._cookies["www.acme.com"]["/"]["foo"]
- self.assert_(foo.expires is None)
- self.assert_(spam.expires is None)
+ self.assertTrue(foo.expires is None)
+ self.assertTrue(spam.expires is None)
def test_ns_parser_special_names(self):
# names such as 'expires' are not special in first name=value pair
@@ -441,8 +441,8 @@
interact_netscape(c, "http://www.acme.com/", 'version=eggs; spam=eggs')
cookies = c._cookies["www.acme.com"]["/"]
- self.assert_('expires' in cookies)
- self.assert_('version' in cookies)
+ self.assertTrue('expires' in cookies)
+ self.assertTrue('version' in cookies)
def test_expires(self):
# if expires is in future, keep cookie...
@@ -457,7 +457,7 @@
now)
h = interact_netscape(c, "http://www.acme.com/")
self.assertEquals(len(c), 1)
- self.assert_('spam="bar"' in h and "foo" not in h)
+ self.assertTrue('spam="bar"' in h and "foo" not in h)
# max-age takes precedence over expires, and zero max-age is request to
# delete both new cookie and any old matching cookie
@@ -478,7 +478,7 @@
self.assertEquals(len(c), 2)
c.clear_session_cookies()
self.assertEquals(len(c), 1)
- self.assert_('spam="bar"' in h)
+ self.assertTrue('spam="bar"' in h)
# XXX RFC 2965 expiry rules (some apply to V0 too)
@@ -488,39 +488,39 @@
c = CookieJar(pol)
interact_2965(c, "http://www.acme.com/", 'spam="bar"; Version="1"')
- self.assert_("/" in c._cookies["www.acme.com"])
+ self.assertTrue("/" in c._cookies["www.acme.com"])
c = CookieJar(pol)
interact_2965(c, "http://www.acme.com/blah", 'eggs="bar"; Version="1"')
- self.assert_("/" in c._cookies["www.acme.com"])
+ self.assertTrue("/" in c._cookies["www.acme.com"])
c = CookieJar(pol)
interact_2965(c, "http://www.acme.com/blah/rhubarb",
'eggs="bar"; Version="1"')
- self.assert_("/blah/" in c._cookies["www.acme.com"])
+ self.assertTrue("/blah/" in c._cookies["www.acme.com"])
c = CookieJar(pol)
interact_2965(c, "http://www.acme.com/blah/rhubarb/",
'eggs="bar"; Version="1"')
- self.assert_("/blah/rhubarb/" in c._cookies["www.acme.com"])
+ self.assertTrue("/blah/rhubarb/" in c._cookies["www.acme.com"])
# Netscape
c = CookieJar()
interact_netscape(c, "http://www.acme.com/", 'spam="bar"')
- self.assert_("/" in c._cookies["www.acme.com"])
+ self.assertTrue("/" in c._cookies["www.acme.com"])
c = CookieJar()
interact_netscape(c, "http://www.acme.com/blah", 'eggs="bar"')
- self.assert_("/" in c._cookies["www.acme.com"])
+ self.assertTrue("/" in c._cookies["www.acme.com"])
c = CookieJar()
interact_netscape(c, "http://www.acme.com/blah/rhubarb", 'eggs="bar"')
- self.assert_("/blah" in c._cookies["www.acme.com"])
+ self.assertTrue("/blah" in c._cookies["www.acme.com"])
c = CookieJar()
interact_netscape(c, "http://www.acme.com/blah/rhubarb/", 'eggs="bar"')
- self.assert_("/blah/rhubarb" in c._cookies["www.acme.com"])
+ self.assertTrue("/blah/rhubarb" in c._cookies["www.acme.com"])
def test_escape_path(self):
cases = [
@@ -589,14 +589,14 @@
self.assertEquals(request_host(req), "www.acme.com")
def test_is_HDN(self):
- self.assert_(is_HDN("foo.bar.com"))
- self.assert_(is_HDN("1foo2.3bar4.5com"))
- self.assert_(not is_HDN("192.168.1.1"))
- self.assert_(not is_HDN(""))
- self.assert_(not is_HDN("."))
- self.assert_(not is_HDN(".foo.bar.com"))
- self.assert_(not is_HDN("..foo"))
- self.assert_(not is_HDN("foo."))
+ self.assertTrue(is_HDN("foo.bar.com"))
+ self.assertTrue(is_HDN("1foo2.3bar4.5com"))
+ self.assertTrue(not is_HDN("192.168.1.1"))
+ self.assertTrue(not is_HDN(""))
+ self.assertTrue(not is_HDN("."))
+ self.assertTrue(not is_HDN(".foo.bar.com"))
+ self.assertTrue(not is_HDN("..foo"))
+ self.assertTrue(not is_HDN("foo."))
def test_reach(self):
self.assertEquals(reach("www.acme.com"), ".acme.com")
@@ -609,40 +609,40 @@
self.assertEquals(reach("192.168.0.1"), "192.168.0.1")
def test_domain_match(self):
- self.assert_(domain_match("192.168.1.1", "192.168.1.1"))
- self.assert_(not domain_match("192.168.1.1", ".168.1.1"))
- self.assert_(domain_match("x.y.com", "x.Y.com"))
- self.assert_(domain_match("x.y.com", ".Y.com"))
- self.assert_(not domain_match("x.y.com", "Y.com"))
- self.assert_(domain_match("a.b.c.com", ".c.com"))
- self.assert_(not domain_match(".c.com", "a.b.c.com"))
- self.assert_(domain_match("example.local", ".local"))
- self.assert_(not domain_match("blah.blah", ""))
- self.assert_(not domain_match("", ".rhubarb.rhubarb"))
- self.assert_(domain_match("", ""))
-
- self.assert_(user_domain_match("acme.com", "acme.com"))
- self.assert_(not user_domain_match("acme.com", ".acme.com"))
- self.assert_(user_domain_match("rhubarb.acme.com", ".acme.com"))
- self.assert_(user_domain_match("www.rhubarb.acme.com", ".acme.com"))
- self.assert_(user_domain_match("x.y.com", "x.Y.com"))
- self.assert_(user_domain_match("x.y.com", ".Y.com"))
- self.assert_(not user_domain_match("x.y.com", "Y.com"))
- self.assert_(user_domain_match("y.com", "Y.com"))
- self.assert_(not user_domain_match(".y.com", "Y.com"))
- self.assert_(user_domain_match(".y.com", ".Y.com"))
- self.assert_(user_domain_match("x.y.com", ".com"))
- self.assert_(not user_domain_match("x.y.com", "com"))
- self.assert_(not user_domain_match("x.y.com", "m"))
- self.assert_(not user_domain_match("x.y.com", ".m"))
- self.assert_(not user_domain_match("x.y.com", ""))
- self.assert_(not user_domain_match("x.y.com", "."))
- self.assert_(user_domain_match("192.168.1.1", "192.168.1.1"))
+ self.assertTrue(domain_match("192.168.1.1", "192.168.1.1"))
+ self.assertTrue(not domain_match("192.168.1.1", ".168.1.1"))
+ self.assertTrue(domain_match("x.y.com", "x.Y.com"))
+ self.assertTrue(domain_match("x.y.com", ".Y.com"))
+ self.assertTrue(not domain_match("x.y.com", "Y.com"))
+ self.assertTrue(domain_match("a.b.c.com", ".c.com"))
+ self.assertTrue(not domain_match(".c.com", "a.b.c.com"))
+ self.assertTrue(domain_match("example.local", ".local"))
+ self.assertTrue(not domain_match("blah.blah", ""))
+ self.assertTrue(not domain_match("", ".rhubarb.rhubarb"))
+ self.assertTrue(domain_match("", ""))
+
+ self.assertTrue(user_domain_match("acme.com", "acme.com"))
+ self.assertTrue(not user_domain_match("acme.com", ".acme.com"))
+ self.assertTrue(user_domain_match("rhubarb.acme.com", ".acme.com"))
+ self.assertTrue(user_domain_match("www.rhubarb.acme.com", ".acme.com"))
+ self.assertTrue(user_domain_match("x.y.com", "x.Y.com"))
+ self.assertTrue(user_domain_match("x.y.com", ".Y.com"))
+ self.assertTrue(not user_domain_match("x.y.com", "Y.com"))
+ self.assertTrue(user_domain_match("y.com", "Y.com"))
+ self.assertTrue(not user_domain_match(".y.com", "Y.com"))
+ self.assertTrue(user_domain_match(".y.com", ".Y.com"))
+ self.assertTrue(user_domain_match("x.y.com", ".com"))
+ self.assertTrue(not user_domain_match("x.y.com", "com"))
+ self.assertTrue(not user_domain_match("x.y.com", "m"))
+ self.assertTrue(not user_domain_match("x.y.com", ".m"))
+ self.assertTrue(not user_domain_match("x.y.com", ""))
+ self.assertTrue(not user_domain_match("x.y.com", "."))
+ self.assertTrue(user_domain_match("192.168.1.1", "192.168.1.1"))
# not both HDNs, so must string-compare equal to match
- self.assert_(not user_domain_match("192.168.1.1", ".168.1.1"))
- self.assert_(not user_domain_match("192.168.1.1", "."))
+ self.assertTrue(not user_domain_match("192.168.1.1", ".168.1.1"))
+ self.assertTrue(not user_domain_match("192.168.1.1", "."))
# empty string is a special case
- self.assert_(not user_domain_match("192.168.1.1", ""))
+ self.assertTrue(not user_domain_match("192.168.1.1", ""))
def test_wrong_domain(self):
# Cookies whose effective request-host name does not domain-match the
@@ -789,7 +789,7 @@
self.assertEquals(len(c), 2)
# ... and check is doesn't get returned
c.add_cookie_header(req)
- self.assert_(not req.has_header("Cookie"))
+ self.assertTrue(not req.has_header("Cookie"))
def test_domain_block(self):
pol = DefaultCookiePolicy(
@@ -813,7 +813,7 @@
self.assertEquals(len(c), 1)
req = urllib.request.Request("http://www.roadrunner.net/")
c.add_cookie_header(req)
- self.assert_((req.has_header("Cookie") and
+ self.assertTrue((req.has_header("Cookie") and
req.has_header("Cookie2")))
c.clear()
@@ -829,7 +829,7 @@
self.assertEquals(len(c), 2)
# ... and check is doesn't get returned
c.add_cookie_header(req)
- self.assert_(not req.has_header("Cookie"))
+ self.assertTrue(not req.has_header("Cookie"))
def test_secure(self):
for ns in True, False:
@@ -847,10 +847,10 @@
url = "http://www.acme.com/"
int(c, url, "foo1=bar%s%s" % (vs, whitespace))
int(c, url, "foo2=bar%s; secure%s" % (vs, whitespace))
- self.assert_(
+ self.assertTrue(
not c._cookies["www.acme.com"]["/"]["foo1"].secure,
"non-secure cookie registered secure")
- self.assert_(
+ self.assertTrue(
c._cookies["www.acme.com"]["/"]["foo2"].secure,
"secure cookie registered non-secure")
@@ -868,7 +868,7 @@
req = urllib.request.Request(url)
self.assertEquals(len(c), 1)
c.add_cookie_header(req)
- self.assert_(req.has_header("Cookie"))
+ self.assertTrue(req.has_header("Cookie"))
def test_domain_mirror(self):
pol = DefaultCookiePolicy(rfc2965=True)
@@ -877,21 +877,21 @@
url = "http://foo.bar.com/"
interact_2965(c, url, "spam=eggs; Version=1")
h = interact_2965(c, url)
- self.assert_("Domain" not in h,
+ self.assertTrue("Domain" not in h,
"absent domain returned with domain present")
c = CookieJar(pol)
url = "http://foo.bar.com/"
interact_2965(c, url, 'spam=eggs; Version=1; Domain=.bar.com')
h = interact_2965(c, url)
- self.assert_('$Domain=".bar.com"' in h, "domain not returned")
+ self.assertTrue('$Domain=".bar.com"' in h, "domain not returned")
c = CookieJar(pol)
url = "http://foo.bar.com/"
# note missing initial dot in Domain
interact_2965(c, url, 'spam=eggs; Version=1; Domain=bar.com')
h = interact_2965(c, url)
- self.assert_('$Domain="bar.com"' in h, "domain not returned")
+ self.assertTrue('$Domain="bar.com"' in h, "domain not returned")
def test_path_mirror(self):
pol = DefaultCookiePolicy(rfc2965=True)
@@ -900,14 +900,14 @@
url = "http://foo.bar.com/"
interact_2965(c, url, "spam=eggs; Version=1")
h = interact_2965(c, url)
- self.assert_("Path" not in h,
+ self.assertTrue("Path" not in h,
"absent path returned with path present")
c = CookieJar(pol)
url = "http://foo.bar.com/"
interact_2965(c, url, 'spam=eggs; Version=1; Path=/')
h = interact_2965(c, url)
- self.assert_('$Path="/"' in h, "path not returned")
+ self.assertTrue('$Path="/"' in h, "path not returned")
def test_port_mirror(self):
pol = DefaultCookiePolicy(rfc2965=True)
@@ -916,28 +916,28 @@
url = "http://foo.bar.com/"
interact_2965(c, url, "spam=eggs; Version=1")
h = interact_2965(c, url)
- self.assert_("Port" not in h,
+ self.assertTrue("Port" not in h,
"absent port returned with port present")
c = CookieJar(pol)
url = "http://foo.bar.com/"
interact_2965(c, url, "spam=eggs; Version=1; Port")
h = interact_2965(c, url)
- self.assert_(re.search("\$Port([^=]|$)", h),
+ self.assertTrue(re.search("\$Port([^=]|$)", h),
"port with no value not returned with no value")
c = CookieJar(pol)
url = "http://foo.bar.com/"
interact_2965(c, url, 'spam=eggs; Version=1; Port="80"')
h = interact_2965(c, url)
- self.assert_('$Port="80"' in h,
+ self.assertTrue('$Port="80"' in h,
"port with single value not returned with single value")
c = CookieJar(pol)
url = "http://foo.bar.com/"
interact_2965(c, url, 'spam=eggs; Version=1; Port="80,8080"')
h = interact_2965(c, url)
- self.assert_('$Port="80,8080"' in h,
+ self.assertTrue('$Port="80,8080"' in h,
"port with multiple values not returned with multiple "
"values")
@@ -948,7 +948,7 @@
'Comment="does anybody read these?"; '
'CommentURL="http://foo.bar.net/comment.html"')
h = interact_2965(c, url)
- self.assert_(
+ self.assertTrue(
"Comment" not in h,
"Comment or CommentURL cookie-attributes returned to server")
@@ -977,7 +977,7 @@
for i in range(4):
i = 0
for c in cs:
- self.assert_(isinstance(c, Cookie))
+ self.assertTrue(isinstance(c, Cookie))
self.assertEquals(c.version, versions[i])
self.assertEquals(c.name, names[i])
self.assertEquals(c.domain, domains[i])
@@ -1030,7 +1030,7 @@
headers = ["Set-Cookie: c=foo; expires=Foo Bar 12 33:22:11 2000"]
c = cookiejar_from_cookie_headers(headers)
cookie = c._cookies["www.example.com"]["/"]["c"]
- self.assert_(cookie.expires is None)
+ self.assertTrue(cookie.expires is None)
class LWPCookieTests(TestCase):
@@ -1104,7 +1104,7 @@
c.add_cookie_header(req)
h = req.get_header("Cookie")
- self.assert_("PART_NUMBER=ROCKET_LAUNCHER_0001" in h and
+ self.assertTrue("PART_NUMBER=ROCKET_LAUNCHER_0001" in h and
"CUSTOMER=WILE_E_COYOTE" in h)
headers.append('Set-Cookie: SHIPPING=FEDEX; path=/foo')
@@ -1115,7 +1115,7 @@
c.add_cookie_header(req)
h = req.get_header("Cookie")
- self.assert_("PART_NUMBER=ROCKET_LAUNCHER_0001" in h and
+ self.assertTrue("PART_NUMBER=ROCKET_LAUNCHER_0001" in h and
"CUSTOMER=WILE_E_COYOTE" in h and
"SHIPPING=FEDEX" not in h)
@@ -1123,7 +1123,7 @@
c.add_cookie_header(req)
h = req.get_header("Cookie")
- self.assert_(("PART_NUMBER=ROCKET_LAUNCHER_0001" in h and
+ self.assertTrue(("PART_NUMBER=ROCKET_LAUNCHER_0001" in h and
"CUSTOMER=WILE_E_COYOTE" in h and
h.startswith("SHIPPING=FEDEX;")))
@@ -1174,7 +1174,7 @@
req = urllib.request.Request("http://www.acme.com/ammo")
c.add_cookie_header(req)
- self.assert_(re.search(r"PART_NUMBER=RIDING_ROCKET_0023;\s*"
+ self.assertTrue(re.search(r"PART_NUMBER=RIDING_ROCKET_0023;\s*"
"PART_NUMBER=ROCKET_LAUNCHER_0001",
req.get_header("Cookie")))
@@ -1209,7 +1209,7 @@
cookie = interact_2965(
c, 'http://www.acme.com/acme/login',
'Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"')
- self.assert_(not cookie)
+ self.assertTrue(not cookie)
#
# 3. User Agent -> Server
@@ -1231,7 +1231,7 @@
cookie = interact_2965(c, 'http://www.acme.com/acme/pickitem',
'Part_Number="Rocket_Launcher_0001"; '
'Version="1"; Path="/acme"');
- self.assert_(re.search(
+ self.assertTrue(re.search(
r'^\$Version="?1"?; Customer="?WILE_E_COYOTE"?; \$Path="/acme"$',
cookie))
@@ -1256,10 +1256,10 @@
cookie = interact_2965(c, "http://www.acme.com/acme/shipping",
'Shipping="FedEx"; Version="1"; Path="/acme"')
- self.assert_(re.search(r'^\$Version="?1"?;', cookie))
- self.assert_(re.search(r'Part_Number="?Rocket_Launcher_0001"?;'
+ self.assertTrue(re.search(r'^\$Version="?1"?;', cookie))
+ self.assertTrue(re.search(r'Part_Number="?Rocket_Launcher_0001"?;'
'\s*\$Path="\/acme"', cookie))
- self.assert_(re.search(r'Customer="?WILE_E_COYOTE"?;\s*\$Path="\/acme"',
+ self.assertTrue(re.search(r'Customer="?WILE_E_COYOTE"?;\s*\$Path="\/acme"',
cookie))
#
@@ -1281,7 +1281,7 @@
# Transaction is complete.
cookie = interact_2965(c, "http://www.acme.com/acme/process")
- self.assert_(
+ self.assertTrue(
re.search(r'Shipping="?FedEx"?;\s*\$Path="\/acme"', cookie) and
"WILE_E_COYOTE" in cookie)
@@ -1330,7 +1330,7 @@
# than once.
cookie = interact_2965(c, "http://www.acme.com/acme/ammo/...")
- self.assert_(
+ self.assertTrue(
re.search(r"Riding_Rocket_0023.*Rocket_Launcher_0001", cookie))
# A subsequent request by the user agent to the (same) server for a URL of
@@ -1343,7 +1343,7 @@
# the server.
cookie = interact_2965(c, "http://www.acme.com/acme/parts/")
- self.assert_("Rocket_Launcher_0001" in cookie and
+ self.assertTrue("Rocket_Launcher_0001" in cookie and
"Riding_Rocket_0023" not in cookie)
def test_rejection(self):
@@ -1357,7 +1357,7 @@
# illegal domain (no embedded dots)
cookie = interact_2965(c, "http://www.acme.com",
'foo=bar; domain=".com"; version=1')
- self.assert_(not c)
+ self.assertTrue(not c)
# legal domain
cookie = interact_2965(c, "http://www.acme.com",
@@ -1449,11 +1449,11 @@
c, "http://www.acme.com/foo%2f%25/<<%0anew\345/\346\370\345",
'bar=baz; path="/foo/"; version=1');
version_re = re.compile(r'^\$version=\"?1\"?', re.I)
- self.assert_("foo=bar" in cookie and version_re.search(cookie))
+ self.assertTrue("foo=bar" in cookie and version_re.search(cookie))
cookie = interact_2965(
c, "http://www.acme.com/foo/%25/<<%0anew\345/\346\370\345")
- self.assert_(not cookie)
+ self.assertTrue(not cookie)
# unicode URL doesn't raise exception
cookie = interact_2965(c, "http://www.acme.com/\xfc")
@@ -1493,11 +1493,11 @@
new_c = save_and_restore(c, True)
self.assertEquals(len(new_c), 6) # none discarded
- self.assert_("name='foo1', value='bar'" in repr(new_c))
+ self.assertTrue("name='foo1', value='bar'" in repr(new_c))
new_c = save_and_restore(c, False)
self.assertEquals(len(new_c), 4) # 2 of them discarded on save
- self.assert_("name='foo1', value='bar'" in repr(new_c))
+ self.assertTrue("name='foo1', value='bar'" in repr(new_c))
def test_netscape_misc(self):
# Some additional Netscape cookies tests.
@@ -1519,7 +1519,7 @@
req = urllib.request.Request("http://foo.bar.acme.com/foo")
c.add_cookie_header(req)
- self.assert_(
+ self.assertTrue(
"PART_NUMBER=3,4" in req.get_header("Cookie") and
"Customer=WILE_E_COYOTE" in req.get_header("Cookie"))
@@ -1530,11 +1530,11 @@
"foo1=bar; PORT; Discard; Version=1;")
cookie = interact_2965(c, "http://example/",
'foo2=bar; domain=".local"; Version=1')
- self.assert_("foo1=bar" in cookie)
+ self.assertTrue("foo1=bar" in cookie)
interact_2965(c, "http://example/", 'foo3=bar; Version=1')
cookie = interact_2965(c, "http://example/")
- self.assert_("foo2=bar" in cookie and len(c) == 3)
+ self.assertTrue("foo2=bar" in cookie and len(c) == 3)
def test_intranet_domains_ns(self):
c = CookieJar(DefaultCookiePolicy(rfc2965 = False))
@@ -1542,10 +1542,10 @@
cookie = interact_netscape(c, "http://example/",
'foo2=bar; domain=.local')
self.assertEquals(len(c), 2)
- self.assert_("foo1=bar" in cookie)
+ self.assertTrue("foo1=bar" in cookie)
cookie = interact_netscape(c, "http://example/")
- self.assert_("foo2=bar" in cookie)
+ self.assertTrue("foo2=bar" in cookie)
self.assertEquals(len(c), 2)
def test_empty_path(self):
@@ -1614,7 +1614,7 @@
key = "%s_after" % cookie.value
counter[key] = counter[key] + 1
- self.assert_(not (
+ self.assertTrue(not (
# a permanent cookie got lost accidently
counter["perm_after"] != counter["perm_before"] or
# a session cookie hasn't been cleared
Modified: python/branches/py3k/Lib/test/test_httplib.py
==============================================================================
--- python/branches/py3k/Lib/test/test_httplib.py (original)
+++ python/branches/py3k/Lib/test/test_httplib.py Wed Jul 1 01:06:06 2009
@@ -265,7 +265,7 @@
# and into the socket.
# default -- use global socket timeout
- self.assert_(socket.getdefaulttimeout() is None)
+ self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
try:
httpConn = client.HTTPConnection(HOST, TimeoutTest.PORT)
@@ -276,7 +276,7 @@
httpConn.close()
# no timeout -- do not use global socket default
- self.assert_(socket.getdefaulttimeout() is None)
+ self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
try:
httpConn = client.HTTPConnection(HOST, TimeoutTest.PORT,
Modified: python/branches/py3k/Lib/test/test_httpservers.py
==============================================================================
--- python/branches/py3k/Lib/test/test_httpservers.py (original)
+++ python/branches/py3k/Lib/test/test_httpservers.py Wed Jul 1 01:06:06 2009
@@ -217,9 +217,9 @@
def check_status_and_reason(self, response, status, data=None):
body = response.read()
- self.assert_(response)
+ self.assertTrue(response)
self.assertEquals(response.status, status)
- self.assert_(response.reason != None)
+ self.assertTrue(response.reason != None)
if data:
self.assertEqual(data, body)
Modified: python/branches/py3k/Lib/test/test_imp.py
==============================================================================
--- python/branches/py3k/Lib/test/test_imp.py (original)
+++ python/branches/py3k/Lib/test/test_imp.py Wed Jul 1 01:06:06 2009
@@ -12,7 +12,7 @@
"""Very basic test of import lock functions."""
def verify_lock_state(self, expected):
- self.failUnlessEqual(imp.lock_held(), expected,
+ self.assertEqual(imp.lock_held(), expected,
"expected imp.lock_held() to be %r" % expected)
def testLock(self):
LOOPS = 50
Modified: python/branches/py3k/Lib/test/test_import.py
==============================================================================
--- python/branches/py3k/Lib/test/test_import.py (original)
+++ python/branches/py3k/Lib/test/test_import.py Wed Jul 1 01:06:06 2009
@@ -145,12 +145,12 @@
# import x.y.z binds x in the current namespace
import test as x
import test.support
- self.assert_(x is test, x.__name__)
- self.assert_(hasattr(test.support, "__file__"))
+ self.assertTrue(x is test, x.__name__)
+ self.assertTrue(hasattr(test.support, "__file__"))
# import x.y.z as w binds z as w
import test.support as y
- self.assert_(y is test.support, y.__name__)
+ self.assertTrue(y is test.support, y.__name__)
def test_import_initless_directory_warning(self):
with warnings.catch_warnings():
@@ -168,7 +168,7 @@
sys.path.insert(0, os.curdir)
try:
mod = __import__(TESTFN)
- self.assert_(TESTFN in sys.modules, "expected module in sys.modules")
+ self.assertTrue(TESTFN in sys.modules, "expected module in sys.modules")
self.assertEquals(mod.a, 1, "module has wrong attribute values")
self.assertEquals(mod.b, 2, "module has wrong attribute values")
@@ -185,7 +185,7 @@
self.assertRaises(ZeroDivisionError, imp.reload, mod)
# But we still expect the module to be in sys.modules.
mod = sys.modules.get(TESTFN)
- self.failIf(mod is None, "expected module to still be in sys.modules")
+ self.assertFalse(mod is None, "expected module to still be in sys.modules")
# We should have replaced a w/ 10, but the old b value should
# stick.
@@ -207,12 +207,12 @@
sys.path.insert(0, os.curdir)
try:
mod = __import__(TESTFN)
- self.failUnless(mod.__file__.endswith('.py'))
+ self.assertTrue(mod.__file__.endswith('.py'))
os.remove(source)
del sys.modules[TESTFN]
mod = __import__(TESTFN)
ext = mod.__file__[-4:]
- self.failUnless(ext in ('.pyc', '.pyo'), ext)
+ self.assertTrue(ext in ('.pyc', '.pyo'), ext)
finally:
sys.path.pop(0)
remove_files(TESTFN)
Modified: python/branches/py3k/Lib/test/test_importhooks.py
==============================================================================
--- python/branches/py3k/Lib/test/test_importhooks.py (original)
+++ python/branches/py3k/Lib/test/test_importhooks.py Wed Jul 1 01:06:06 2009
@@ -177,7 +177,7 @@
TestImporter.modules['reloadmodule'] = (False, test_co)
import reloadmodule
- self.failIf(hasattr(reloadmodule,'reloaded'))
+ self.assertFalse(hasattr(reloadmodule,'reloaded'))
import hooktestpackage.newrel
self.assertEqual(hooktestpackage.newrel.get_name(),
Modified: python/branches/py3k/Lib/test/test_index.py
==============================================================================
--- python/branches/py3k/Lib/test/test_index.py (original)
+++ python/branches/py3k/Lib/test/test_index.py Wed Jul 1 01:06:06 2009
@@ -59,10 +59,10 @@
def test_error(self):
self.o.ind = 'dumb'
self.n.ind = 'bad'
- self.failUnlessRaises(TypeError, operator.index, self.o)
- self.failUnlessRaises(TypeError, operator.index, self.n)
- self.failUnlessRaises(TypeError, slice(self.o).indices, 0)
- self.failUnlessRaises(TypeError, slice(self.n).indices, 0)
+ self.assertRaises(TypeError, operator.index, self.o)
+ self.assertRaises(TypeError, operator.index, self.n)
+ self.assertRaises(TypeError, slice(self.o).indices, 0)
+ self.assertRaises(TypeError, slice(self.n).indices, 0)
class SeqTestCase(unittest.TestCase):
@@ -114,11 +114,11 @@
self.o.ind = 'dumb'
self.n.ind = 'bad'
indexobj = lambda x, obj: obj.seq[x]
- self.failUnlessRaises(TypeError, indexobj, self.o, self)
- self.failUnlessRaises(TypeError, indexobj, self.n, self)
+ self.assertRaises(TypeError, indexobj, self.o, self)
+ self.assertRaises(TypeError, indexobj, self.n, self)
sliceobj = lambda x, obj: obj.seq[x:]
- self.failUnlessRaises(TypeError, sliceobj, self.o, self)
- self.failUnlessRaises(TypeError, sliceobj, self.n, self)
+ self.assertRaises(TypeError, sliceobj, self.o, self)
+ self.assertRaises(TypeError, sliceobj, self.n, self)
class ListTestCase(SeqTestCase):
@@ -151,7 +151,7 @@
lst = [5, 6, 7, 8, 9, 11]
l2 = lst.__imul__(self.n)
- self.assert_(l2 is lst)
+ self.assertTrue(l2 is lst)
self.assertEqual(lst, [5, 6, 7, 8, 9, 11] * 3)
@@ -188,8 +188,8 @@
(0, maxsize, 1))
def test_sequence_repeat(self):
- self.failUnlessRaises(OverflowError, lambda: "a" * self.pos)
- self.failUnlessRaises(OverflowError, lambda: "a" * self.neg)
+ self.assertRaises(OverflowError, lambda: "a" * self.pos)
+ self.assertRaises(OverflowError, lambda: "a" * self.neg)
def test_main():
Modified: python/branches/py3k/Lib/test/test_inspect.py
==============================================================================
--- python/branches/py3k/Lib/test/test_inspect.py (original)
+++ python/branches/py3k/Lib/test/test_inspect.py Wed Jul 1 01:06:06 2009
@@ -52,13 +52,13 @@
def istest(self, predicate, exp):
obj = eval(exp)
- self.failUnless(predicate(obj), '%s(%s)' % (predicate.__name__, exp))
+ self.assertTrue(predicate(obj), '%s(%s)' % (predicate.__name__, exp))
for other in self.predicates - set([predicate]):
if predicate == inspect.isgeneratorfunction and\
other == inspect.isfunction:
continue
- self.failIf(other(obj), 'not %s(%s)' % (other.__name__, exp))
+ self.assertFalse(other(obj), 'not %s(%s)' % (other.__name__, exp))
def generator_function_example(self):
for i in range(2):
@@ -91,15 +91,15 @@
self.istest(inspect.isgetsetdescriptor,
'type(tb.tb_frame).f_locals')
else:
- self.failIf(inspect.isgetsetdescriptor(type(tb.tb_frame).f_locals))
+ self.assertFalse(inspect.isgetsetdescriptor(type(tb.tb_frame).f_locals))
if hasattr(types, 'MemberDescriptorType'):
self.istest(inspect.ismemberdescriptor, 'datetime.timedelta.days')
else:
- self.failIf(inspect.ismemberdescriptor(datetime.timedelta.days))
+ self.assertFalse(inspect.ismemberdescriptor(datetime.timedelta.days))
def test_isroutine(self):
- self.assert_(inspect.isroutine(mod.spam))
- self.assert_(inspect.isroutine([].count))
+ self.assertTrue(inspect.isroutine(mod.spam))
+ self.assertTrue(inspect.isroutine([].count))
def test_isclass(self):
self.istest(inspect.isclass, 'mod.StupidGit')
@@ -117,8 +117,8 @@
x = C()
x.a = 42
members = dict(inspect.getmembers(x))
- self.assert_('a' in members)
- self.assert_('b' not in members)
+ self.assertTrue('a' in members)
+ self.assertTrue('b' not in members)
class TestInterpreterStack(IsTestBase):
@@ -132,7 +132,7 @@
self.istest(inspect.isframe, 'mod.fr')
def test_stack(self):
- self.assert_(len(mod.st) >= 5)
+ self.assertTrue(len(mod.st) >= 5)
self.assertEqual(revise(*mod.st[0][1:]),
(modfile, 16, 'eggs', [' st = inspect.stack()\n'], 0))
self.assertEqual(revise(*mod.st[1][1:]),
@@ -449,25 +449,25 @@
datablob = '1'
attrs = attrs_wo_objs(A)
- self.assert_(('s', 'static method', A) in attrs, 'missing static method')
- self.assert_(('c', 'class method', A) in attrs, 'missing class method')
- self.assert_(('p', 'property', A) in attrs, 'missing property')
- self.assert_(('m', 'method', A) in attrs,
+ self.assertTrue(('s', 'static method', A) in attrs, 'missing static method')
+ self.assertTrue(('c', 'class method', A) in attrs, 'missing class method')
+ self.assertTrue(('p', 'property', A) in attrs, 'missing property')
+ self.assertTrue(('m', 'method', A) in attrs,
'missing plain method: %r' % attrs)
- self.assert_(('m1', 'method', A) in attrs, 'missing plain method')
- self.assert_(('datablob', 'data', A) in attrs, 'missing data')
+ self.assertTrue(('m1', 'method', A) in attrs, 'missing plain method')
+ self.assertTrue(('datablob', 'data', A) in attrs, 'missing data')
class B(A):
def m(self): pass
attrs = attrs_wo_objs(B)
- self.assert_(('s', 'static method', A) in attrs, 'missing static method')
- self.assert_(('c', 'class method', A) in attrs, 'missing class method')
- self.assert_(('p', 'property', A) in attrs, 'missing property')
- self.assert_(('m', 'method', B) in attrs, 'missing plain method')
- self.assert_(('m1', 'method', A) in attrs, 'missing plain method')
- self.assert_(('datablob', 'data', A) in attrs, 'missing data')
+ self.assertTrue(('s', 'static method', A) in attrs, 'missing static method')
+ self.assertTrue(('c', 'class method', A) in attrs, 'missing class method')
+ self.assertTrue(('p', 'property', A) in attrs, 'missing property')
+ self.assertTrue(('m', 'method', B) in attrs, 'missing plain method')
+ self.assertTrue(('m1', 'method', A) in attrs, 'missing plain method')
+ self.assertTrue(('datablob', 'data', A) in attrs, 'missing data')
class C(A):
@@ -476,24 +476,24 @@
def c(self): pass
attrs = attrs_wo_objs(C)
- self.assert_(('s', 'static method', A) in attrs, 'missing static method')
- self.assert_(('c', 'method', C) in attrs, 'missing plain method')
- self.assert_(('p', 'property', A) in attrs, 'missing property')
- self.assert_(('m', 'method', C) in attrs, 'missing plain method')
- self.assert_(('m1', 'method', A) in attrs, 'missing plain method')
- self.assert_(('datablob', 'data', A) in attrs, 'missing data')
+ self.assertTrue(('s', 'static method', A) in attrs, 'missing static method')
+ self.assertTrue(('c', 'method', C) in attrs, 'missing plain method')
+ self.assertTrue(('p', 'property', A) in attrs, 'missing property')
+ self.assertTrue(('m', 'method', C) in attrs, 'missing plain method')
+ self.assertTrue(('m1', 'method', A) in attrs, 'missing plain method')
+ self.assertTrue(('datablob', 'data', A) in attrs, 'missing data')
class D(B, C):
def m1(self): pass
attrs = attrs_wo_objs(D)
- self.assert_(('s', 'static method', A) in attrs, 'missing static method')
- self.assert_(('c', 'method', C) in attrs, 'missing plain method')
- self.assert_(('p', 'property', A) in attrs, 'missing property')
- self.assert_(('m', 'method', B) in attrs, 'missing plain method')
- self.assert_(('m1', 'method', D) in attrs, 'missing plain method')
- self.assert_(('datablob', 'data', A) in attrs, 'missing data')
+ self.assertTrue(('s', 'static method', A) in attrs, 'missing static method')
+ self.assertTrue(('c', 'method', C) in attrs, 'missing plain method')
+ self.assertTrue(('p', 'property', A) in attrs, 'missing property')
+ self.assertTrue(('m', 'method', B) in attrs, 'missing plain method')
+ self.assertTrue(('m1', 'method', D) in attrs, 'missing plain method')
+ self.assertTrue(('datablob', 'data', A) in attrs, 'missing data')
def test_main():
run_unittest(TestDecorators, TestRetrievingSourceCode, TestOneliners,
Modified: python/branches/py3k/Lib/test/test_int.py
==============================================================================
--- python/branches/py3k/Lib/test/test_int.py (original)
+++ python/branches/py3k/Lib/test/test_int.py Wed Jul 1 01:06:06 2009
@@ -52,15 +52,15 @@
s = repr(-1-sys.maxsize)
x = int(s)
self.assertEqual(x+1, -sys.maxsize)
- self.assert_(isinstance(x, int))
+ self.assertTrue(isinstance(x, int))
# should return long
self.assertEqual(int(s[1:]), sys.maxsize+1)
# should return long
x = int(1e100)
- self.assert_(isinstance(x, int))
+ self.assertTrue(isinstance(x, int))
x = int(-1e100)
- self.assert_(isinstance(x, int))
+ self.assertTrue(isinstance(x, int))
# SF bug 434186: 0x80000000/2 != 0x80000000>>1.
@@ -78,7 +78,7 @@
self.assertRaises(ValueError, int, '123\x00 245', 20)
x = int('1' * 600)
- self.assert_(isinstance(x, int))
+ self.assertTrue(isinstance(x, int))
self.assertRaises(TypeError, int, 1, 12)
@@ -96,8 +96,8 @@
self.assertRaises(ValueError, int, "0b", 0)
# Bug #3236: Return small longs from PyLong_FromString
- self.assert_(int("10") is 10)
- self.assert_(int("-1") is -1)
+ self.assertTrue(int("10") is 10)
+ self.assertTrue(int("-1") is -1)
# SF bug 1334662: int(string, base) wrong answers
# Various representations of 2**32 evaluated to 0
Modified: python/branches/py3k/Lib/test/test_io.py
==============================================================================
--- python/branches/py3k/Lib/test/test_io.py (original)
+++ python/branches/py3k/Lib/test/test_io.py Wed Jul 1 01:06:06 2009
@@ -391,7 +391,7 @@
with self.open(support.TESTFN, "ab") as f:
self.assertEqual(f.tell(), 3)
with self.open(support.TESTFN, "a") as f:
- self.assert_(f.tell() > 0)
+ self.assertTrue(f.tell() > 0)
def test_destructor(self):
record = []
@@ -509,7 +509,7 @@
wr = weakref.ref(f)
del f
support.gc_collect()
- self.assert_(wr() is None, wr)
+ self.assertTrue(wr() is None, wr)
with self.open(support.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"abcxxx")
@@ -615,8 +615,8 @@
if s:
# The destructor *may* have printed an unraisable error, check it
self.assertEqual(len(s.splitlines()), 1)
- self.assert_(s.startswith("Exception IOError: "), s)
- self.assert_(s.endswith(" ignored"), s)
+ self.assertTrue(s.startswith("Exception IOError: "), s)
+ self.assertTrue(s.endswith(" ignored"), s)
def test_repr(self):
raw = self.MockRawIO()
@@ -713,7 +713,7 @@
self.assertEquals(b"e", bufio.read(1))
self.assertEquals(b"fg", bufio.read())
self.assertEquals(b"", bufio.peek(1))
- self.assert_(None is bufio.read())
+ self.assertTrue(None is bufio.read())
self.assertEquals(b"", bufio.read())
def test_read_past_eof(self):
@@ -815,7 +815,7 @@
wr = weakref.ref(f)
del f
support.gc_collect()
- self.assert_(wr() is None, wr)
+ self.assertTrue(wr() is None, wr)
class PyBufferedReaderTest(BufferedReaderTest):
tp = pyio.BufferedReader
@@ -864,7 +864,7 @@
flushed = b"".join(writer._write_stack)
# At least (total - 8) bytes were implicitly flushed, perhaps more
# depending on the implementation.
- self.assert_(flushed.startswith(contents[:-8]), flushed)
+ self.assertTrue(flushed.startswith(contents[:-8]), flushed)
def check_writes(self, intermediate_func):
# Lots of writes, test the flushed output is as expected.
@@ -1075,7 +1075,7 @@
wr = weakref.ref(f)
del f
support.gc_collect()
- self.assert_(wr() is None, wr)
+ self.assertTrue(wr() is None, wr)
with self.open(support.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"123xxx")
@@ -1565,7 +1565,7 @@
t = self.TextIOWrapper(b, encoding="utf8")
self.assertEqual(t.encoding, "utf8")
t = self.TextIOWrapper(b)
- self.assert_(t.encoding is not None)
+ self.assertTrue(t.encoding is not None)
codecs.lookup(t.encoding)
def test_encoding_errors_reading(self):
@@ -1735,8 +1735,8 @@
if s:
# The destructor *may* have printed an unraisable error, check it
self.assertEqual(len(s.splitlines()), 1)
- self.assert_(s.startswith("Exception IOError: "), s)
- self.assert_(s.endswith(" ignored"), s)
+ self.assertTrue(s.startswith("Exception IOError: "), s)
+ self.assertTrue(s.endswith(" ignored"), s)
# Systematic tests of the text I/O API
@@ -2054,7 +2054,7 @@
wr = weakref.ref(t)
del t
support.gc_collect()
- self.assert_(wr() is None, wr)
+ self.assertTrue(wr() is None, wr)
with self.open(support.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"456def")
@@ -2278,7 +2278,7 @@
wr = weakref.ref(c)
del c, b
support.gc_collect()
- self.assert_(wr() is None, wr)
+ self.assertTrue(wr() is None, wr)
def test_abcs(self):
# Test the visible base classes are ABCs.
Modified: python/branches/py3k/Lib/test/test_ioctl.py
==============================================================================
--- python/branches/py3k/Lib/test/test_ioctl.py (original)
+++ python/branches/py3k/Lib/test/test_ioctl.py Wed Jul 1 01:06:06 2009
@@ -24,7 +24,7 @@
tty = open("/dev/tty", "r")
r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ")
rpgrp = struct.unpack("i", r)[0]
- self.assert_(rpgrp in ids, "%s not in %s" % (rpgrp, ids))
+ self.assertTrue(rpgrp in ids, "%s not in %s" % (rpgrp, ids))
def test_ioctl_mutate(self):
import array
@@ -34,7 +34,7 @@
r = fcntl.ioctl(tty, termios.TIOCGPGRP, buf, 1)
rpgrp = buf[0]
self.assertEquals(r, 0)
- self.assert_(rpgrp in ids, "%s not in %s" % (rpgrp, ids))
+ self.assertTrue(rpgrp in ids, "%s not in %s" % (rpgrp, ids))
def test_ioctl_signed_unsigned_code_param(self):
if not pty:
Modified: python/branches/py3k/Lib/test/test_iter.py
==============================================================================
--- python/branches/py3k/Lib/test/test_iter.py (original)
+++ python/branches/py3k/Lib/test/test_iter.py Wed Jul 1 01:06:06 2009
@@ -75,7 +75,7 @@
seq = list(range(10))
it = iter(seq)
it2 = iter(it)
- self.assert_(it is it2)
+ self.assertTrue(it is it2)
# Test that for loops over iterators work
def test_iter_for_loop(self):
@@ -542,23 +542,23 @@
def test_in_and_not_in(self):
for sc5 in IteratingSequenceClass(5), SequenceClass(5):
for i in range(5):
- self.assert_(i in sc5)
+ self.assertTrue(i in sc5)
for i in "abc", -1, 5, 42.42, (3, 4), [], {1: 1}, 3-12j, sc5:
- self.assert_(i not in sc5)
+ self.assertTrue(i not in sc5)
self.assertRaises(TypeError, lambda: 3 in 12)
self.assertRaises(TypeError, lambda: 3 not in map)
d = {"one": 1, "two": 2, "three": 3, 1j: 2j}
for k in d:
- self.assert_(k in d)
- self.assert_(k not in d.values())
+ self.assertTrue(k in d)
+ self.assertTrue(k not in d.values())
for v in d.values():
- self.assert_(v in d.values())
- self.assert_(v not in d)
+ self.assertTrue(v in d.values())
+ self.assertTrue(v not in d)
for k, v in d.items():
- self.assert_((k, v) in d.items())
- self.assert_((v, k) not in d.items())
+ self.assertTrue((k, v) in d.items())
+ self.assertTrue((v, k) not in d.items())
f = open(TESTFN, "w")
try:
@@ -569,9 +569,9 @@
try:
for chunk in "abc":
f.seek(0, 0)
- self.assert_(chunk not in f)
+ self.assertTrue(chunk not in f)
f.seek(0, 0)
- self.assert_((chunk + "\n") in f)
+ self.assertTrue((chunk + "\n") in f)
finally:
f.close()
try:
Modified: python/branches/py3k/Lib/test/test_itertools.py
==============================================================================
--- python/branches/py3k/Lib/test/test_itertools.py (original)
+++ python/branches/py3k/Lib/test/test_itertools.py Wed Jul 1 01:06:06 2009
@@ -131,7 +131,7 @@
self.assertEqual(len(c), r) # r-length combinations
self.assertEqual(len(set(c)), r) # no duplicate elements
self.assertEqual(list(c), sorted(c)) # keep original ordering
- self.assert_(all(e in values for e in c)) # elements taken from input iterable
+ self.assertTrue(all(e in values for e in c)) # elements taken from input iterable
self.assertEqual(list(c),
[e for e in values if e in c]) # comb is a subsequence of the input iterable
self.assertEqual(result, list(combinations1(values, r))) # matches first pure python version
@@ -195,14 +195,14 @@
if n == 0 or r <= 1:
self.assertEquals(result, regular_combs) # cases that should be identical
else:
- self.assert_(set(result) >= set(regular_combs)) # rest should be supersets of regular combs
+ self.assertTrue(set(result) >= set(regular_combs)) # rest should be supersets of regular combs
for c in result:
self.assertEqual(len(c), r) # r-length combinations
noruns = [k for k,v in groupby(c)] # combo without consecutive repeats
self.assertEqual(len(noruns), len(set(noruns))) # no repeats other than consecutive
self.assertEqual(list(c), sorted(c)) # keep original ordering
- self.assert_(all(e in values for e in c)) # elements taken from input iterable
+ self.assertTrue(all(e in values for e in c)) # elements taken from input iterable
self.assertEqual(noruns,
[e for e in values if e in c]) # comb is a subsequence of the input iterable
self.assertEqual(result, list(cwr1(values, r))) # matches first pure python version
@@ -265,7 +265,7 @@
for p in result:
self.assertEqual(len(p), r) # r-length permutations
self.assertEqual(len(set(p)), r) # no duplicate elements
- self.assert_(all(e in values for e in p)) # elements taken from input iterable
+ self.assertTrue(all(e in values for e in p)) # elements taken from input iterable
self.assertEqual(result, list(permutations1(values, r))) # matches first pure python version
self.assertEqual(result, list(permutations2(values, r))) # matches second pure python version
if r == n:
@@ -836,7 +836,7 @@
# tee pass-through to copyable iterator
a, b = tee('abc')
c, d = tee(a)
- self.assert_(a is c)
+ self.assertTrue(a is c)
# test tee_new
t1, t2 = tee('abc')
@@ -844,7 +844,7 @@
self.assertRaises(TypeError, tnew)
self.assertRaises(TypeError, tnew, 10)
t3 = tnew(t1)
- self.assert_(list(t1) == list(t2) == list(t3) == list('abc'))
+ self.assertTrue(list(t1) == list(t2) == list(t3) == list('abc'))
# test that tee objects are weak referencable
a, b = tee(range(10))
@@ -1356,7 +1356,7 @@
Subclass(newarg=1)
except TypeError as err:
# we expect type errors because of wrong argument count
- self.failIf("does not take keyword arguments" in err.args[0])
+ self.assertFalse("does not take keyword arguments" in err.args[0])
libreftest = """ Doctest for examples in the library reference: libitertools.tex
Modified: python/branches/py3k/Lib/test/test_kqueue.py
==============================================================================
--- python/branches/py3k/Lib/test/test_kqueue.py (original)
+++ python/branches/py3k/Lib/test/test_kqueue.py Wed Jul 1 01:06:06 2009
@@ -15,10 +15,10 @@
class TestKQueue(unittest.TestCase):
def test_create_queue(self):
kq = select.kqueue()
- self.assert_(kq.fileno() > 0, kq.fileno())
- self.assert_(not kq.closed)
+ self.assertTrue(kq.fileno() > 0, kq.fileno())
+ self.assertTrue(not kq.closed)
kq.close()
- self.assert_(kq.closed)
+ self.assertTrue(kq.closed)
self.assertRaises(ValueError, kq.fileno)
def test_create_event(self):
@@ -34,8 +34,8 @@
self.assertEqual(ev.udata, 0)
self.assertEqual(ev, ev)
self.assertNotEqual(ev, other)
- self.assert_(ev < other)
- self.assert_(other >= ev)
+ self.assertTrue(ev < other)
+ self.assertTrue(other >= ev)
for op in lt, le, gt, ge:
self.assertRaises(TypeError, op, ev, None)
self.assertRaises(TypeError, op, ev, 1)
Modified: python/branches/py3k/Lib/test/test_largefile.py
==============================================================================
--- python/branches/py3k/Lib/test/test_largefile.py (original)
+++ python/branches/py3k/Lib/test/test_largefile.py Wed Jul 1 01:06:06 2009
@@ -139,7 +139,7 @@
for pos in (2**31-1, 2**31, 2**31+1):
with self.open(TESTFN, 'rb') as f:
f.seek(pos)
- self.assert_(f.seekable())
+ self.assertTrue(f.seekable())
def test_main():
Modified: python/branches/py3k/Lib/test/test_list.py
==============================================================================
--- python/branches/py3k/Lib/test/test_list.py (original)
+++ python/branches/py3k/Lib/test/test_list.py Wed Jul 1 01:06:06 2009
@@ -9,7 +9,7 @@
l0_3 = [0, 1, 2, 3]
l0_3_bis = list(l0_3)
self.assertEqual(l0_3, l0_3_bis)
- self.assert_(l0_3 is not l0_3_bis)
+ self.assertTrue(l0_3 is not l0_3_bis)
self.assertEqual(list(()), [])
self.assertEqual(list((0, 1, 2, 3)), [0, 1, 2, 3])
self.assertEqual(list(''), [])
@@ -39,11 +39,11 @@
def test_truth(self):
super().test_truth()
- self.assert_(not [])
- self.assert_([42])
+ self.assertTrue(not [])
+ self.assertTrue([42])
def test_identity(self):
- self.assert_([] is not [])
+ self.assertTrue([] is not [])
def test_len(self):
super().test_len()
Modified: python/branches/py3k/Lib/test/test_logging.py
==============================================================================
--- python/branches/py3k/Lib/test/test_logging.py (original)
+++ python/branches/py3k/Lib/test/test_logging.py Wed Jul 1 01:06:06 2009
@@ -99,7 +99,7 @@
finally:
logging._releaseLock()
- def assert_log_lines(self, expected_values, stream=None):
+ def assertTruelog_lines(self, expected_values, stream=None):
"""Match the collected log lines against the regular expression
self.expected_log_pat, and compare the extracted group values to
the expected_values list of tuples."""
@@ -165,7 +165,7 @@
INF.debug(m())
- self.assert_log_lines([
+ self.assertTruelog_lines([
('ERR', 'CRITICAL', '1'),
('ERR', 'ERROR', '2'),
('INF', 'CRITICAL', '3'),
@@ -197,7 +197,7 @@
INF_ERR.info(m())
INF_ERR.debug(m())
- self.assert_log_lines([
+ self.assertTruelog_lines([
('INF.ERR', 'CRITICAL', '1'),
('INF.ERR', 'ERROR', '2'),
])
@@ -228,7 +228,7 @@
INF_ERR_UNDEF.info(m())
INF_ERR_UNDEF.debug(m())
- self.assert_log_lines([
+ self.assertTruelog_lines([
('INF.UNDEF', 'CRITICAL', '1'),
('INF.UNDEF', 'ERROR', '2'),
('INF.UNDEF', 'WARNING', '3'),
@@ -256,7 +256,7 @@
GRANDCHILD.debug(m())
CHILD.debug(m())
- self.assert_log_lines([
+ self.assertTruelog_lines([
('INF.BADPARENT.UNDEF', 'CRITICAL', '1'),
('INF.BADPARENT.UNDEF', 'INFO', '2'),
('INF.BADPARENT', 'CRITICAL', '3'),
@@ -285,7 +285,7 @@
spam_eggs_fish.info(self.next_message()) # Good.
spam_bakedbeans.info(self.next_message())
- self.assert_log_lines([
+ self.assertTruelog_lines([
('spam.eggs', 'INFO', '2'),
('spam.eggs.fish', 'INFO', '3'),
])
@@ -367,7 +367,7 @@
self.root_logger.setLevel(VERBOSE)
# Levels >= 'Verbose' are good.
self.log_at_all_levels(self.root_logger)
- self.assert_log_lines([
+ self.assertTruelog_lines([
('Verbose', '5'),
('Sociable', '6'),
('Effusive', '7'),
@@ -382,7 +382,7 @@
try:
# Levels >= 'Sociable' are good.
self.log_at_all_levels(self.root_logger)
- self.assert_log_lines([
+ self.assertTruelog_lines([
('Sociable', '6'),
('Effusive', '7'),
('Terse', '8'),
@@ -413,12 +413,12 @@
('Taciturn', '9'),
('Silent', '10'),
]
- self.assert_log_lines(first_lines)
+ self.assertTruelog_lines(first_lines)
specific_filter = VerySpecificFilter()
self.root_logger.addFilter(specific_filter)
self.log_at_all_levels(self.root_logger)
- self.assert_log_lines(first_lines + [
+ self.assertTruelog_lines(first_lines + [
# Not only 'Garrulous' is still missing, but also 'Sociable'
# and 'Taciturn'
('Boring', '11'),
@@ -458,9 +458,9 @@
# The memory handler flushes to its target handler based on specific
# criteria (message count and message level).
self.mem_logger.debug(self.next_message())
- self.assert_log_lines([])
+ self.assertTruelog_lines([])
self.mem_logger.info(self.next_message())
- self.assert_log_lines([])
+ self.assertTruelog_lines([])
# This will flush because the level is >= logging.WARNING
self.mem_logger.warn(self.next_message())
lines = [
@@ -468,19 +468,19 @@
('INFO', '2'),
('WARNING', '3'),
]
- self.assert_log_lines(lines)
+ self.assertTruelog_lines(lines)
for n in (4, 14):
for i in range(9):
self.mem_logger.debug(self.next_message())
- self.assert_log_lines(lines)
+ self.assertTruelog_lines(lines)
# This will flush because it's the 10th message since the last
# flush.
self.mem_logger.debug(self.next_message())
lines = lines + [('DEBUG', str(i)) for i in range(n, n + 10)]
- self.assert_log_lines(lines)
+ self.assertTruelog_lines(lines)
self.mem_logger.debug(self.next_message())
- self.assert_log_lines(lines)
+ self.assertTruelog_lines(lines)
class ExceptionFormatter(logging.Formatter):
@@ -650,11 +650,11 @@
logger.info(self.next_message())
# Outputs a message
logger.error(self.next_message())
- self.assert_log_lines([
+ self.assertTruelog_lines([
('ERROR', '2'),
], stream=output)
# Original logger output is empty.
- self.assert_log_lines([])
+ self.assertTruelog_lines([])
def test_config1_ok(self, config=config1):
# A config file defining a sub-parser as well.
@@ -664,12 +664,12 @@
# Both will output a message
logger.info(self.next_message())
logger.error(self.next_message())
- self.assert_log_lines([
+ self.assertTruelog_lines([
('INFO', '1'),
('ERROR', '2'),
], stream=output)
# Original logger output is empty.
- self.assert_log_lines([])
+ self.assertTruelog_lines([])
def test_config2_failure(self):
# A simple config file which overrides the default settings.
@@ -692,7 +692,7 @@
self.assertEquals(output.getvalue(),
"ERROR:root:just testing\nGot a [RuntimeError]\n")
# Original logger output is empty
- self.assert_log_lines([])
+ self.assertTruelog_lines([])
def test_config5_ok(self):
self.test_config1_ok(config=self.config5)
@@ -826,7 +826,7 @@
key = id(obj), repr(obj)
self._survivors[key] = weakref.ref(obj)
- def _assert_survival(self):
+ def _assertTruesurvival(self):
"""Assert that all objects watched for survival have survived."""
# Trigger cycle breaking.
gc.collect()
@@ -847,16 +847,16 @@
foo.setLevel(logging.DEBUG)
self.root_logger.debug(self.next_message())
foo.debug(self.next_message())
- self.assert_log_lines([
+ self.assertTruelog_lines([
('foo', 'DEBUG', '2'),
])
del foo
# foo has survived.
- self._assert_survival()
+ self._assertTruesurvival()
# foo has retained its settings.
bar = logging.getLogger("foo")
bar.debug(self.next_message())
- self.assert_log_lines([
+ self.assertTruelog_lines([
('foo', 'DEBUG', '2'),
('foo', 'DEBUG', '3'),
])
@@ -881,7 +881,7 @@
# check we wrote exactly those bytes, ignoring trailing \n etc
f = open(fn, encoding="utf8")
try:
- self.failUnlessEqual(f.read().rstrip(), data)
+ self.assertEqual(f.read().rstrip(), data)
finally:
f.close()
finally:
Modified: python/branches/py3k/Lib/test/test_long.py
==============================================================================
--- python/branches/py3k/Lib/test/test_long.py (original)
+++ python/branches/py3k/Lib/test/test_long.py Wed Jul 1 01:06:06 2009
@@ -65,7 +65,7 @@
# The sign of the number is also random.
def getran(self, ndigits):
- self.assert_(ndigits > 0)
+ self.assertTrue(ndigits > 0)
nbits_hi = ndigits * SHIFT
nbits_lo = nbits_hi - SHIFT + 1
answer = 0
@@ -74,13 +74,13 @@
while nbits < nbits_lo:
bits = (r >> 1) + 1
bits = min(bits, nbits_hi - nbits)
- self.assert_(1 <= bits <= SHIFT)
+ self.assertTrue(1 <= bits <= SHIFT)
nbits = nbits + bits
answer = answer << bits
if r & 1:
answer = answer | ((1 << bits) - 1)
r = int(random.random() * (SHIFT * 2))
- self.assert_(nbits_lo <= nbits <= nbits_hi)
+ self.assertTrue(nbits_lo <= nbits <= nbits_hi)
if random.random() < 0.5:
answer = -answer
return answer
@@ -106,9 +106,9 @@
eq(r, r2, Frm("divmod returns different mod than %% for %r and %r", x, y))
eq(x, q*y + r, Frm("x != q*y + r after divmod on x=%r, y=%r", x, y))
if y > 0:
- self.assert_(0 <= r < y, Frm("bad mod from divmod on %r and %r", x, y))
+ self.assertTrue(0 <= r < y, Frm("bad mod from divmod on %r and %r", x, y))
else:
- self.assert_(y < r <= 0, Frm("bad mod from divmod on %r and %r", x, y))
+ self.assertTrue(y < r <= 0, Frm("bad mod from divmod on %r and %r", x, y))
def test_division(self):
digits = list(range(1, MAXDIGITS+1)) + list(range(KARATSUBA_CUTOFF,
@@ -538,7 +538,7 @@
y = int(x)
except OverflowError:
self.fail("int(long(sys.maxsize) + 1) mustn't overflow")
- self.assert_(isinstance(y, int),
+ self.assertTrue(isinstance(y, int),
"int(long(sys.maxsize) + 1) should have returned long")
x = hugeneg_aslong - 1
@@ -546,14 +546,14 @@
y = int(x)
except OverflowError:
self.fail("int(long(-sys.maxsize-1) - 1) mustn't overflow")
- self.assert_(isinstance(y, int),
+ self.assertTrue(isinstance(y, int),
"int(long(-sys.maxsize-1) - 1) should have returned long")
class long2(int):
pass
x = long2(1<<100)
y = int(x)
- self.assert_(type(y) is int,
+ self.assertTrue(type(y) is int,
"overflowing int conversion must return long not long subtype")
# ----------------------------------- tests of auto int->long conversion
@@ -958,7 +958,7 @@
self.assertEqual(k, len(bin(x).lstrip('-0b')))
# Behaviour as specified in the docs
if x != 0:
- self.assert_(2**(k-1) <= abs(x) < 2**k)
+ self.assertTrue(2**(k-1) <= abs(x) < 2**k)
else:
self.assertEqual(k, 0)
# Alternative definition: x.bit_length() == 1 + floor(log_2(x))
@@ -995,7 +995,7 @@
got = round(k+offset, -1)
expected = v+offset
self.assertEqual(got, expected)
- self.assert_(type(got) is int)
+ self.assertTrue(type(got) is int)
# larger second argument
self.assertEqual(round(-150, -2), -200)
@@ -1034,7 +1034,7 @@
got = round(10**k + 324678, -3)
expect = 10**k + 325000
self.assertEqual(got, expect)
- self.assert_(type(got) is int)
+ self.assertTrue(type(got) is int)
# nonnegative second argument: round(x, n) should just return x
for n in range(5):
@@ -1042,7 +1042,7 @@
x = random.randrange(-10000, 10000)
got = round(x, n)
self.assertEqual(got, x)
- self.assert_(type(got) is int)
+ self.assertTrue(type(got) is int)
for huge_n in 2**31-1, 2**31, 2**63-1, 2**63, 2**100, 10**100:
self.assertEqual(round(8979323, huge_n), 8979323)
@@ -1051,7 +1051,7 @@
x = random.randrange(-10000, 10000)
got = round(x)
self.assertEqual(got, x)
- self.assert_(type(got) is int)
+ self.assertTrue(type(got) is int)
# bad second argument
bad_exponents = ('brian', 2.0, 0j, None)
Modified: python/branches/py3k/Lib/test/test_macpath.py
==============================================================================
--- python/branches/py3k/Lib/test/test_macpath.py (original)
+++ python/branches/py3k/Lib/test/test_macpath.py Wed Jul 1 01:06:06 2009
@@ -10,37 +10,37 @@
def test_isabs(self):
isabs = macpath.isabs
- self.assert_(isabs("xx:yy"))
- self.assert_(isabs("xx:yy:"))
- self.assert_(isabs("xx:"))
- self.failIf(isabs("foo"))
- self.failIf(isabs(":foo"))
- self.failIf(isabs(":foo:bar"))
- self.failIf(isabs(":foo:bar:"))
-
- self.assert_(isabs(b"xx:yy"))
- self.assert_(isabs(b"xx:yy:"))
- self.assert_(isabs(b"xx:"))
- self.failIf(isabs(b"foo"))
- self.failIf(isabs(b":foo"))
- self.failIf(isabs(b":foo:bar"))
- self.failIf(isabs(b":foo:bar:"))
+ self.assertTrue(isabs("xx:yy"))
+ self.assertTrue(isabs("xx:yy:"))
+ self.assertTrue(isabs("xx:"))
+ self.assertFalse(isabs("foo"))
+ self.assertFalse(isabs(":foo"))
+ self.assertFalse(isabs(":foo:bar"))
+ self.assertFalse(isabs(":foo:bar:"))
+
+ self.assertTrue(isabs(b"xx:yy"))
+ self.assertTrue(isabs(b"xx:yy:"))
+ self.assertTrue(isabs(b"xx:"))
+ self.assertFalse(isabs(b"foo"))
+ self.assertFalse(isabs(b":foo"))
+ self.assertFalse(isabs(b":foo:bar"))
+ self.assertFalse(isabs(b":foo:bar:"))
def test_commonprefix(self):
commonprefix = macpath.commonprefix
- self.assert_(commonprefix(["home:swenson:spam", "home:swen:spam"])
+ self.assertTrue(commonprefix(["home:swenson:spam", "home:swen:spam"])
== "home:swen")
- self.assert_(commonprefix([":home:swen:spam", ":home:swen:eggs"])
+ self.assertTrue(commonprefix([":home:swen:spam", ":home:swen:eggs"])
== ":home:swen:")
- self.assert_(commonprefix([":home:swen:spam", ":home:swen:spam"])
+ self.assertTrue(commonprefix([":home:swen:spam", ":home:swen:spam"])
== ":home:swen:spam")
- self.assert_(commonprefix([b"home:swenson:spam", b"home:swen:spam"])
+ self.assertTrue(commonprefix([b"home:swenson:spam", b"home:swen:spam"])
== b"home:swen")
- self.assert_(commonprefix([b":home:swen:spam", b":home:swen:eggs"])
+ self.assertTrue(commonprefix([b":home:swen:spam", b":home:swen:eggs"])
== b":home:swen:")
- self.assert_(commonprefix([b":home:swen:spam", b":home:swen:spam"])
+ self.assertTrue(commonprefix([b":home:swen:spam", b":home:swen:spam"])
== b":home:swen:spam")
def test_split(self):
Modified: python/branches/py3k/Lib/test/test_mailbox.py
==============================================================================
--- python/branches/py3k/Lib/test/test_mailbox.py (original)
+++ python/branches/py3k/Lib/test/test_mailbox.py Wed Jul 1 01:06:06 2009
@@ -21,16 +21,16 @@
def _check_sample(self, msg):
# Inspect a mailbox.Message representation of the sample message
- self.assert_(isinstance(msg, email.message.Message))
- self.assert_(isinstance(msg, mailbox.Message))
+ self.assertTrue(isinstance(msg, email.message.Message))
+ self.assertTrue(isinstance(msg, mailbox.Message))
for key, value in _sample_headers.items():
- self.assert_(value in msg.get_all(key))
- self.assert_(msg.is_multipart())
+ self.assertTrue(value in msg.get_all(key))
+ self.assertTrue(msg.is_multipart())
self.assertEqual(len(msg.get_payload()), len(_sample_payloads))
for i, payload in enumerate(_sample_payloads):
part = msg.get_payload(i)
- self.assert_(isinstance(part, email.message.Message))
- self.assert_(not isinstance(part, mailbox.Message))
+ self.assertTrue(isinstance(part, email.message.Message))
+ self.assertTrue(not isinstance(part, mailbox.Message))
self.assertEqual(part.get_payload(), payload)
def _delete_recursively(self, target):
@@ -92,7 +92,7 @@
self.assertEqual(len(self._box), 2)
method(key0)
l = len(self._box)
- self.assert_(l == 1, "actual l: %s" % l)
+ self.assertTrue(l == 1, "actual l: %s" % l)
self.assertRaises(KeyError, lambda: self._box[key0])
self.assertRaises(KeyError, lambda: method(key0))
self.assertEqual(self._box.get_string(key1), self._template % 1)
@@ -100,7 +100,7 @@
self.assertEqual(len(self._box), 2)
method(key2)
l = len(self._box)
- self.assert_(l == 1, "actual l: %s" % l)
+ self.assertTrue(l == 1, "actual l: %s" % l)
self.assertRaises(KeyError, lambda: self._box[key2])
self.assertRaises(KeyError, lambda: method(key2))
self.assertEqual(self._box.get_string(key1), self._template % 1)
@@ -127,8 +127,8 @@
msg = self._box.get(key0)
self.assertEqual(msg['from'], 'foo')
self.assertEqual(msg.get_payload(), '0')
- self.assert_(self._box.get('foo') is None)
- self.assert_(self._box.get('foo', False) is False)
+ self.assertTrue(self._box.get('foo') is None)
+ self.assertTrue(self._box.get('foo', False) is False)
self._box.close()
self._box = self._factory(self._path)
key1 = self._box.add(self._template % 1)
@@ -151,7 +151,7 @@
key0 = self._box.add(self._template % 0)
key1 = self._box.add(_sample_message)
msg0 = self._box.get_message(key0)
- self.assert_(isinstance(msg0, mailbox.Message))
+ self.assertTrue(isinstance(msg0, mailbox.Message))
self.assertEqual(msg0['from'], 'foo')
self.assertEqual(msg0.get_payload(), '0')
self._check_sample(self._box.get_message(key1))
@@ -228,29 +228,29 @@
count = 0
for value in returned_values:
self.assertEqual(value['from'], 'foo')
- self.assert_(int(value.get_payload()) < repetitions)
+ self.assertTrue(int(value.get_payload()) < repetitions)
count += 1
self.assertEqual(len(values), count)
def test_contains(self):
# Check existence of keys using __contains__()
method = self._box.__contains__
- self.assert_(not method('foo'))
+ self.assertTrue(not method('foo'))
key0 = self._box.add(self._template % 0)
- self.assert_(method(key0))
- self.assert_(not method('foo'))
+ self.assertTrue(method(key0))
+ self.assertTrue(not method('foo'))
key1 = self._box.add(self._template % 1)
- self.assert_(method(key1))
- self.assert_(method(key0))
- self.assert_(not method('foo'))
+ self.assertTrue(method(key1))
+ self.assertTrue(method(key0))
+ self.assertTrue(not method('foo'))
self._box.remove(key0)
- self.assert_(not method(key0))
- self.assert_(method(key1))
- self.assert_(not method('foo'))
+ self.assertTrue(not method(key0))
+ self.assertTrue(method(key1))
+ self.assertTrue(not method('foo'))
self._box.remove(key1)
- self.assert_(not method(key1))
- self.assert_(not method(key0))
- self.assert_(not method('foo'))
+ self.assertTrue(not method(key1))
+ self.assertTrue(not method(key0))
+ self.assertTrue(not method('foo'))
def test_len(self, repetitions=10):
# Get message count
@@ -297,7 +297,7 @@
for i in range(iterations):
self._box.add(self._template % i)
for i, key in enumerate(keys):
- self.assert_(self._box.get_string(key) == self._template % i)
+ self.assertTrue(self._box.get_string(key) == self._template % i)
self._box.clear()
self.assertEqual(len(self._box), 0)
for i, key in enumerate(keys):
@@ -306,19 +306,19 @@
def test_pop(self):
# Get and remove a message using pop()
key0 = self._box.add(self._template % 0)
- self.assert_(key0 in self._box)
+ self.assertTrue(key0 in self._box)
key1 = self._box.add(self._template % 1)
- self.assert_(key1 in self._box)
+ self.assertTrue(key1 in self._box)
self.assertEqual(self._box.pop(key0).get_payload(), '0')
- self.assert_(key0 not in self._box)
- self.assert_(key1 in self._box)
+ self.assertTrue(key0 not in self._box)
+ self.assertTrue(key1 in self._box)
key2 = self._box.add(self._template % 2)
- self.assert_(key2 in self._box)
+ self.assertTrue(key2 in self._box)
self.assertEqual(self._box.pop(key2).get_payload(), '2')
- self.assert_(key2 not in self._box)
- self.assert_(key1 in self._box)
+ self.assertTrue(key2 not in self._box)
+ self.assertTrue(key1 in self._box)
self.assertEqual(self._box.pop(key1).get_payload(), '1')
- self.assert_(key1 not in self._box)
+ self.assertTrue(key1 not in self._box)
self.assertEqual(len(self._box), 0)
def test_popitem(self, iterations=10):
@@ -329,8 +329,8 @@
seen = []
for i in range(10):
key, msg = self._box.popitem()
- self.assert_(key in keys)
- self.assert_(key not in seen)
+ self.assertTrue(key in keys)
+ self.assertTrue(key not in seen)
seen.append(key)
self.assertEqual(int(msg.get_payload()), keys.index(key))
self.assertEqual(len(self._box), 0)
@@ -377,11 +377,11 @@
def test_lock_unlock(self):
# Lock and unlock the mailbox
- self.assert_(not os.path.exists(self._get_lock_path()))
+ self.assertTrue(not os.path.exists(self._get_lock_path()))
self._box.lock()
- self.assert_(os.path.exists(self._get_lock_path()))
+ self.assertTrue(os.path.exists(self._get_lock_path()))
self._box.unlock()
- self.assert_(not os.path.exists(self._get_lock_path()))
+ self.assertTrue(not os.path.exists(self._get_lock_path()))
def test_close(self):
# Close mailbox and flush changes to disk
@@ -400,7 +400,7 @@
keys = self._box.keys()
self.assertEqual(len(keys), 3)
for key in keys:
- self.assert_(self._box.get_string(key) in contents)
+ self.assertTrue(self._box.get_string(key) in contents)
oldbox.close()
def test_dump_message(self):
@@ -469,7 +469,7 @@
msg.set_subdir('cur')
msg.set_info('foo')
key = self._box.add(msg)
- self.assert_(os.path.exists(os.path.join(self._path, 'cur', '%s%sfoo' %
+ self.assertTrue(os.path.exists(os.path.join(self._path, 'cur', '%s%sfoo' %
(key, self._box.colon))))
def test_get_MM(self):
@@ -479,7 +479,7 @@
msg.set_flags('RF')
key = self._box.add(msg)
msg_returned = self._box.get_message(key)
- self.assert_(isinstance(msg_returned, mailbox.MaildirMessage))
+ self.assertTrue(isinstance(msg_returned, mailbox.MaildirMessage))
self.assertEqual(msg_returned.get_subdir(), 'cur')
self.assertEqual(msg_returned.get_flags(), 'FR')
@@ -519,7 +519,7 @@
box = mailbox.Maildir(self._path, factory=FakeMessage)
box.colon = self._box.colon
msg2 = box.get_message(key)
- self.assert_(isinstance(msg2, FakeMessage))
+ self.assertTrue(isinstance(msg2, FakeMessage))
def test_initialize_new(self):
# Initialize a non-existent mailbox
@@ -545,7 +545,7 @@
for subdir in '', 'tmp', 'new', 'cur':
path = os.path.join(self._path, subdir)
mode = os.stat(path)[stat.ST_MODE]
- self.assert_(stat.S_ISDIR(mode), "Not a directory: '%s'" % path)
+ self.assertTrue(stat.S_ISDIR(mode), "Not a directory: '%s'" % path)
def test_list_folders(self):
# List folders
@@ -561,7 +561,7 @@
self._box.add_folder('foo.bar')
folder0 = self._box.get_folder('foo.bar')
folder0.add(self._template % 'bar')
- self.assert_(os.path.isdir(os.path.join(self._path, '.foo.bar')))
+ self.assertTrue(os.path.isdir(os.path.join(self._path, '.foo.bar')))
folder1 = self._box.get_folder('foo.bar')
self.assertEqual(folder1.get_string(folder1.keys()[0]),
self._template % 'bar')
@@ -571,7 +571,7 @@
self._box.add_folder('one')
self._box.add_folder('two')
self.assertEqual(len(self._box.list_folders()), 2)
- self.assert_(set(self._box.list_folders()) == set(('one', 'two')))
+ self.assertTrue(set(self._box.list_folders()) == set(('one', 'two')))
self._box.remove_folder('one')
self.assertEqual(len(self._box.list_folders()), 1)
self.assertEqual(set(self._box.list_folders()), set(('two',)))
@@ -596,14 +596,14 @@
f.write("@")
f.close()
self._box.clean()
- self.assert_(os.path.exists(foo_path))
- self.assert_(os.path.exists(bar_path))
+ self.assertTrue(os.path.exists(foo_path))
+ self.assertTrue(os.path.exists(bar_path))
foo_stat = os.stat(foo_path)
os.utime(foo_path, (time.time() - 129600 - 2,
foo_stat.st_mtime))
self._box.clean()
- self.assert_(not os.path.exists(foo_path))
- self.assert_(os.path.exists(bar_path))
+ self.assertTrue(not os.path.exists(foo_path))
+ self.assertTrue(os.path.exists(bar_path))
def test_create_tmp(self, repetitions=10):
# Create files in tmp directory
@@ -623,13 +623,13 @@
"tmp")),
"File in wrong location: '%s'" % head)
match = pattern.match(tail)
- self.assert_(match is not None, "Invalid file name: '%s'" % tail)
+ self.assertTrue(match is not None, "Invalid file name: '%s'" % tail)
groups = match.groups()
if previous_groups is not None:
- self.assert_(int(groups[0] >= previous_groups[0]),
+ self.assertTrue(int(groups[0] >= previous_groups[0]),
"Non-monotonic seconds: '%s' before '%s'" %
(previous_groups[0], groups[0]))
- self.assert_(int(groups[1] >= previous_groups[1]) or
+ self.assertTrue(int(groups[1] >= previous_groups[1]) or
groups[0] != groups[1],
"Non-monotonic milliseconds: '%s' before '%s'" %
(previous_groups[1], groups[1]))
@@ -691,10 +691,10 @@
return None
box = self._factory(self._path, factory=dummy_factory)
folder = box.add_folder('folder1')
- self.assert_(folder._factory is dummy_factory)
+ self.assertTrue(folder._factory is dummy_factory)
folder1_alias = box.get_folder('folder1')
- self.assert_(folder1_alias._factory is dummy_factory)
+ self.assertTrue(folder1_alias._factory is dummy_factory)
def test_directory_in_folder (self):
# Test that mailboxes still work if there's a stray extra directory
@@ -721,7 +721,7 @@
os.umask(orig_umask)
path = os.path.join(self._path, self._box._lookup(key))
mode = os.stat(path).st_mode
- self.assert_(mode & 0o111 == 0)
+ self.assertTrue(mode & 0o111 == 0)
def test_folder_file_perms(self):
# From bug #3228, we want to verify that the file created inside a Maildir
@@ -802,7 +802,7 @@
self._box = self._factory(self._path)
self.assertEqual(len(self._box), 3)
for key in self._box.keys():
- self.assert_(self._box.get_string(key) in values)
+ self.assertTrue(self._box.get_string(key) in values)
self._box.close()
self.assertEqual(mtime, os.path.getmtime(self._path))
@@ -859,7 +859,7 @@
self._box.lock()
key2 = self._box.add(msg)
self._box.flush()
- self.assert_(self._box._locked)
+ self.assertTrue(self._box._locked)
self._box.close()
@@ -913,15 +913,15 @@
new_folder = self._box.add_folder('foo.bar')
folder0 = self._box.get_folder('foo.bar')
folder0.add(self._template % 'bar')
- self.assert_(os.path.isdir(os.path.join(self._path, 'foo.bar')))
+ self.assertTrue(os.path.isdir(os.path.join(self._path, 'foo.bar')))
folder1 = self._box.get_folder('foo.bar')
self.assertEqual(folder1.get_string(folder1.keys()[0]),
self._template % 'bar')
# Test for bug #1569790: verify that folders returned by .get_folder()
# use the same factory function.
- self.assert_(new_folder._factory is self._box._factory)
- self.assert_(folder0._factory is self._box._factory)
+ self.assertTrue(new_folder._factory is self._box._factory)
+ self.assertTrue(folder0._factory is self._box._factory)
def test_add_and_remove_folders(self):
# Delete folders
@@ -990,7 +990,7 @@
{'foo':[key0,key1,key3], 'unseen':[key0], 'bar':[key3],
'replied':[key3]})
self._box.pack()
- self.assert_(self._box.keys() == [1, 2, 3])
+ self.assertTrue(self._box.keys() == [1, 2, 3])
key0 = key0
key1 = key0 + 1
key2 = key1 + 1
@@ -1082,11 +1082,11 @@
# Initialize without arguments
msg = self._factory()
self._post_initialize_hook(msg)
- self.assert_(isinstance(msg, email.message.Message))
- self.assert_(isinstance(msg, mailbox.Message))
- self.assert_(isinstance(msg, self._factory))
+ self.assertTrue(isinstance(msg, email.message.Message))
+ self.assertTrue(isinstance(msg, mailbox.Message))
+ self.assertTrue(isinstance(msg, self._factory))
self.assertEqual(msg.keys(), [])
- self.assert_(not msg.is_multipart())
+ self.assertTrue(not msg.is_multipart())
self.assertEqual(msg.get_payload(), None)
def test_initialize_incorrectly(self):
@@ -1159,7 +1159,7 @@
def test_date(self):
# Use get_date() and set_date()
msg = mailbox.MaildirMessage(_sample_message)
- self.assert_(abs(msg.get_date() - time.time()) < 60)
+ self.assertTrue(abs(msg.get_date() - time.time()) < 60)
msg.set_date(0.0)
self.assertEqual(msg.get_date(), 0.0)
@@ -1234,7 +1234,7 @@
# Check contents of "From " line
if sender is None:
sender = "MAILER-DAEMON"
- self.assert_(re.match(sender + r" \w{3} \w{3} [\d ]\d [\d ]\d:\d{2}:"
+ self.assertTrue(re.match(sender + r" \w{3} \w{3} [\d ]\d [\d ]\d:\d{2}:"
r"\d{2} \d{4}", msg.get_from()) is not None)
@@ -1309,19 +1309,19 @@
msg = mailbox.BabylMessage(_sample_message)
visible = msg.get_visible()
self.assertEqual(visible.keys(), [])
- self.assert_(visible.get_payload() is None)
+ self.assertTrue(visible.get_payload() is None)
visible['User-Agent'] = 'FooBar 1.0'
visible['X-Whatever'] = 'Blah'
self.assertEqual(msg.get_visible().keys(), [])
msg.set_visible(visible)
visible = msg.get_visible()
- self.assert_(visible.keys() == ['User-Agent', 'X-Whatever'])
- self.assert_(visible['User-Agent'] == 'FooBar 1.0')
+ self.assertTrue(visible.keys() == ['User-Agent', 'X-Whatever'])
+ self.assertTrue(visible['User-Agent'] == 'FooBar 1.0')
self.assertEqual(visible['X-Whatever'], 'Blah')
- self.assert_(visible.get_payload() is None)
+ self.assertTrue(visible.get_payload() is None)
msg.update_visible()
self.assertEqual(visible.keys(), ['User-Agent', 'X-Whatever'])
- self.assert_(visible.get_payload() is None)
+ self.assertTrue(visible.get_payload() is None)
visible = msg.get_visible()
self.assertEqual(visible.keys(), ['User-Agent', 'Date', 'From', 'To',
'Subject'])
@@ -1423,7 +1423,7 @@
msg_mboxMMDF.set_flags(setting)
msg = mailbox.MaildirMessage(msg_mboxMMDF)
self.assertEqual(msg.get_flags(), result)
- self.assert_(msg.get_date() == 0.0, msg.get_date())
+ self.assertTrue(msg.get_date() == 0.0, msg.get_date())
msg_mboxMMDF.set_flags('O')
self.assertEqual(mailbox.MaildirMessage(msg_mboxMMDF).get_subdir(),
'cur')
@@ -1655,7 +1655,7 @@
proxy.seek(2, 0)
self.assertEqual(proxy.read(), b'o' + linesep + b'bar' + linesep)
proxy.seek(100)
- self.failIf(proxy.read())
+ self.assertFalse(proxy.read())
def _test_close(self, proxy):
# Close a file
@@ -1820,36 +1820,36 @@
# Test for regression on bug #117490:
# Make sure the boxes attribute actually gets set.
self.mbox = mailbox.Maildir(support.TESTFN)
- #self.assert_(hasattr(self.mbox, "boxes"))
+ #self.assertTrue(hasattr(self.mbox, "boxes"))
#self.assertEqual(len(self.mbox.boxes), 0)
- self.assert_(self.mbox.next() is None)
- self.assert_(self.mbox.next() is None)
+ self.assertTrue(self.mbox.next() is None)
+ self.assertTrue(self.mbox.next() is None)
def test_nonempty_maildir_cur(self):
self.createMessage("cur")
self.mbox = mailbox.Maildir(support.TESTFN)
#self.assertEqual(len(self.mbox.boxes), 1)
- self.assert_(self.mbox.next() is not None)
- self.assert_(self.mbox.next() is None)
- self.assert_(self.mbox.next() is None)
+ self.assertTrue(self.mbox.next() is not None)
+ self.assertTrue(self.mbox.next() is None)
+ self.assertTrue(self.mbox.next() is None)
def test_nonempty_maildir_new(self):
self.createMessage("new")
self.mbox = mailbox.Maildir(support.TESTFN)
#self.assertEqual(len(self.mbox.boxes), 1)
- self.assert_(self.mbox.next() is not None)
- self.assert_(self.mbox.next() is None)
- self.assert_(self.mbox.next() is None)
+ self.assertTrue(self.mbox.next() is not None)
+ self.assertTrue(self.mbox.next() is None)
+ self.assertTrue(self.mbox.next() is None)
def test_nonempty_maildir_both(self):
self.createMessage("cur")
self.createMessage("new")
self.mbox = mailbox.Maildir(support.TESTFN)
#self.assertEqual(len(self.mbox.boxes), 2)
- self.assert_(self.mbox.next() is not None)
- self.assert_(self.mbox.next() is not None)
- self.assert_(self.mbox.next() is None)
- self.assert_(self.mbox.next() is None)
+ self.assertTrue(self.mbox.next() is not None)
+ self.assertTrue(self.mbox.next() is not None)
+ self.assertTrue(self.mbox.next() is None)
+ self.assertTrue(self.mbox.next() is None)
## End: tests from the original module (for backward compatibility).
Modified: python/branches/py3k/Lib/test/test_math.py
==============================================================================
--- python/branches/py3k/Lib/test/test_math.py (original)
+++ python/branches/py3k/Lib/test/test_math.py Wed Jul 1 01:06:06 2009
@@ -72,7 +72,7 @@
self.ftest('acos(1)', math.acos(1), 0)
self.assertRaises(ValueError, math.acos, INF)
self.assertRaises(ValueError, math.acos, NINF)
- self.assert_(math.isnan(math.acos(NAN)))
+ self.assertTrue(math.isnan(math.acos(NAN)))
def testAcosh(self):
self.assertRaises(TypeError, math.acosh)
@@ -82,7 +82,7 @@
self.assertRaises(ValueError, math.acosh, -1)
self.assertEquals(math.acosh(INF), INF)
self.assertRaises(ValueError, math.acosh, NINF)
- self.assert_(math.isnan(math.acosh(NAN)))
+ self.assertTrue(math.isnan(math.acosh(NAN)))
def testAsin(self):
self.assertRaises(TypeError, math.asin)
@@ -91,7 +91,7 @@
self.ftest('asin(1)', math.asin(1), math.pi/2)
self.assertRaises(ValueError, math.asin, INF)
self.assertRaises(ValueError, math.asin, NINF)
- self.assert_(math.isnan(math.asin(NAN)))
+ self.assertTrue(math.isnan(math.asin(NAN)))
def testAsinh(self):
self.assertRaises(TypeError, math.asinh)
@@ -100,7 +100,7 @@
self.ftest('asinh(-1)', math.asinh(-1), -0.88137358701954305)
self.assertEquals(math.asinh(INF), INF)
self.assertEquals(math.asinh(NINF), NINF)
- self.assert_(math.isnan(math.asinh(NAN)))
+ self.assertTrue(math.isnan(math.asinh(NAN)))
def testAtan(self):
self.assertRaises(TypeError, math.atan)
@@ -109,7 +109,7 @@
self.ftest('atan(1)', math.atan(1), math.pi/4)
self.ftest('atan(inf)', math.atan(INF), math.pi/2)
self.ftest('atan(-inf)', math.atan(NINF), -math.pi/2)
- self.assert_(math.isnan(math.atan(NAN)))
+ self.assertTrue(math.isnan(math.atan(NAN)))
def testAtanh(self):
self.assertRaises(TypeError, math.atan)
@@ -120,7 +120,7 @@
self.assertRaises(ValueError, math.atanh, -1)
self.assertRaises(ValueError, math.atanh, INF)
self.assertRaises(ValueError, math.atanh, NINF)
- self.assert_(math.isnan(math.atanh(NAN)))
+ self.assertTrue(math.isnan(math.atanh(NAN)))
def testAtan2(self):
self.assertRaises(TypeError, math.atan2)
@@ -137,7 +137,7 @@
self.assertEqual(math.atan2(0., 0.), 0.)
self.assertEqual(math.atan2(0., 2.3), 0.)
self.assertEqual(math.atan2(0., INF), 0.)
- self.assert_(math.isnan(math.atan2(0., NAN)))
+ self.assertTrue(math.isnan(math.atan2(0., NAN)))
# math.atan2(-0, x)
self.ftest('atan2(-0., -inf)', math.atan2(-0., NINF), -math.pi)
self.ftest('atan2(-0., -2.3)', math.atan2(-0., -2.3), -math.pi)
@@ -145,7 +145,7 @@
self.assertEqual(math.atan2(-0., 0.), -0.)
self.assertEqual(math.atan2(-0., 2.3), -0.)
self.assertEqual(math.atan2(-0., INF), -0.)
- self.assert_(math.isnan(math.atan2(-0., NAN)))
+ self.assertTrue(math.isnan(math.atan2(-0., NAN)))
# math.atan2(INF, x)
self.ftest('atan2(inf, -inf)', math.atan2(INF, NINF), math.pi*3/4)
self.ftest('atan2(inf, -2.3)', math.atan2(INF, -2.3), math.pi/2)
@@ -153,7 +153,7 @@
self.ftest('atan2(inf, 0.)', math.atan2(INF, 0.0), math.pi/2)
self.ftest('atan2(inf, 2.3)', math.atan2(INF, 2.3), math.pi/2)
self.ftest('atan2(inf, inf)', math.atan2(INF, INF), math.pi/4)
- self.assert_(math.isnan(math.atan2(INF, NAN)))
+ self.assertTrue(math.isnan(math.atan2(INF, NAN)))
# math.atan2(NINF, x)
self.ftest('atan2(-inf, -inf)', math.atan2(NINF, NINF), -math.pi*3/4)
self.ftest('atan2(-inf, -2.3)', math.atan2(NINF, -2.3), -math.pi/2)
@@ -161,27 +161,27 @@
self.ftest('atan2(-inf, 0.)', math.atan2(NINF, 0.0), -math.pi/2)
self.ftest('atan2(-inf, 2.3)', math.atan2(NINF, 2.3), -math.pi/2)
self.ftest('atan2(-inf, inf)', math.atan2(NINF, INF), -math.pi/4)
- self.assert_(math.isnan(math.atan2(NINF, NAN)))
+ self.assertTrue(math.isnan(math.atan2(NINF, NAN)))
# math.atan2(+finite, x)
self.ftest('atan2(2.3, -inf)', math.atan2(2.3, NINF), math.pi)
self.ftest('atan2(2.3, -0.)', math.atan2(2.3, -0.), math.pi/2)
self.ftest('atan2(2.3, 0.)', math.atan2(2.3, 0.), math.pi/2)
self.assertEqual(math.atan2(2.3, INF), 0.)
- self.assert_(math.isnan(math.atan2(2.3, NAN)))
+ self.assertTrue(math.isnan(math.atan2(2.3, NAN)))
# math.atan2(-finite, x)
self.ftest('atan2(-2.3, -inf)', math.atan2(-2.3, NINF), -math.pi)
self.ftest('atan2(-2.3, -0.)', math.atan2(-2.3, -0.), -math.pi/2)
self.ftest('atan2(-2.3, 0.)', math.atan2(-2.3, 0.), -math.pi/2)
self.assertEqual(math.atan2(-2.3, INF), -0.)
- self.assert_(math.isnan(math.atan2(-2.3, NAN)))
+ self.assertTrue(math.isnan(math.atan2(-2.3, NAN)))
# math.atan2(NAN, x)
- self.assert_(math.isnan(math.atan2(NAN, NINF)))
- self.assert_(math.isnan(math.atan2(NAN, -2.3)))
- self.assert_(math.isnan(math.atan2(NAN, -0.)))
- self.assert_(math.isnan(math.atan2(NAN, 0.)))
- self.assert_(math.isnan(math.atan2(NAN, 2.3)))
- self.assert_(math.isnan(math.atan2(NAN, INF)))
- self.assert_(math.isnan(math.atan2(NAN, NAN)))
+ self.assertTrue(math.isnan(math.atan2(NAN, NINF)))
+ self.assertTrue(math.isnan(math.atan2(NAN, -2.3)))
+ self.assertTrue(math.isnan(math.atan2(NAN, -0.)))
+ self.assertTrue(math.isnan(math.atan2(NAN, 0.)))
+ self.assertTrue(math.isnan(math.atan2(NAN, 2.3)))
+ self.assertTrue(math.isnan(math.atan2(NAN, INF)))
+ self.assertTrue(math.isnan(math.atan2(NAN, NAN)))
def testCeil(self):
self.assertRaises(TypeError, math.ceil)
@@ -194,7 +194,7 @@
self.ftest('ceil(-1.5)', math.ceil(-1.5), -1)
#self.assertEquals(math.ceil(INF), INF)
#self.assertEquals(math.ceil(NINF), NINF)
- #self.assert_(math.isnan(math.ceil(NAN)))
+ #self.assertTrue(math.isnan(math.ceil(NAN)))
class TestCeil:
def __ceil__(self):
@@ -226,14 +226,14 @@
self.assertEquals(copysign(INF, NINF), NINF)
self.assertEquals(copysign(NINF, INF), INF)
self.assertEquals(copysign(NINF, NINF), NINF)
- self.assert_(math.isnan(copysign(NAN, 1.)))
- self.assert_(math.isnan(copysign(NAN, INF)))
- self.assert_(math.isnan(copysign(NAN, NINF)))
- self.assert_(math.isnan(copysign(NAN, NAN)))
+ self.assertTrue(math.isnan(copysign(NAN, 1.)))
+ self.assertTrue(math.isnan(copysign(NAN, INF)))
+ self.assertTrue(math.isnan(copysign(NAN, NINF)))
+ self.assertTrue(math.isnan(copysign(NAN, NAN)))
# copysign(INF, NAN) may be INF or it may be NINF, since
# we don't know whether the sign bit of NAN is set on any
# given platform.
- self.assert_(math.isinf(copysign(INF, NAN)))
+ self.assertTrue(math.isinf(copysign(INF, NAN)))
# similarly, copysign(2., NAN) could be 2. or -2.
self.assertEquals(abs(copysign(2., NAN)), 2.)
@@ -244,12 +244,12 @@
self.ftest('cos(pi/2)', math.cos(math.pi/2), 0)
self.ftest('cos(pi)', math.cos(math.pi), -1)
try:
- self.assert_(math.isnan(math.cos(INF)))
- self.assert_(math.isnan(math.cos(NINF)))
+ self.assertTrue(math.isnan(math.cos(INF)))
+ self.assertTrue(math.isnan(math.cos(NINF)))
except ValueError:
self.assertRaises(ValueError, math.cos, INF)
self.assertRaises(ValueError, math.cos, NINF)
- self.assert_(math.isnan(math.cos(NAN)))
+ self.assertTrue(math.isnan(math.cos(NAN)))
def testCosh(self):
self.assertRaises(TypeError, math.cosh)
@@ -257,7 +257,7 @@
self.ftest('cosh(2)-2*cosh(1)**2', math.cosh(2)-2*math.cosh(1)**2, -1) # Thanks to Lambert
self.assertEquals(math.cosh(INF), INF)
self.assertEquals(math.cosh(NINF), INF)
- self.assert_(math.isnan(math.cosh(NAN)))
+ self.assertTrue(math.isnan(math.cosh(NAN)))
def testDegrees(self):
self.assertRaises(TypeError, math.degrees)
@@ -272,7 +272,7 @@
self.ftest('exp(1)', math.exp(1), math.e)
self.assertEquals(math.exp(INF), INF)
self.assertEquals(math.exp(NINF), 0.)
- self.assert_(math.isnan(math.exp(NAN)))
+ self.assertTrue(math.isnan(math.exp(NAN)))
def testFabs(self):
self.assertRaises(TypeError, math.fabs)
@@ -309,7 +309,7 @@
self.ftest('floor(-1.23e167)', math.floor(-1.23e167), -1.23e167)
#self.assertEquals(math.ceil(INF), INF)
#self.assertEquals(math.ceil(NINF), NINF)
- #self.assert_(math.isnan(math.floor(NAN)))
+ #self.assertTrue(math.isnan(math.floor(NAN)))
class TestFloor:
def __floor__(self):
@@ -332,9 +332,9 @@
self.ftest('fmod(-10,1)', math.fmod(-10,1), 0)
self.ftest('fmod(-10,0.5)', math.fmod(-10,0.5), 0)
self.ftest('fmod(-10,1.5)', math.fmod(-10,1.5), -1)
- self.assert_(math.isnan(math.fmod(NAN, 1.)))
- self.assert_(math.isnan(math.fmod(1., NAN)))
- self.assert_(math.isnan(math.fmod(NAN, NAN)))
+ self.assertTrue(math.isnan(math.fmod(NAN, 1.)))
+ self.assertTrue(math.isnan(math.fmod(1., NAN)))
+ self.assertTrue(math.isnan(math.fmod(NAN, NAN)))
self.assertRaises(ValueError, math.fmod, 1., 0.)
self.assertRaises(ValueError, math.fmod, INF, 1.)
self.assertRaises(ValueError, math.fmod, NINF, 1.)
@@ -362,7 +362,7 @@
self.assertEquals(math.frexp(INF)[0], INF)
self.assertEquals(math.frexp(NINF)[0], NINF)
- self.assert_(math.isnan(math.frexp(NAN)[0]))
+ self.assertTrue(math.isnan(math.frexp(NAN)[0]))
@unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
"test requires IEEE 754 doubles")
@@ -464,8 +464,8 @@
self.assertEqual(math.hypot(INF, NAN), INF)
self.assertEqual(math.hypot(NAN, NINF), INF)
self.assertEqual(math.hypot(NINF, NAN), INF)
- self.assert_(math.isnan(math.hypot(1.0, NAN)))
- self.assert_(math.isnan(math.hypot(NAN, -2.0)))
+ self.assertTrue(math.isnan(math.hypot(1.0, NAN)))
+ self.assertTrue(math.isnan(math.hypot(NAN, -2.0)))
def testLdexp(self):
self.assertRaises(TypeError, math.ldexp)
@@ -479,7 +479,7 @@
self.assertEquals(math.ldexp(-1., -1000000), -0.)
self.assertEquals(math.ldexp(INF, 30), INF)
self.assertEquals(math.ldexp(NINF, -213), NINF)
- self.assert_(math.isnan(math.ldexp(NAN, 0)))
+ self.assertTrue(math.isnan(math.ldexp(NAN, 0)))
# large second argument
for n in [10**5, 10**10, 10**20, 10**40]:
@@ -489,7 +489,7 @@
self.assertEquals(math.ldexp(-1., -n), -0.)
self.assertEquals(math.ldexp(0., -n), 0.)
self.assertEquals(math.ldexp(-0., -n), -0.)
- self.assert_(math.isnan(math.ldexp(NAN, -n)))
+ self.assertTrue(math.isnan(math.ldexp(NAN, -n)))
self.assertRaises(OverflowError, math.ldexp, 1., n)
self.assertRaises(OverflowError, math.ldexp, -1., n)
@@ -497,7 +497,7 @@
self.assertEquals(math.ldexp(-0., n), -0.)
self.assertEquals(math.ldexp(INF, n), INF)
self.assertEquals(math.ldexp(NINF, n), NINF)
- self.assert_(math.isnan(math.ldexp(NAN, n)))
+ self.assertTrue(math.isnan(math.ldexp(NAN, n)))
def testLog(self):
self.assertRaises(TypeError, math.log)
@@ -509,7 +509,7 @@
self.ftest('log(10**40, 10**20)', math.log(10**40, 10**20), 2)
self.assertEquals(math.log(INF), INF)
self.assertRaises(ValueError, math.log, NINF)
- self.assert_(math.isnan(math.log(NAN)))
+ self.assertTrue(math.isnan(math.log(NAN)))
def testLog1p(self):
self.assertRaises(TypeError, math.log1p)
@@ -519,7 +519,7 @@
self.ftest('log1p(1)', math.log1p(1), math.log(2))
self.assertEquals(math.log1p(INF), INF)
self.assertRaises(ValueError, math.log1p, NINF)
- self.assert_(math.isnan(math.log1p(NAN)))
+ self.assertTrue(math.isnan(math.log1p(NAN)))
n= 2**90
self.assertAlmostEquals(math.log1p(n), 62.383246250395075)
self.assertAlmostEquals(math.log1p(n), math.log1p(float(n)))
@@ -531,7 +531,7 @@
self.ftest('log10(10)', math.log10(10), 1)
self.assertEquals(math.log(INF), INF)
self.assertRaises(ValueError, math.log10, NINF)
- self.assert_(math.isnan(math.log10(NAN)))
+ self.assertTrue(math.isnan(math.log10(NAN)))
def testModf(self):
self.assertRaises(TypeError, math.modf)
@@ -549,8 +549,8 @@
self.assertEquals(math.modf(NINF), (-0.0, NINF))
modf_nan = math.modf(NAN)
- self.assert_(math.isnan(modf_nan[0]))
- self.assert_(math.isnan(modf_nan[1]))
+ self.assertTrue(math.isnan(modf_nan[0]))
+ self.assertTrue(math.isnan(modf_nan[1]))
def testPow(self):
self.assertRaises(TypeError, math.pow)
@@ -562,9 +562,9 @@
self.assertEqual(math.pow(NINF, 1), NINF)
self.assertEqual((math.pow(1, INF)), 1.)
self.assertEqual((math.pow(1, NINF)), 1.)
- self.assert_(math.isnan(math.pow(NAN, 1)))
- self.assert_(math.isnan(math.pow(2, NAN)))
- self.assert_(math.isnan(math.pow(0, NAN)))
+ self.assertTrue(math.isnan(math.pow(NAN, 1)))
+ self.assertTrue(math.isnan(math.pow(2, NAN)))
+ self.assertTrue(math.isnan(math.pow(0, NAN)))
self.assertEqual(math.pow(1, NAN), 1)
# pow(0., x)
@@ -578,7 +578,7 @@
self.assertRaises(ValueError, math.pow, 0., -2.3)
self.assertRaises(ValueError, math.pow, 0., -3.)
self.assertRaises(ValueError, math.pow, 0., NINF)
- self.assert_(math.isnan(math.pow(0., NAN)))
+ self.assertTrue(math.isnan(math.pow(0., NAN)))
# pow(INF, x)
self.assertEqual(math.pow(INF, INF), INF)
@@ -591,7 +591,7 @@
self.assertEqual(math.pow(INF, -2.3), 0.)
self.assertEqual(math.pow(INF, -3.), 0.)
self.assertEqual(math.pow(INF, NINF), 0.)
- self.assert_(math.isnan(math.pow(INF, NAN)))
+ self.assertTrue(math.isnan(math.pow(INF, NAN)))
# pow(-0., x)
self.assertEqual(math.pow(-0., INF), 0.)
@@ -604,7 +604,7 @@
self.assertRaises(ValueError, math.pow, -0., -2.3)
self.assertRaises(ValueError, math.pow, -0., -3.)
self.assertRaises(ValueError, math.pow, -0., NINF)
- self.assert_(math.isnan(math.pow(-0., NAN)))
+ self.assertTrue(math.isnan(math.pow(-0., NAN)))
# pow(NINF, x)
self.assertEqual(math.pow(NINF, INF), INF)
@@ -617,7 +617,7 @@
self.assertEqual(math.pow(NINF, -2.3), 0.)
self.assertEqual(math.pow(NINF, -3.), -0.)
self.assertEqual(math.pow(NINF, NINF), 0.)
- self.assert_(math.isnan(math.pow(NINF, NAN)))
+ self.assertTrue(math.isnan(math.pow(NINF, NAN)))
# pow(-1, x)
self.assertEqual(math.pow(-1., INF), 1.)
@@ -630,7 +630,7 @@
self.assertRaises(ValueError, math.pow, -1., -2.3)
self.assertEqual(math.pow(-1., -3.), -1.)
self.assertEqual(math.pow(-1., NINF), 1.)
- self.assert_(math.isnan(math.pow(-1., NAN)))
+ self.assertTrue(math.isnan(math.pow(-1., NAN)))
# pow(1, x)
self.assertEqual(math.pow(1., INF), 1.)
@@ -713,12 +713,12 @@
self.ftest('sin(pi/2)', math.sin(math.pi/2), 1)
self.ftest('sin(-pi/2)', math.sin(-math.pi/2), -1)
try:
- self.assert_(math.isnan(math.sin(INF)))
- self.assert_(math.isnan(math.sin(NINF)))
+ self.assertTrue(math.isnan(math.sin(INF)))
+ self.assertTrue(math.isnan(math.sin(NINF)))
except ValueError:
self.assertRaises(ValueError, math.sin, INF)
self.assertRaises(ValueError, math.sin, NINF)
- self.assert_(math.isnan(math.sin(NAN)))
+ self.assertTrue(math.isnan(math.sin(NAN)))
def testSinh(self):
self.assertRaises(TypeError, math.sinh)
@@ -727,7 +727,7 @@
self.ftest('sinh(1)+sinh(-1)', math.sinh(1)+math.sinh(-1), 0)
self.assertEquals(math.sinh(INF), INF)
self.assertEquals(math.sinh(NINF), NINF)
- self.assert_(math.isnan(math.sinh(NAN)))
+ self.assertTrue(math.isnan(math.sinh(NAN)))
def testSqrt(self):
self.assertRaises(TypeError, math.sqrt)
@@ -736,7 +736,7 @@
self.ftest('sqrt(4)', math.sqrt(4), 2)
self.assertEquals(math.sqrt(INF), INF)
self.assertRaises(ValueError, math.sqrt, NINF)
- self.assert_(math.isnan(math.sqrt(NAN)))
+ self.assertTrue(math.isnan(math.sqrt(NAN)))
def testTan(self):
self.assertRaises(TypeError, math.tan)
@@ -744,12 +744,12 @@
self.ftest('tan(pi/4)', math.tan(math.pi/4), 1)
self.ftest('tan(-pi/4)', math.tan(-math.pi/4), -1)
try:
- self.assert_(math.isnan(math.tan(INF)))
- self.assert_(math.isnan(math.tan(NINF)))
+ self.assertTrue(math.isnan(math.tan(INF)))
+ self.assertTrue(math.isnan(math.tan(NINF)))
except:
self.assertRaises(ValueError, math.tan, INF)
self.assertRaises(ValueError, math.tan, NINF)
- self.assert_(math.isnan(math.tan(NAN)))
+ self.assertTrue(math.isnan(math.tan(NAN)))
def testTanh(self):
self.assertRaises(TypeError, math.tanh)
@@ -757,7 +757,7 @@
self.ftest('tanh(1)+tanh(-1)', math.tanh(1)+math.tanh(-1), 0)
self.ftest('tanh(inf)', math.tanh(INF), 1)
self.ftest('tanh(-inf)', math.tanh(NINF), -1)
- self.assert_(math.isnan(math.tanh(NAN)))
+ self.assertTrue(math.isnan(math.tanh(NAN)))
# check that tanh(-0.) == -0. on IEEE 754 systems
if float.__getformat__("double").startswith("IEEE"):
self.assertEqual(math.tanh(-0.), -0.)
@@ -804,20 +804,20 @@
self.assertEqual(math.copysign(4., -0.), -4.0)
def testIsnan(self):
- self.assert_(math.isnan(float("nan")))
- self.assert_(math.isnan(float("inf")* 0.))
- self.failIf(math.isnan(float("inf")))
- self.failIf(math.isnan(0.))
- self.failIf(math.isnan(1.))
+ self.assertTrue(math.isnan(float("nan")))
+ self.assertTrue(math.isnan(float("inf")* 0.))
+ self.assertFalse(math.isnan(float("inf")))
+ self.assertFalse(math.isnan(0.))
+ self.assertFalse(math.isnan(1.))
def testIsinf(self):
- self.assert_(math.isinf(float("inf")))
- self.assert_(math.isinf(float("-inf")))
- self.assert_(math.isinf(1E400))
- self.assert_(math.isinf(-1E400))
- self.failIf(math.isinf(float("nan")))
- self.failIf(math.isinf(0.))
- self.failIf(math.isinf(1.))
+ self.assertTrue(math.isinf(float("inf")))
+ self.assertTrue(math.isinf(float("-inf")))
+ self.assertTrue(math.isinf(1E400))
+ self.assertTrue(math.isinf(-1E400))
+ self.assertFalse(math.isinf(float("nan")))
+ self.assertFalse(math.isinf(0.))
+ self.assertFalse(math.isinf(1.))
# RED_FLAG 16-Oct-2000 Tim
# While 2.0 is more consistent about exceptions than previous releases, it
Modified: python/branches/py3k/Lib/test/test_memoryio.py
==============================================================================
--- python/branches/py3k/Lib/test/test_memoryio.py (original)
+++ python/branches/py3k/Lib/test/test_memoryio.py Wed Jul 1 01:06:06 2009
@@ -222,8 +222,8 @@
memio = self.ioclass(buf * 10)
self.assertEqual(iter(memio), memio)
- self.failUnless(hasattr(memio, '__iter__'))
- self.failUnless(hasattr(memio, '__next__'))
+ self.assertTrue(hasattr(memio, '__iter__'))
+ self.assertTrue(hasattr(memio, '__next__'))
i = 0
for line in memio:
self.assertEqual(line, buf)
Modified: python/branches/py3k/Lib/test/test_memoryview.py
==============================================================================
--- python/branches/py3k/Lib/test/test_memoryview.py (original)
+++ python/branches/py3k/Lib/test/test_memoryview.py Wed Jul 1 01:06:06 2009
@@ -28,7 +28,7 @@
oldrefcount = sys.getrefcount(b)
m = self._view(b)
self.assertEquals(m[0], item(b"a"))
- self.assert_(isinstance(m[0], bytes), type(m[0]))
+ self.assertTrue(isinstance(m[0], bytes), type(m[0]))
self.assertEquals(m[5], item(b"f"))
self.assertEquals(m[-1], item(b"f"))
self.assertEquals(m[-6], item(b"a"))
@@ -119,7 +119,7 @@
expected = b"".join(
self.getitem_type(bytes([c])) for c in b"abcdef")
self.assertEquals(b, expected)
- self.assert_(isinstance(b, bytes), type(b))
+ self.assertTrue(isinstance(b, bytes), type(b))
def test_tolist(self):
for tp in self._types:
@@ -214,7 +214,7 @@
b = m = o = None
# The cycle must be broken
gc.collect()
- self.assert_(wr() is None, wr())
+ self.assertTrue(wr() is None, wr())
# Variations on source objects for the buffer: bytes-like objects, then arrays
@@ -291,8 +291,8 @@
def test_constructor(self):
for tp in self._types:
ob = tp(self._source)
- self.assert_(memoryview(ob))
- self.assert_(memoryview(object=ob))
+ self.assertTrue(memoryview(ob))
+ self.assertTrue(memoryview(object=ob))
self.assertRaises(TypeError, memoryview)
self.assertRaises(TypeError, memoryview, ob, ob)
self.assertRaises(TypeError, memoryview, argument=ob)
Modified: python/branches/py3k/Lib/test/test_mimetypes.py
==============================================================================
--- python/branches/py3k/Lib/test/test_mimetypes.py (original)
+++ python/branches/py3k/Lib/test/test_mimetypes.py Wed Jul 1 01:06:06 2009
@@ -47,7 +47,7 @@
def test_guess_all_types(self):
eq = self.assertEqual
- unless = self.failUnless
+ unless = self.assertTrue
# First try strict. Use a set here for testing the results because if
# test_urllib2 is run before test_mimetypes, global state is modified
# such that the 'all' set will have more items in it.
Modified: python/branches/py3k/Lib/test/test_minidom.py
==============================================================================
--- python/branches/py3k/Lib/test/test_minidom.py (original)
+++ python/branches/py3k/Lib/test/test_minidom.py Wed Jul 1 01:06:06 2009
@@ -733,7 +733,7 @@
def check_clone_attribute(self, deep, testName):
doc = parseString("<doc attr='value'/>")
attr = doc.documentElement.getAttributeNode("attr")
- self.failIfEqual(attr, None)
+ self.assertNotEqual(attr, None)
clone = attr.cloneNode(deep)
self.confirm(not clone.isSameNode(attr))
self.confirm(not attr.isSameNode(clone))
Modified: python/branches/py3k/Lib/test/test_mmap.py
==============================================================================
--- python/branches/py3k/Lib/test/test_mmap.py (original)
+++ python/branches/py3k/Lib/test/test_mmap.py Wed Jul 1 01:06:06 2009
@@ -501,8 +501,8 @@
f.close()
def test_error(self):
- self.assert_(issubclass(mmap.error, EnvironmentError))
- self.assert_("mmap.error" in str(mmap.error))
+ self.assertTrue(issubclass(mmap.error, EnvironmentError))
+ self.assertTrue("mmap.error" in str(mmap.error))
def test_io_methods(self):
data = b"0123456789"
Modified: python/branches/py3k/Lib/test/test_module.py
==============================================================================
--- python/branches/py3k/Lib/test/test_module.py (original)
+++ python/branches/py3k/Lib/test/test_module.py Wed Jul 1 01:06:06 2009
@@ -10,7 +10,7 @@
# An uninitialized module has no __dict__ or __name__,
# and __doc__ is None
foo = ModuleType.__new__(ModuleType)
- self.failUnless(foo.__dict__ is None)
+ self.assertTrue(foo.__dict__ is None)
try:
s = foo.__name__
self.fail("__name__ = %s" % repr(s))
@@ -52,7 +52,7 @@
self.assertEqual(foo.bar, 42)
self.assertEqual(foo.__dict__,
{"__name__": "foo", "__doc__": "foodoc", "bar": 42})
- self.failUnless(foo.__dict__ is d)
+ self.assertTrue(foo.__dict__ is d)
def test_main():
run_unittest(ModuleTests)
Modified: python/branches/py3k/Lib/test/test_modulefinder.py
==============================================================================
--- python/branches/py3k/Lib/test/test_modulefinder.py (original)
+++ python/branches/py3k/Lib/test/test_modulefinder.py Wed Jul 1 01:06:06 2009
@@ -233,12 +233,12 @@
more = list(found - modules)
less = list(modules - found)
# check if we found what we expected, not more, not less
- self.failUnlessEqual((more, less), ([], []))
+ self.assertEqual((more, less), ([], []))
# check for missing and maybe missing modules
bad, maybe = mf.any_missing_maybe()
- self.failUnlessEqual(bad, missing)
- self.failUnlessEqual(maybe, maybe_missing)
+ self.assertEqual(bad, missing)
+ self.assertEqual(maybe, maybe_missing)
finally:
distutils.dir_util.remove_tree(TEST_DIR)
Modified: python/branches/py3k/Lib/test/test_multibytecodec.py
==============================================================================
--- python/branches/py3k/Lib/test/test_multibytecodec.py (original)
+++ python/branches/py3k/Lib/test/test_multibytecodec.py Wed Jul 1 01:06:06 2009
@@ -242,10 +242,10 @@
self.assertEqual(iso2022jp2.decode('iso2022-jp-2'), uni)
def test_iso2022_jp_g0(self):
- self.failIf(b'\x0e' in '\N{SOFT HYPHEN}'.encode('iso-2022-jp-2'))
+ self.assertFalse(b'\x0e' in '\N{SOFT HYPHEN}'.encode('iso-2022-jp-2'))
for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'):
e = '\u3406'.encode(encoding)
- self.failIf(any(x > 0x80 for x in e))
+ self.assertFalse(any(x > 0x80 for x in e))
def test_bug1572832(self):
if sys.maxunicode >= 0x10000:
Modified: python/branches/py3k/Lib/test/test_multibytecodec_support.py
==============================================================================
--- python/branches/py3k/Lib/test/test_multibytecodec_support.py (original)
+++ python/branches/py3k/Lib/test/test_multibytecodec_support.py Wed Jul 1 01:06:06 2009
@@ -53,9 +53,9 @@
if expected:
result = func(source, scheme)[0]
if func is self.decode:
- self.assert_(type(result) is str, type(result))
+ self.assertTrue(type(result) is str, type(result))
else:
- self.assert_(type(result) is bytes, type(result))
+ self.assertTrue(type(result) is bytes, type(result))
self.assertEqual(result, expected)
else:
self.assertRaises(UnicodeError, func, source, scheme)
Modified: python/branches/py3k/Lib/test/test_netrc.py
==============================================================================
--- python/branches/py3k/Lib/test/test_netrc.py (original)
+++ python/branches/py3k/Lib/test/test_netrc.py Wed Jul 1 01:06:06 2009
@@ -34,11 +34,11 @@
def test_case_1(self):
nrc = netrc.netrc(temp_filename)
- self.assert_(nrc.macros == {'macro1':['line1\n', 'line2\n'],
+ self.assertTrue(nrc.macros == {'macro1':['line1\n', 'line2\n'],
'macro2':['line3\n', 'line4\n']}
)
- self.assert_(nrc.hosts['foo'] == ('log1', 'acct1', 'pass1'))
- self.assert_(nrc.hosts['default'] == ('log2', None, 'pass2'))
+ self.assertTrue(nrc.hosts['foo'] == ('log1', 'acct1', 'pass1'))
+ self.assertTrue(nrc.hosts['default'] == ('log2', None, 'pass2'))
def test_main():
support.run_unittest(NetrcTestCase)
Modified: python/branches/py3k/Lib/test/test_normalization.py
==============================================================================
--- python/branches/py3k/Lib/test/test_normalization.py (original)
+++ python/branches/py3k/Lib/test/test_normalization.py Wed Jul 1 01:06:06 2009
@@ -67,14 +67,14 @@
continue
# Perform tests
- self.failUnless(c2 == NFC(c1) == NFC(c2) == NFC(c3), line)
- self.failUnless(c4 == NFC(c4) == NFC(c5), line)
- self.failUnless(c3 == NFD(c1) == NFD(c2) == NFD(c3), line)
- self.failUnless(c5 == NFD(c4) == NFD(c5), line)
- self.failUnless(c4 == NFKC(c1) == NFKC(c2) == \
+ self.assertTrue(c2 == NFC(c1) == NFC(c2) == NFC(c3), line)
+ self.assertTrue(c4 == NFC(c4) == NFC(c5), line)
+ self.assertTrue(c3 == NFD(c1) == NFD(c2) == NFD(c3), line)
+ self.assertTrue(c5 == NFD(c4) == NFD(c5), line)
+ self.assertTrue(c4 == NFKC(c1) == NFKC(c2) == \
NFKC(c3) == NFKC(c4) == NFKC(c5),
line)
- self.failUnless(c5 == NFKD(c1) == NFKD(c2) == \
+ self.assertTrue(c5 == NFKD(c1) == NFKD(c2) == \
NFKD(c3) == NFKD(c4) == NFKD(c5),
line)
@@ -87,7 +87,7 @@
X = chr(c)
if X in part1_data:
continue
- self.failUnless(X == NFC(X) == NFD(X) == NFKC(X) == NFKD(X), c)
+ self.assertTrue(X == NFC(X) == NFD(X) == NFKC(X) == NFKD(X), c)
def test_bug_834676(self):
# Check for bug 834676
Modified: python/branches/py3k/Lib/test/test_opcodes.py
==============================================================================
--- python/branches/py3k/Lib/test/test_opcodes.py (original)
+++ python/branches/py3k/Lib/test/test_opcodes.py Wed Jul 1 01:06:06 2009
@@ -60,7 +60,7 @@
try: raise DClass(a)
except DClass as v:
- self.assert_(isinstance(v, DClass))
+ self.assertTrue(isinstance(v, DClass))
else:
self.fail("no exception")
Modified: python/branches/py3k/Lib/test/test_operator.py
==============================================================================
--- python/branches/py3k/Lib/test/test_operator.py (original)
+++ python/branches/py3k/Lib/test/test_operator.py Wed Jul 1 01:06:06 2009
@@ -34,237 +34,237 @@
class OperatorTestCase(unittest.TestCase):
def test_lt(self):
- self.failUnlessRaises(TypeError, operator.lt)
- self.failUnlessRaises(TypeError, operator.lt, 1j, 2j)
- self.failIf(operator.lt(1, 0))
- self.failIf(operator.lt(1, 0.0))
- self.failIf(operator.lt(1, 1))
- self.failIf(operator.lt(1, 1.0))
- self.failUnless(operator.lt(1, 2))
- self.failUnless(operator.lt(1, 2.0))
+ self.assertRaises(TypeError, operator.lt)
+ self.assertRaises(TypeError, operator.lt, 1j, 2j)
+ self.assertFalse(operator.lt(1, 0))
+ self.assertFalse(operator.lt(1, 0.0))
+ self.assertFalse(operator.lt(1, 1))
+ self.assertFalse(operator.lt(1, 1.0))
+ self.assertTrue(operator.lt(1, 2))
+ self.assertTrue(operator.lt(1, 2.0))
def test_le(self):
- self.failUnlessRaises(TypeError, operator.le)
- self.failUnlessRaises(TypeError, operator.le, 1j, 2j)
- self.failIf(operator.le(1, 0))
- self.failIf(operator.le(1, 0.0))
- self.failUnless(operator.le(1, 1))
- self.failUnless(operator.le(1, 1.0))
- self.failUnless(operator.le(1, 2))
- self.failUnless(operator.le(1, 2.0))
+ self.assertRaises(TypeError, operator.le)
+ self.assertRaises(TypeError, operator.le, 1j, 2j)
+ self.assertFalse(operator.le(1, 0))
+ self.assertFalse(operator.le(1, 0.0))
+ self.assertTrue(operator.le(1, 1))
+ self.assertTrue(operator.le(1, 1.0))
+ self.assertTrue(operator.le(1, 2))
+ self.assertTrue(operator.le(1, 2.0))
def test_eq(self):
class C(object):
def __eq__(self, other):
raise SyntaxError
- self.failUnlessRaises(TypeError, operator.eq)
- self.failUnlessRaises(SyntaxError, operator.eq, C(), C())
- self.failIf(operator.eq(1, 0))
- self.failIf(operator.eq(1, 0.0))
- self.failUnless(operator.eq(1, 1))
- self.failUnless(operator.eq(1, 1.0))
- self.failIf(operator.eq(1, 2))
- self.failIf(operator.eq(1, 2.0))
+ self.assertRaises(TypeError, operator.eq)
+ self.assertRaises(SyntaxError, operator.eq, C(), C())
+ self.assertFalse(operator.eq(1, 0))
+ self.assertFalse(operator.eq(1, 0.0))
+ self.assertTrue(operator.eq(1, 1))
+ self.assertTrue(operator.eq(1, 1.0))
+ self.assertFalse(operator.eq(1, 2))
+ self.assertFalse(operator.eq(1, 2.0))
def test_ne(self):
class C(object):
def __ne__(self, other):
raise SyntaxError
- self.failUnlessRaises(TypeError, operator.ne)
- self.failUnlessRaises(SyntaxError, operator.ne, C(), C())
- self.failUnless(operator.ne(1, 0))
- self.failUnless(operator.ne(1, 0.0))
- self.failIf(operator.ne(1, 1))
- self.failIf(operator.ne(1, 1.0))
- self.failUnless(operator.ne(1, 2))
- self.failUnless(operator.ne(1, 2.0))
+ self.assertRaises(TypeError, operator.ne)
+ self.assertRaises(SyntaxError, operator.ne, C(), C())
+ self.assertTrue(operator.ne(1, 0))
+ self.assertTrue(operator.ne(1, 0.0))
+ self.assertFalse(operator.ne(1, 1))
+ self.assertFalse(operator.ne(1, 1.0))
+ self.assertTrue(operator.ne(1, 2))
+ self.assertTrue(operator.ne(1, 2.0))
def test_ge(self):
- self.failUnlessRaises(TypeError, operator.ge)
- self.failUnlessRaises(TypeError, operator.ge, 1j, 2j)
- self.failUnless(operator.ge(1, 0))
- self.failUnless(operator.ge(1, 0.0))
- self.failUnless(operator.ge(1, 1))
- self.failUnless(operator.ge(1, 1.0))
- self.failIf(operator.ge(1, 2))
- self.failIf(operator.ge(1, 2.0))
+ self.assertRaises(TypeError, operator.ge)
+ self.assertRaises(TypeError, operator.ge, 1j, 2j)
+ self.assertTrue(operator.ge(1, 0))
+ self.assertTrue(operator.ge(1, 0.0))
+ self.assertTrue(operator.ge(1, 1))
+ self.assertTrue(operator.ge(1, 1.0))
+ self.assertFalse(operator.ge(1, 2))
+ self.assertFalse(operator.ge(1, 2.0))
def test_gt(self):
- self.failUnlessRaises(TypeError, operator.gt)
- self.failUnlessRaises(TypeError, operator.gt, 1j, 2j)
- self.failUnless(operator.gt(1, 0))
- self.failUnless(operator.gt(1, 0.0))
- self.failIf(operator.gt(1, 1))
- self.failIf(operator.gt(1, 1.0))
- self.failIf(operator.gt(1, 2))
- self.failIf(operator.gt(1, 2.0))
+ self.assertRaises(TypeError, operator.gt)
+ self.assertRaises(TypeError, operator.gt, 1j, 2j)
+ self.assertTrue(operator.gt(1, 0))
+ self.assertTrue(operator.gt(1, 0.0))
+ self.assertFalse(operator.gt(1, 1))
+ self.assertFalse(operator.gt(1, 1.0))
+ self.assertFalse(operator.gt(1, 2))
+ self.assertFalse(operator.gt(1, 2.0))
def test_abs(self):
- self.failUnlessRaises(TypeError, operator.abs)
- self.failUnlessRaises(TypeError, operator.abs, None)
+ self.assertRaises(TypeError, operator.abs)
+ self.assertRaises(TypeError, operator.abs, None)
self.assertEqual(operator.abs(-1), 1)
self.assertEqual(operator.abs(1), 1)
def test_add(self):
- self.failUnlessRaises(TypeError, operator.add)
- self.failUnlessRaises(TypeError, operator.add, None, None)
- self.failUnless(operator.add(3, 4) == 7)
+ self.assertRaises(TypeError, operator.add)
+ self.assertRaises(TypeError, operator.add, None, None)
+ self.assertTrue(operator.add(3, 4) == 7)
def test_bitwise_and(self):
- self.failUnlessRaises(TypeError, operator.and_)
- self.failUnlessRaises(TypeError, operator.and_, None, None)
- self.failUnless(operator.and_(0xf, 0xa) == 0xa)
+ self.assertRaises(TypeError, operator.and_)
+ self.assertRaises(TypeError, operator.and_, None, None)
+ self.assertTrue(operator.and_(0xf, 0xa) == 0xa)
def test_concat(self):
- self.failUnlessRaises(TypeError, operator.concat)
- self.failUnlessRaises(TypeError, operator.concat, None, None)
- self.failUnless(operator.concat('py', 'thon') == 'python')
- self.failUnless(operator.concat([1, 2], [3, 4]) == [1, 2, 3, 4])
- self.failUnless(operator.concat(Seq1([5, 6]), Seq1([7])) == [5, 6, 7])
- self.failUnless(operator.concat(Seq2([5, 6]), Seq2([7])) == [5, 6, 7])
- self.failUnlessRaises(TypeError, operator.concat, 13, 29)
+ self.assertRaises(TypeError, operator.concat)
+ self.assertRaises(TypeError, operator.concat, None, None)
+ self.assertTrue(operator.concat('py', 'thon') == 'python')
+ self.assertTrue(operator.concat([1, 2], [3, 4]) == [1, 2, 3, 4])
+ self.assertTrue(operator.concat(Seq1([5, 6]), Seq1([7])) == [5, 6, 7])
+ self.assertTrue(operator.concat(Seq2([5, 6]), Seq2([7])) == [5, 6, 7])
+ self.assertRaises(TypeError, operator.concat, 13, 29)
def test_countOf(self):
- self.failUnlessRaises(TypeError, operator.countOf)
- self.failUnlessRaises(TypeError, operator.countOf, None, None)
- self.failUnless(operator.countOf([1, 2, 1, 3, 1, 4], 3) == 1)
- self.failUnless(operator.countOf([1, 2, 1, 3, 1, 4], 5) == 0)
+ self.assertRaises(TypeError, operator.countOf)
+ self.assertRaises(TypeError, operator.countOf, None, None)
+ self.assertTrue(operator.countOf([1, 2, 1, 3, 1, 4], 3) == 1)
+ self.assertTrue(operator.countOf([1, 2, 1, 3, 1, 4], 5) == 0)
def test_delitem(self):
a = [4, 3, 2, 1]
- self.failUnlessRaises(TypeError, operator.delitem, a)
- self.failUnlessRaises(TypeError, operator.delitem, a, None)
- self.failUnless(operator.delitem(a, 1) is None)
- self.assert_(a == [4, 2, 1])
+ self.assertRaises(TypeError, operator.delitem, a)
+ self.assertRaises(TypeError, operator.delitem, a, None)
+ self.assertTrue(operator.delitem(a, 1) is None)
+ self.assertTrue(a == [4, 2, 1])
def test_floordiv(self):
- self.failUnlessRaises(TypeError, operator.floordiv, 5)
- self.failUnlessRaises(TypeError, operator.floordiv, None, None)
- self.failUnless(operator.floordiv(5, 2) == 2)
+ self.assertRaises(TypeError, operator.floordiv, 5)
+ self.assertRaises(TypeError, operator.floordiv, None, None)
+ self.assertTrue(operator.floordiv(5, 2) == 2)
def test_truediv(self):
- self.failUnlessRaises(TypeError, operator.truediv, 5)
- self.failUnlessRaises(TypeError, operator.truediv, None, None)
- self.failUnless(operator.truediv(5, 2) == 2.5)
+ self.assertRaises(TypeError, operator.truediv, 5)
+ self.assertRaises(TypeError, operator.truediv, None, None)
+ self.assertTrue(operator.truediv(5, 2) == 2.5)
def test_getitem(self):
a = range(10)
- self.failUnlessRaises(TypeError, operator.getitem)
- self.failUnlessRaises(TypeError, operator.getitem, a, None)
- self.failUnless(operator.getitem(a, 2) == 2)
+ self.assertRaises(TypeError, operator.getitem)
+ self.assertRaises(TypeError, operator.getitem, a, None)
+ self.assertTrue(operator.getitem(a, 2) == 2)
def test_indexOf(self):
- self.failUnlessRaises(TypeError, operator.indexOf)
- self.failUnlessRaises(TypeError, operator.indexOf, None, None)
- self.failUnless(operator.indexOf([4, 3, 2, 1], 3) == 1)
+ self.assertRaises(TypeError, operator.indexOf)
+ self.assertRaises(TypeError, operator.indexOf, None, None)
+ self.assertTrue(operator.indexOf([4, 3, 2, 1], 3) == 1)
self.assertRaises(ValueError, operator.indexOf, [4, 3, 2, 1], 0)
def test_invert(self):
- self.failUnlessRaises(TypeError, operator.invert)
- self.failUnlessRaises(TypeError, operator.invert, None)
+ self.assertRaises(TypeError, operator.invert)
+ self.assertRaises(TypeError, operator.invert, None)
self.assertEqual(operator.inv(4), -5)
def test_lshift(self):
- self.failUnlessRaises(TypeError, operator.lshift)
- self.failUnlessRaises(TypeError, operator.lshift, None, 42)
- self.failUnless(operator.lshift(5, 1) == 10)
- self.failUnless(operator.lshift(5, 0) == 5)
+ self.assertRaises(TypeError, operator.lshift)
+ self.assertRaises(TypeError, operator.lshift, None, 42)
+ self.assertTrue(operator.lshift(5, 1) == 10)
+ self.assertTrue(operator.lshift(5, 0) == 5)
self.assertRaises(ValueError, operator.lshift, 2, -1)
def test_mod(self):
- self.failUnlessRaises(TypeError, operator.mod)
- self.failUnlessRaises(TypeError, operator.mod, None, 42)
- self.failUnless(operator.mod(5, 2) == 1)
+ self.assertRaises(TypeError, operator.mod)
+ self.assertRaises(TypeError, operator.mod, None, 42)
+ self.assertTrue(operator.mod(5, 2) == 1)
def test_mul(self):
- self.failUnlessRaises(TypeError, operator.mul)
- self.failUnlessRaises(TypeError, operator.mul, None, None)
- self.failUnless(operator.mul(5, 2) == 10)
+ self.assertRaises(TypeError, operator.mul)
+ self.assertRaises(TypeError, operator.mul, None, None)
+ self.assertTrue(operator.mul(5, 2) == 10)
def test_neg(self):
- self.failUnlessRaises(TypeError, operator.neg)
- self.failUnlessRaises(TypeError, operator.neg, None)
+ self.assertRaises(TypeError, operator.neg)
+ self.assertRaises(TypeError, operator.neg, None)
self.assertEqual(operator.neg(5), -5)
self.assertEqual(operator.neg(-5), 5)
self.assertEqual(operator.neg(0), 0)
self.assertEqual(operator.neg(-0), 0)
def test_bitwise_or(self):
- self.failUnlessRaises(TypeError, operator.or_)
- self.failUnlessRaises(TypeError, operator.or_, None, None)
- self.failUnless(operator.or_(0xa, 0x5) == 0xf)
+ self.assertRaises(TypeError, operator.or_)
+ self.assertRaises(TypeError, operator.or_, None, None)
+ self.assertTrue(operator.or_(0xa, 0x5) == 0xf)
def test_pos(self):
- self.failUnlessRaises(TypeError, operator.pos)
- self.failUnlessRaises(TypeError, operator.pos, None)
+ self.assertRaises(TypeError, operator.pos)
+ self.assertRaises(TypeError, operator.pos, None)
self.assertEqual(operator.pos(5), 5)
self.assertEqual(operator.pos(-5), -5)
self.assertEqual(operator.pos(0), 0)
self.assertEqual(operator.pos(-0), 0)
def test_pow(self):
- self.failUnlessRaises(TypeError, operator.pow)
- self.failUnlessRaises(TypeError, operator.pow, None, None)
+ self.assertRaises(TypeError, operator.pow)
+ self.assertRaises(TypeError, operator.pow, None, None)
self.assertEqual(operator.pow(3,5), 3**5)
self.assertEqual(operator.__pow__(3,5), 3**5)
self.assertRaises(TypeError, operator.pow, 1)
self.assertRaises(TypeError, operator.pow, 1, 2, 3)
def test_rshift(self):
- self.failUnlessRaises(TypeError, operator.rshift)
- self.failUnlessRaises(TypeError, operator.rshift, None, 42)
- self.failUnless(operator.rshift(5, 1) == 2)
- self.failUnless(operator.rshift(5, 0) == 5)
+ self.assertRaises(TypeError, operator.rshift)
+ self.assertRaises(TypeError, operator.rshift, None, 42)
+ self.assertTrue(operator.rshift(5, 1) == 2)
+ self.assertTrue(operator.rshift(5, 0) == 5)
self.assertRaises(ValueError, operator.rshift, 2, -1)
def test_contains(self):
- self.failUnlessRaises(TypeError, operator.contains)
- self.failUnlessRaises(TypeError, operator.contains, None, None)
- self.failUnless(operator.contains(range(4), 2))
- self.failIf(operator.contains(range(4), 5))
+ self.assertRaises(TypeError, operator.contains)
+ self.assertRaises(TypeError, operator.contains, None, None)
+ self.assertTrue(operator.contains(range(4), 2))
+ self.assertFalse(operator.contains(range(4), 5))
def test_setitem(self):
a = list(range(3))
- self.failUnlessRaises(TypeError, operator.setitem, a)
- self.failUnlessRaises(TypeError, operator.setitem, a, None, None)
- self.failUnless(operator.setitem(a, 0, 2) is None)
- self.assert_(a == [2, 1, 2])
+ self.assertRaises(TypeError, operator.setitem, a)
+ self.assertRaises(TypeError, operator.setitem, a, None, None)
+ self.assertTrue(operator.setitem(a, 0, 2) is None)
+ self.assertTrue(a == [2, 1, 2])
self.assertRaises(IndexError, operator.setitem, a, 4, 2)
def test_sub(self):
- self.failUnlessRaises(TypeError, operator.sub)
- self.failUnlessRaises(TypeError, operator.sub, None, None)
- self.failUnless(operator.sub(5, 2) == 3)
+ self.assertRaises(TypeError, operator.sub)
+ self.assertRaises(TypeError, operator.sub, None, None)
+ self.assertTrue(operator.sub(5, 2) == 3)
def test_truth(self):
class C(object):
def __bool__(self):
raise SyntaxError
- self.failUnlessRaises(TypeError, operator.truth)
- self.failUnlessRaises(SyntaxError, operator.truth, C())
- self.failUnless(operator.truth(5))
- self.failUnless(operator.truth([0]))
- self.failIf(operator.truth(0))
- self.failIf(operator.truth([]))
+ self.assertRaises(TypeError, operator.truth)
+ self.assertRaises(SyntaxError, operator.truth, C())
+ self.assertTrue(operator.truth(5))
+ self.assertTrue(operator.truth([0]))
+ self.assertFalse(operator.truth(0))
+ self.assertFalse(operator.truth([]))
def test_bitwise_xor(self):
- self.failUnlessRaises(TypeError, operator.xor)
- self.failUnlessRaises(TypeError, operator.xor, None, None)
- self.failUnless(operator.xor(0xb, 0xc) == 0x7)
+ self.assertRaises(TypeError, operator.xor)
+ self.assertRaises(TypeError, operator.xor, None, None)
+ self.assertTrue(operator.xor(0xb, 0xc) == 0x7)
def test_is(self):
a = b = 'xyzpdq'
c = a[:3] + b[3:]
- self.failUnlessRaises(TypeError, operator.is_)
- self.failUnless(operator.is_(a, b))
- self.failIf(operator.is_(a,c))
+ self.assertRaises(TypeError, operator.is_)
+ self.assertTrue(operator.is_(a, b))
+ self.assertFalse(operator.is_(a,c))
def test_is_not(self):
a = b = 'xyzpdq'
c = a[:3] + b[3:]
- self.failUnlessRaises(TypeError, operator.is_not)
- self.failIf(operator.is_not(a, b))
- self.failUnless(operator.is_not(a,c))
+ self.assertRaises(TypeError, operator.is_not)
+ self.assertFalse(operator.is_not(a, b))
+ self.assertTrue(operator.is_not(a,c))
def test_attrgetter(self):
class A:
@@ -290,7 +290,7 @@
class C(object):
def __getattr__(self, name):
raise SyntaxError
- self.failUnlessRaises(SyntaxError, operator.attrgetter('foo'), C())
+ self.assertRaises(SyntaxError, operator.attrgetter('foo'), C())
# recursive gets
a = A()
@@ -322,7 +322,7 @@
class C(object):
def __getitem__(self, name):
raise SyntaxError
- self.failUnlessRaises(SyntaxError, operator.itemgetter(42), C())
+ self.assertRaises(SyntaxError, operator.itemgetter(42), C())
f = operator.itemgetter('name')
self.assertRaises(TypeError, f, a)
Modified: python/branches/py3k/Lib/test/test_optparse.py
==============================================================================
--- python/branches/py3k/Lib/test/test_optparse.py (original)
+++ python/branches/py3k/Lib/test/test_optparse.py Wed Jul 1 01:06:06 2009
@@ -109,7 +109,7 @@
except expected_exception as err:
actual_message = str(err)
if isinstance(expected_message, retype):
- self.assert_(expected_message.search(actual_message),
+ self.assertTrue(expected_message.search(actual_message),
"""\
expected exception message pattern:
/%s/
@@ -165,7 +165,7 @@
sys.stdout = save_stdout
except InterceptedError as err:
- self.assert_(
+ self.assertTrue(
isinstance(output, str),
"expected output to be an ordinary string, not %r"
% type(output))
@@ -338,7 +338,7 @@
def test_get_option(self):
opt1 = self.parser.get_option("-v")
- self.assert_(isinstance(opt1, Option))
+ self.assertTrue(isinstance(opt1, Option))
self.assertEqual(opt1._short_opts, ["-v", "-n"])
self.assertEqual(opt1._long_opts, ["--verbose", "--noisy"])
self.assertEqual(opt1.action, "store_true")
@@ -349,33 +349,33 @@
opt2 = self.parser.get_option("--verbose")
opt3 = self.parser.get_option("-n")
opt4 = self.parser.get_option("--noisy")
- self.assert_(opt1 is opt2 is opt3 is opt4)
+ self.assertTrue(opt1 is opt2 is opt3 is opt4)
def test_has_option(self):
- self.assert_(self.parser.has_option("-v"))
- self.assert_(self.parser.has_option("--verbose"))
+ self.assertTrue(self.parser.has_option("-v"))
+ self.assertTrue(self.parser.has_option("--verbose"))
- def assert_removed(self):
- self.assert_(self.parser.get_option("-v") is None)
- self.assert_(self.parser.get_option("--verbose") is None)
- self.assert_(self.parser.get_option("-n") is None)
- self.assert_(self.parser.get_option("--noisy") is None)
-
- self.failIf(self.parser.has_option("-v"))
- self.failIf(self.parser.has_option("--verbose"))
- self.failIf(self.parser.has_option("-n"))
- self.failIf(self.parser.has_option("--noisy"))
+ def assertTrueremoved(self):
+ self.assertTrue(self.parser.get_option("-v") is None)
+ self.assertTrue(self.parser.get_option("--verbose") is None)
+ self.assertTrue(self.parser.get_option("-n") is None)
+ self.assertTrue(self.parser.get_option("--noisy") is None)
+
+ self.assertFalse(self.parser.has_option("-v"))
+ self.assertFalse(self.parser.has_option("--verbose"))
+ self.assertFalse(self.parser.has_option("-n"))
+ self.assertFalse(self.parser.has_option("--noisy"))
- self.assert_(self.parser.has_option("-q"))
- self.assert_(self.parser.has_option("--silent"))
+ self.assertTrue(self.parser.has_option("-q"))
+ self.assertTrue(self.parser.has_option("--silent"))
def test_remove_short_opt(self):
self.parser.remove_option("-n")
- self.assert_removed()
+ self.assertTrueremoved()
def test_remove_long_opt(self):
self.parser.remove_option("--verbose")
- self.assert_removed()
+ self.assertTrueremoved()
def test_remove_nonexistent(self):
self.assertRaises(self.parser.remove_option, ('foo',), None,
@@ -779,14 +779,14 @@
{'verbose': 0},
[])
if hasattr(__builtins__, 'False'):
- self.failUnless(options.verbose is False)
+ self.assertTrue(options.verbose is False)
def test_bool_true(self):
(options, args) = self.assertParseOK(["-v"],
{'verbose': 1},
[])
if hasattr(__builtins__, 'True'):
- self.failUnless(options.verbose is True)
+ self.assertTrue(options.verbose is True)
def test_bool_flicker_on_and_off(self):
self.assertParseOK(["-qvq", "-q", "-v"],
@@ -992,7 +992,7 @@
description="Some more options")
group.set_title("Bacon")
group.add_option("--bacon", type="int")
- self.assert_(self.parser.get_option_group("--bacon"), group)
+ self.assertTrue(self.parser.get_option_group("--bacon"), group)
# -- Test extending and parser.parse_args() ----------------------------
@@ -1088,15 +1088,15 @@
if opt == "-x":
self.assertEqual(option._short_opts, ["-x"])
self.assertEqual(option._long_opts, [])
- self.assert_(parser_ is self.parser)
- self.assert_(value is None)
+ self.assertTrue(parser_ is self.parser)
+ self.assertTrue(value is None)
self.assertEqual(vars(parser_.values), {'filename': None})
parser_.values.x = 42
elif opt == "--file":
self.assertEqual(option._short_opts, ["-f"])
self.assertEqual(option._long_opts, ["--file"])
- self.assert_(parser_ is self.parser)
+ self.assertTrue(parser_ is self.parser)
self.assertEqual(value, "foo")
self.assertEqual(vars(parser_.values), {'filename': None, 'x': 42})
@@ -1134,7 +1134,7 @@
def process_tuple(self, option, opt, value, parser_, len, type):
self.assertEqual(len, 3)
- self.assert_(type is int)
+ self.assertTrue(type is int)
if opt == "-p":
self.assertEqual(value, "1,2,3")
@@ -1225,7 +1225,7 @@
option_list=options)
def variable_args(self, option, opt, value, parser):
- self.assert_(value is None)
+ self.assertTrue(value is None)
done = 0
value = []
rargs = parser.rargs
@@ -1281,7 +1281,7 @@
class TestConflict(ConflictBase):
"""Use the default conflict resolution for Optik 1.2: error."""
- def assert_conflict_error(self, func):
+ def assertTrueconflict_error(self, func):
err = self.assertRaises(
func, ("-v", "--version"), {'action' : "callback",
'callback' : self.show_version,
@@ -1293,11 +1293,11 @@
self.assertEqual(err.option_id, "-v/--version")
def test_conflict_error(self):
- self.assert_conflict_error(self.parser.add_option)
+ self.assertTrueconflict_error(self.parser.add_option)
def test_conflict_error_group(self):
group = OptionGroup(self.parser, "Group 1")
- self.assert_conflict_error(group.add_option)
+ self.assertTrueconflict_error(group.add_option)
def test_no_such_conflict_handler(self):
self.assertRaises(
@@ -1317,8 +1317,8 @@
verbose_opt = self.parser.get_option("--verbose")
version_opt = self.parser.get_option("--version")
- self.assert_(v_opt is version_opt)
- self.assert_(v_opt is not verbose_opt)
+ self.assertTrue(v_opt is version_opt)
+ self.assertTrue(v_opt is not verbose_opt)
self.assertEqual(v_opt._long_opts, ["--version"])
self.assertEqual(version_opt._short_opts, ["-v"])
self.assertEqual(version_opt._long_opts, ["--version"])
Modified: python/branches/py3k/Lib/test/test_os.py
==============================================================================
--- python/branches/py3k/Lib/test/test_os.py (original)
+++ python/branches/py3k/Lib/test/test_os.py Wed Jul 1 01:06:06 2009
@@ -20,7 +20,7 @@
def test_access(self):
f = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR)
os.close(f)
- self.assert_(os.access(support.TESTFN, os.W_OK))
+ self.assertTrue(os.access(support.TESTFN, os.W_OK))
def test_closerange(self):
first = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR)
@@ -85,7 +85,7 @@
def check_tempfile(self, name):
# make sure it doesn't already exist:
- self.failIf(os.path.exists(name),
+ self.assertFalse(os.path.exists(name),
"file already exists for temporary file")
# make sure we can create the file
open(name, "w")
@@ -102,7 +102,7 @@
self.check_tempfile(name)
name = os.tempnam(support.TESTFN, "pfx")
- self.assert_(os.path.basename(name)[:3] == "pfx")
+ self.assertTrue(os.path.basename(name)[:3] == "pfx")
self.check_tempfile(name)
def test_tmpfile(self):
@@ -151,7 +151,7 @@
fp.seek(0,0)
s = fp.read()
fp.close()
- self.assert_(s == "foobar")
+ self.assertTrue(s == "foobar")
def test_tmpnam(self):
import sys
@@ -176,7 +176,7 @@
# the root of the current drive. That's a terrible place to
# put temp files, and, depending on privileges, the user
# may not even be able to open a file in the root directory.
- self.failIf(os.path.exists(name),
+ self.assertFalse(os.path.exists(name),
"file already exists for temporary file")
else:
self.check_tempfile(name)
@@ -228,7 +228,7 @@
def trunc(x): return x
self.assertEquals(trunc(getattr(result, attr)),
result[getattr(stat, name)])
- self.assert_(attr in members)
+ self.assertTrue(attr in members)
try:
result[200]
@@ -520,7 +520,7 @@
os.makedirs(path)
# Try paths with a '.' in them
- self.failUnlessRaises(OSError, os.makedirs, os.curdir)
+ self.assertRaises(OSError, os.makedirs, os.curdir)
path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4', 'dir5', os.curdir)
os.makedirs(path)
path = os.path.join(base, 'dir1', os.curdir, 'dir2', 'dir3', 'dir4',
Modified: python/branches/py3k/Lib/test/test_ossaudiodev.py
==============================================================================
--- python/branches/py3k/Lib/test/test_ossaudiodev.py (original)
+++ python/branches/py3k/Lib/test/test_ossaudiodev.py Wed Jul 1 01:06:06 2009
@@ -58,7 +58,7 @@
dsp.fileno()
# Make sure the read-only attributes work.
- self.failIf(dsp.closed)
+ self.assertFalse(dsp.closed)
self.assertEqual(dsp.name, "/dev/dsp")
self.assertEqual(dsp.mode, "w", "bad dsp.mode: %r" % dsp.mode)
@@ -84,7 +84,7 @@
elapsed_time = t2 - t1
percent_diff = (abs(elapsed_time - expected_time) / expected_time) * 100
- self.failUnless(percent_diff <= 10.0,
+ self.assertTrue(percent_diff <= 10.0,
"elapsed time (%s) > 10%% off of expected time (%s)" %
(elapsed_time, expected_time))
@@ -133,7 +133,7 @@
]:
(fmt, channels, rate) = config
result = dsp.setparameters(fmt, channels, rate, False)
- self.failIfEqual(result, config,
+ self.assertNotEqual(result, config,
"unexpectedly got requested configuration")
try:
@@ -157,7 +157,7 @@
#self.set_bad_parameters(dsp)
finally:
dsp.close()
- self.failUnless(dsp.closed)
+ self.assertTrue(dsp.closed)
def test_main():
Modified: python/branches/py3k/Lib/test/test_parser.py
==============================================================================
--- python/branches/py3k/Lib/test/test_parser.py (original)
+++ python/branches/py3k/Lib/test/test_parser.py Wed Jul 1 01:06:06 2009
@@ -546,15 +546,15 @@
bottom = min(st1, st2, st3)
top = max(st1, st2, st3)
mid = sorted([st1, st2, st3])[1]
- self.assert_(bottom < mid)
- self.assert_(bottom < top)
- self.assert_(mid < top)
- self.assert_(bottom <= mid)
- self.assert_(bottom <= top)
- self.assert_(mid <= top)
- self.assert_(bottom <= bottom)
- self.assert_(mid <= mid)
- self.assert_(top <= top)
+ self.assertTrue(bottom < mid)
+ self.assertTrue(bottom < top)
+ self.assertTrue(mid < top)
+ self.assertTrue(bottom <= mid)
+ self.assertTrue(bottom <= top)
+ self.assertTrue(mid <= top)
+ self.assertTrue(bottom <= bottom)
+ self.assertTrue(mid <= mid)
+ self.assertTrue(top <= top)
# interaction with other types
self.assertEquals(st1 == 1588.602459, False)
self.assertEquals('spanish armada' != st2, True)
Modified: python/branches/py3k/Lib/test/test_peepholer.py
==============================================================================
--- python/branches/py3k/Lib/test/test_peepholer.py (original)
+++ python/branches/py3k/Lib/test/test_peepholer.py Wed Jul 1 01:06:06 2009
@@ -25,9 +25,9 @@
del x
asm = disassemble(unot)
for elem in ('UNARY_NOT', 'POP_JUMP_IF_FALSE'):
- self.assert_(elem not in asm)
+ self.assertTrue(elem not in asm)
for elem in ('POP_JUMP_IF_TRUE',):
- self.assert_(elem in asm)
+ self.assertTrue(elem in asm)
def test_elim_inversion_of_is_or_in(self):
for line, elem in (
@@ -37,7 +37,7 @@
('not a not in b', '(in)',),
):
asm = dis_single(line)
- self.assert_(elem in asm)
+ self.assertTrue(elem in asm)
def test_global_as_constant(self):
# LOAD_GLOBAL None/True/False --> LOAD_CONST None/True/False
@@ -54,14 +54,14 @@
for func, name in ((f, 'None'), (g, 'True'), (h, 'False')):
asm = disassemble(func)
for elem in ('LOAD_GLOBAL',):
- self.assert_(elem not in asm)
+ self.assertTrue(elem not in asm)
for elem in ('LOAD_CONST', '('+name+')'):
- self.assert_(elem in asm)
+ self.assertTrue(elem in asm)
def f():
'Adding a docstring made this test fail in Py2.5.0'
return None
- self.assert_('LOAD_CONST' in disassemble(f))
- self.assert_('LOAD_GLOBAL' not in disassemble(f))
+ self.assertTrue('LOAD_CONST' in disassemble(f))
+ self.assertTrue('LOAD_GLOBAL' not in disassemble(f))
def test_while_one(self):
# Skip over: LOAD_CONST trueconst POP_JUMP_IF_FALSE xx
@@ -71,9 +71,9 @@
return list
asm = disassemble(f)
for elem in ('LOAD_CONST', 'POP_JUMP_IF_FALSE'):
- self.assert_(elem not in asm)
+ self.assertTrue(elem not in asm)
for elem in ('JUMP_ABSOLUTE',):
- self.assert_(elem in asm)
+ self.assertTrue(elem in asm)
def test_pack_unpack(self):
for line, elem in (
@@ -82,9 +82,9 @@
('a, b, c = a, b, c', 'ROT_THREE',),
):
asm = dis_single(line)
- self.assert_(elem in asm)
- self.assert_('BUILD_TUPLE' not in asm)
- self.assert_('UNPACK_TUPLE' not in asm)
+ self.assertTrue(elem in asm)
+ self.assertTrue('BUILD_TUPLE' not in asm)
+ self.assertTrue('UNPACK_TUPLE' not in asm)
def test_folding_of_tuples_of_constants(self):
for line, elem in (
@@ -95,8 +95,8 @@
('((1, 2), 3, 4)', '(((1, 2), 3, 4))'),
):
asm = dis_single(line)
- self.assert_(elem in asm)
- self.assert_('BUILD_TUPLE' not in asm)
+ self.assertTrue(elem in asm)
+ self.assertTrue('BUILD_TUPLE' not in asm)
# Bug 1053819: Tuple of constants misidentified when presented with:
# . . . opcode_with_arg 100 unary_opcode BUILD_TUPLE 1 . . .
@@ -134,17 +134,17 @@
('a = 13 | 7', '(15)'), # binary or
):
asm = dis_single(line)
- self.assert_(elem in asm, asm)
- self.assert_('BINARY_' not in asm)
+ self.assertTrue(elem in asm, asm)
+ self.assertTrue('BINARY_' not in asm)
# Verify that unfoldables are skipped
asm = dis_single('a=2+"b"')
- self.assert_('(2)' in asm)
- self.assert_("('b')" in asm)
+ self.assertTrue('(2)' in asm)
+ self.assertTrue("('b')" in asm)
# Verify that large sequences do not result from folding
asm = dis_single('a="x"*1000')
- self.assert_('(1000)' in asm)
+ self.assertTrue('(1000)' in asm)
def test_folding_of_unaryops_on_constants(self):
for line, elem in (
@@ -152,8 +152,8 @@
('~-2', '(1)'), # unary invert
):
asm = dis_single(line)
- self.assert_(elem in asm, asm)
- self.assert_('UNARY_' not in asm)
+ self.assertTrue(elem in asm, asm)
+ self.assertTrue('UNARY_' not in asm)
# Verify that unfoldables are skipped
for line, elem in (
@@ -161,16 +161,16 @@
('~"abc"', "('abc')"), # unary invert
):
asm = dis_single(line)
- self.assert_(elem in asm, asm)
- self.assert_('UNARY_' in asm)
+ self.assertTrue(elem in asm, asm)
+ self.assertTrue('UNARY_' in asm)
def test_elim_extra_return(self):
# RETURN LOAD_CONST None RETURN --> RETURN
def f(x):
return x
asm = disassemble(f)
- self.assert_('LOAD_CONST' not in asm)
- self.assert_('(None)' not in asm)
+ self.assertTrue('LOAD_CONST' not in asm)
+ self.assertTrue('(None)' not in asm)
self.assertEqual(asm.split().count('RETURN_VALUE'), 1)
def test_elim_jump_to_return(self):
@@ -178,8 +178,8 @@
def f(cond, true_value, false_value):
return true_value if cond else false_value
asm = disassemble(f)
- self.assert_('JUMP_FORWARD' not in asm)
- self.assert_('JUMP_ABSOLUTE' not in asm)
+ self.assertTrue('JUMP_FORWARD' not in asm)
+ self.assertTrue('JUMP_ABSOLUTE' not in asm)
self.assertEqual(asm.split().count('RETURN_VALUE'), 2)
def test_elim_jump_after_return1(self):
@@ -194,8 +194,8 @@
return 5
return 6
asm = disassemble(f)
- self.assert_('JUMP_FORWARD' not in asm)
- self.assert_('JUMP_ABSOLUTE' not in asm)
+ self.assertTrue('JUMP_FORWARD' not in asm)
+ self.assertTrue('JUMP_ABSOLUTE' not in asm)
self.assertEqual(asm.split().count('RETURN_VALUE'), 6)
def test_elim_jump_after_return2(self):
@@ -204,7 +204,7 @@
while 1:
if cond1: return 4
asm = disassemble(f)
- self.assert_('JUMP_FORWARD' not in asm)
+ self.assertTrue('JUMP_FORWARD' not in asm)
# There should be one jump for the while loop.
self.assertEqual(asm.split().count('JUMP_ABSOLUTE'), 1)
self.assertEqual(asm.split().count('RETURN_VALUE'), 2)
@@ -215,7 +215,7 @@
pass
return g
asm = disassemble(f)
- self.assert_('BINARY_ADD' not in asm)
+ self.assertTrue('BINARY_ADD' not in asm)
def test_main(verbose=None):
Modified: python/branches/py3k/Lib/test/test_pep247.py
==============================================================================
--- python/branches/py3k/Lib/test/test_pep247.py (original)
+++ python/branches/py3k/Lib/test/test_pep247.py Wed Jul 1 01:06:06 2009
@@ -11,8 +11,8 @@
class Pep247Test(unittest.TestCase):
def check_module(self, module, key=None):
- self.assert_(hasattr(module, 'digest_size'))
- self.assert_(module.digest_size is None or module.digest_size > 0)
+ self.assertTrue(hasattr(module, 'digest_size'))
+ self.assertTrue(module.digest_size is None or module.digest_size > 0)
self.check_object(module.new, module.digest_size, key)
def check_object(self, cls, digest_size, key):
@@ -31,7 +31,7 @@
obj3.update(b'string')
h2 = obj3.digest()
self.assertEquals(h1, h2)
- self.assert_(hasattr(obj1, 'digest_size'))
+ self.assertTrue(hasattr(obj1, 'digest_size'))
if digest_size is not None:
self.assertEquals(obj1.digest_size, digest_size)
Modified: python/branches/py3k/Lib/test/test_pep277.py
==============================================================================
--- python/branches/py3k/Lib/test/test_pep277.py (original)
+++ python/branches/py3k/Lib/test/test_pep277.py Wed Jul 1 01:06:06 2009
@@ -82,8 +82,8 @@
sys.getfilesystemencoding()))
sf2 = set("\\".join((str(support.TESTFN), f))
for f in f2)
- self.failUnlessEqual(len(f1), len(self.files))
- self.failUnlessEqual(sf2, set(self.files))
+ self.assertEqual(len(f1), len(self.files))
+ self.assertEqual(sf2, set(self.files))
def test_rename(self):
for name in self.files:
Modified: python/branches/py3k/Lib/test/test_pep3120.py
==============================================================================
Binary files. No diff available.
Modified: python/branches/py3k/Lib/test/test_pep352.py
==============================================================================
--- python/branches/py3k/Lib/test/test_pep352.py (original)
+++ python/branches/py3k/Lib/test/test_pep352.py Wed Jul 1 01:06:06 2009
@@ -12,7 +12,7 @@
inheritance hierarchy)"""
def test_builtins_new_style(self):
- self.failUnless(issubclass(Exception, object))
+ self.assertTrue(issubclass(Exception, object))
def verify_instance_interface(self, ins):
for attr in ("args", "__str__", "__repr__"):
@@ -38,7 +38,7 @@
last_exc = getattr(builtins, superclass_name)
except AttributeError:
self.fail("base class %s not a built-in" % superclass_name)
- self.failUnless(superclass_name in exc_set,
+ self.assertTrue(superclass_name in exc_set,
'%s not found' % superclass_name)
exc_set.discard(superclass_name)
superclasses = [] # Loop will insert base exception
@@ -66,20 +66,20 @@
elif last_depth > depth:
while superclasses[-1][0] >= depth:
superclasses.pop()
- self.failUnless(issubclass(exc, superclasses[-1][1]),
+ self.assertTrue(issubclass(exc, superclasses[-1][1]),
"%s is not a subclass of %s" % (exc.__name__,
superclasses[-1][1].__name__))
try: # Some exceptions require arguments; just skip them
self.verify_instance_interface(exc())
except TypeError:
pass
- self.failUnless(exc_name in exc_set)
+ self.assertTrue(exc_name in exc_set)
exc_set.discard(exc_name)
last_exc = exc
last_depth = depth
finally:
inheritance_tree.close()
- self.failUnlessEqual(len(exc_set), 0, "%s not accounted for" % exc_set)
+ self.assertEqual(len(exc_set), 0, "%s not accounted for" % exc_set)
interface_tests = ("length", "args", "str", "repr")
Modified: python/branches/py3k/Lib/test/test_pkg.py
==============================================================================
--- python/branches/py3k/Lib/test/test_pkg.py (original)
+++ python/branches/py3k/Lib/test/test_pkg.py Wed Jul 1 01:06:06 2009
@@ -130,7 +130,7 @@
self.assertEqual(subsub.__name__, "t2.sub.subsub")
self.assertEqual(sub.subsub.__name__, "t2.sub.subsub")
for name in ['spam', 'sub', 'subsub', 't2']:
- self.failUnless(locals()["name"], "Failed to import %s" % name)
+ self.assertTrue(locals()["name"], "Failed to import %s" % name)
import t2.sub
import t2.sub.subsub
@@ -140,7 +140,7 @@
s = """
from t2 import *
- self.failUnless(dir(), ['self', 'sub'])
+ self.assertTrue(dir(), ['self', 'sub'])
"""
self.run_code(s)
@@ -258,25 +258,25 @@
self.assertEqual(fixdir(dir(tas)),
['__doc__', '__file__', '__name__',
'__package__', '__path__'])
- self.failIf(t7)
+ self.assertFalse(t7)
from t7 import sub as subpar
self.assertEqual(fixdir(dir(subpar)),
['__doc__', '__file__', '__name__',
'__package__', '__path__'])
- self.failIf(t7)
- self.failIf(sub)
+ self.assertFalse(t7)
+ self.assertFalse(sub)
from t7.sub import subsub as subsubsub
self.assertEqual(fixdir(dir(subsubsub)),
['__doc__', '__file__', '__name__',
'__package__', '__path__', 'spam'])
- self.failIf(t7)
- self.failIf(sub)
- self.failIf(subsub)
+ self.assertFalse(t7)
+ self.assertFalse(sub)
+ self.assertFalse(subsub)
from t7.sub.subsub import spam as ham
self.assertEqual(ham, 1)
- self.failIf(t7)
- self.failIf(sub)
- self.failIf(subsub)
+ self.assertFalse(t7)
+ self.assertFalse(sub)
+ self.assertFalse(subsub)
def test_main():
Modified: python/branches/py3k/Lib/test/test_pkgimport.py
==============================================================================
--- python/branches/py3k/Lib/test/test_pkgimport.py (original)
+++ python/branches/py3k/Lib/test/test_pkgimport.py Wed Jul 1 01:06:06 2009
@@ -52,7 +52,7 @@
try: __import__(self.module_name)
except SyntaxError: pass
else: raise RuntimeError('Failed to induce SyntaxError')
- self.assert_(self.module_name not in sys.modules and
+ self.assertTrue(self.module_name not in sys.modules and
not hasattr(sys.modules[self.package_name], 'foo'))
# ...make up a variable name that isn't bound in __builtins__
Modified: python/branches/py3k/Lib/test/test_platform.py
==============================================================================
--- python/branches/py3k/Lib/test/test_platform.py (original)
+++ python/branches/py3k/Lib/test/test_platform.py Wed Jul 1 01:06:06 2009
@@ -125,12 +125,12 @@
def test_uname(self):
res = platform.uname()
- self.assert_(any(res))
+ self.assertTrue(any(res))
def test_java_ver(self):
res = platform.java_ver()
if sys.platform == 'java':
- self.assert_(all(res))
+ self.assertTrue(all(res))
def test_win32_ver(self):
res = platform.win32_ver()
@@ -148,7 +148,7 @@
real_ver = ln.strip().split()[-1]
break
fd.close()
- self.failIf(real_ver is None)
+ self.assertFalse(real_ver is None)
self.assertEquals(res[0], real_ver)
# res[1] claims to contain
Modified: python/branches/py3k/Lib/test/test_poplib.py
==============================================================================
--- python/branches/py3k/Lib/test/test_poplib.py (original)
+++ python/branches/py3k/Lib/test/test_poplib.py Wed Jul 1 01:06:06 2009
@@ -251,7 +251,7 @@
self.client = poplib.POP3_SSL(self.server.host, self.server.port)
def test__all__(self):
- self.assert_('POP3_SSL' in poplib.__all__)
+ self.assertTrue('POP3_SSL' in poplib.__all__)
class TestTimeouts(TestCase):
Modified: python/branches/py3k/Lib/test/test_posix.py
==============================================================================
--- python/branches/py3k/Lib/test/test_posix.py (original)
+++ python/branches/py3k/Lib/test/test_posix.py Wed Jul 1 01:06:06 2009
@@ -42,13 +42,13 @@
def test_statvfs(self):
if hasattr(posix, 'statvfs'):
- self.assert_(posix.statvfs(os.curdir))
+ self.assertTrue(posix.statvfs(os.curdir))
def test_fstatvfs(self):
if hasattr(posix, 'fstatvfs'):
fp = open(support.TESTFN)
try:
- self.assert_(posix.fstatvfs(fp.fileno()))
+ self.assertTrue(posix.fstatvfs(fp.fileno()))
finally:
fp.close()
@@ -68,7 +68,7 @@
fp = open(support.TESTFN)
try:
fd = posix.dup(fp.fileno())
- self.assert_(isinstance(fd, int))
+ self.assertTrue(isinstance(fd, int))
os.close(fd)
finally:
fp.close()
@@ -123,13 +123,13 @@
if hasattr(posix, 'fstat'):
fp = open(support.TESTFN)
try:
- self.assert_(posix.fstat(fp.fileno()))
+ self.assertTrue(posix.fstat(fp.fileno()))
finally:
fp.close()
def test_stat(self):
if hasattr(posix, 'stat'):
- self.assert_(posix.stat(support.TESTFN))
+ self.assertTrue(posix.stat(support.TESTFN))
if hasattr(posix, 'chown'):
def test_chown(self):
@@ -165,21 +165,21 @@
def test_lsdir(self):
if hasattr(posix, 'lsdir'):
- self.assert_(support.TESTFN in posix.lsdir(os.curdir))
+ self.assertTrue(support.TESTFN in posix.lsdir(os.curdir))
def test_access(self):
if hasattr(posix, 'access'):
- self.assert_(posix.access(support.TESTFN, os.R_OK))
+ self.assertTrue(posix.access(support.TESTFN, os.R_OK))
def test_umask(self):
if hasattr(posix, 'umask'):
old_mask = posix.umask(0)
- self.assert_(isinstance(old_mask, int))
+ self.assertTrue(isinstance(old_mask, int))
posix.umask(old_mask)
def test_strerror(self):
if hasattr(posix, 'strerror'):
- self.assert_(posix.strerror(0))
+ self.assertTrue(posix.strerror(0))
def test_pipe(self):
if hasattr(posix, 'pipe'):
Modified: python/branches/py3k/Lib/test/test_posixpath.py
==============================================================================
--- python/branches/py3k/Lib/test/test_posixpath.py (original)
+++ python/branches/py3k/Lib/test/test_posixpath.py Wed Jul 1 01:06:06 2009
@@ -26,7 +26,7 @@
safe_rmdir(support.TESTFN + suffix)
def assertIs(self, a, b):
- self.assert_(a is b)
+ self.assertTrue(a is b)
def test_normcase(self):
# Check that normcase() is idempotent
@@ -200,8 +200,8 @@
for s1 in testlist:
for s2 in testlist:
p = posixpath.commonprefix([s1, s2])
- self.assert_(s1.startswith(p))
- self.assert_(s2.startswith(p))
+ self.assertTrue(s1.startswith(p))
+ self.assertTrue(s2.startswith(p))
if s1 != s2:
n = len(p)
self.assertNotEqual(s1[n:n+1], s2[n:n+1])
@@ -229,7 +229,7 @@
f.close()
self.assertEqual(d, b"foobar")
- self.assert_(
+ self.assertTrue(
posixpath.getctime(support.TESTFN) <=
posixpath.getmtime(support.TESTFN)
)
@@ -402,8 +402,8 @@
except ImportError:
pass
else:
- self.assert_(isinstance(posixpath.expanduser("~/"), str))
- self.assert_(isinstance(posixpath.expanduser(b"~/"), bytes))
+ self.assertTrue(isinstance(posixpath.expanduser("~/"), str))
+ self.assertTrue(isinstance(posixpath.expanduser(b"~/"), bytes))
# if home directory == root directory, this test makes no sense
if posixpath.expanduser("~") != '/':
self.assertEqual(
@@ -414,10 +414,10 @@
posixpath.expanduser(b"~") + b"/",
posixpath.expanduser(b"~/")
)
- self.assert_(isinstance(posixpath.expanduser("~root/"), str))
- self.assert_(isinstance(posixpath.expanduser("~foo/"), str))
- self.assert_(isinstance(posixpath.expanduser(b"~root/"), bytes))
- self.assert_(isinstance(posixpath.expanduser(b"~foo/"), bytes))
+ self.assertTrue(isinstance(posixpath.expanduser("~root/"), str))
+ self.assertTrue(isinstance(posixpath.expanduser("~foo/"), str))
+ self.assertTrue(isinstance(posixpath.expanduser(b"~root/"), bytes))
+ self.assertTrue(isinstance(posixpath.expanduser(b"~foo/"), bytes))
with support.EnvironmentVarGuard() as env:
env['HOME'] = '/'
@@ -481,14 +481,14 @@
self.assertRaises(TypeError, posixpath.normpath)
def test_abspath(self):
- self.assert_("foo" in posixpath.abspath("foo"))
- self.assert_(b"foo" in posixpath.abspath(b"foo"))
+ self.assertTrue("foo" in posixpath.abspath("foo"))
+ self.assertTrue(b"foo" in posixpath.abspath(b"foo"))
self.assertRaises(TypeError, posixpath.abspath)
def test_realpath(self):
- self.assert_("foo" in realpath("foo"))
- self.assert_(b"foo" in realpath(b"foo"))
+ self.assertTrue("foo" in realpath("foo"))
+ self.assertTrue(b"foo" in realpath(b"foo"))
self.assertRaises(TypeError, posixpath.realpath)
if hasattr(os, "symlink"):
Modified: python/branches/py3k/Lib/test/test_pprint.py
==============================================================================
--- python/branches/py3k/Lib/test/test_pprint.py (original)
+++ python/branches/py3k/Lib/test/test_pprint.py Wed Jul 1 01:06:06 2009
@@ -34,7 +34,7 @@
def test_basic(self):
# Verify .isrecursive() and .isreadable() w/o recursion
- verify = self.assert_
+ verify = self.assertTrue
pp = pprint.PrettyPrinter()
for safe in (2, 2.0, 2j, "abc", [3], (2,2), {3: 3}, "yaddayadda",
self.a, self.b):
@@ -57,7 +57,7 @@
self.d = {}
self.d[0] = self.d[1] = self.d[2] = self.d
- verify = self.assert_
+ verify = self.assertTrue
pp = pprint.PrettyPrinter()
for icky in self.a, self.b, self.d, (self.d, self.d):
@@ -85,7 +85,7 @@
def test_unreadable(self):
# Not recursive but not readable anyway
- verify = self.assert_
+ verify = self.assertTrue
pp = pprint.PrettyPrinter()
for unreadable in type(3), pprint, pprint.isrecursive:
# module-level convenience functions
@@ -108,7 +108,7 @@
# it sorted a dict display if and only if the display required
# multiple lines. For that reason, dicts with more than one element
# aren't tested here.
- verify = self.assert_
+ verify = self.assertTrue
for simple in (0, 0, 0+0j, 0.0, "", b"",
(), tuple2(), tuple3(),
[], list2(), list3(),
Modified: python/branches/py3k/Lib/test/test_property.py
==============================================================================
--- python/branches/py3k/Lib/test/test_property.py (original)
+++ python/branches/py3k/Lib/test/test_property.py Wed Jul 1 01:06:06 2009
@@ -86,8 +86,8 @@
self.assertEqual(base.spam, 10)
self.assertEqual(base._spam, 10)
delattr(base, "spam")
- self.assert_(not hasattr(base, "spam"))
- self.assert_(not hasattr(base, "_spam"))
+ self.assertTrue(not hasattr(base, "spam"))
+ self.assertTrue(not hasattr(base, "_spam"))
base.spam = 20
self.assertEqual(base.spam, 20)
self.assertEqual(base._spam, 20)
Modified: python/branches/py3k/Lib/test/test_pwd.py
==============================================================================
--- python/branches/py3k/Lib/test/test_pwd.py (original)
+++ python/branches/py3k/Lib/test/test_pwd.py Wed Jul 1 01:06:06 2009
@@ -13,19 +13,19 @@
for e in entries:
self.assertEqual(len(e), 7)
self.assertEqual(e[0], e.pw_name)
- self.assert_(isinstance(e.pw_name, str))
+ self.assertTrue(isinstance(e.pw_name, str))
self.assertEqual(e[1], e.pw_passwd)
- self.assert_(isinstance(e.pw_passwd, str))
+ self.assertTrue(isinstance(e.pw_passwd, str))
self.assertEqual(e[2], e.pw_uid)
- self.assert_(isinstance(e.pw_uid, int))
+ self.assertTrue(isinstance(e.pw_uid, int))
self.assertEqual(e[3], e.pw_gid)
- self.assert_(isinstance(e.pw_gid, int))
+ self.assertTrue(isinstance(e.pw_gid, int))
self.assertEqual(e[4], e.pw_gecos)
- self.assert_(isinstance(e.pw_gecos, str))
+ self.assertTrue(isinstance(e.pw_gecos, str))
self.assertEqual(e[5], e.pw_dir)
- self.assert_(isinstance(e.pw_dir, str))
+ self.assertTrue(isinstance(e.pw_dir, str))
self.assertEqual(e[6], e.pw_shell)
- self.assert_(isinstance(e.pw_shell, str))
+ self.assertTrue(isinstance(e.pw_shell, str))
# The following won't work, because of duplicate entries
# for one uid
@@ -43,8 +43,8 @@
for e in entries:
if not e[0] or e[0] == '+':
continue # skip NIS entries etc.
- self.assert_(pwd.getpwnam(e.pw_name) in entriesbyname[e.pw_name])
- self.assert_(pwd.getpwuid(e.pw_uid) in entriesbyuid[e.pw_uid])
+ self.assertTrue(pwd.getpwnam(e.pw_name) in entriesbyname[e.pw_name])
+ self.assertTrue(pwd.getpwuid(e.pw_uid) in entriesbyuid[e.pw_uid])
def test_errors(self):
self.assertRaises(TypeError, pwd.getpwuid)
Modified: python/branches/py3k/Lib/test/test_pyclbr.py
==============================================================================
--- python/branches/py3k/Lib/test/test_pyclbr.py (original)
+++ python/branches/py3k/Lib/test/test_pyclbr.py Wed Jul 1 01:06:06 2009
@@ -31,7 +31,7 @@
''' succeed iff hasattr(obj,attr) or attr in ignore. '''
if attr in ignore: return
if not hasattr(obj, attr): print("???", attr)
- self.failUnless(hasattr(obj, attr),
+ self.assertTrue(hasattr(obj, attr),
'expected hasattr(%r, %r)' % (obj, attr))
@@ -40,7 +40,7 @@
if key in ignore: return
if key not in obj:
print("***",key, file=sys.stderr)
- self.failUnless(key in obj, "%r in %r" % (key, obj))
+ self.assertTrue(key in obj, "%r in %r" % (key, obj))
def assertEqualsOrIgnored(self, a, b, ignore):
''' succeed iff a == b or a in ignore or b in ignore '''
@@ -84,12 +84,12 @@
self.assertHasattr(module, name, ignore)
py_item = getattr(module, name)
if isinstance(value, pyclbr.Function):
- self.assert_(isinstance(py_item, (FunctionType, BuiltinFunctionType)))
+ self.assertTrue(isinstance(py_item, (FunctionType, BuiltinFunctionType)))
if py_item.__module__ != moduleName:
continue # skip functions that came from somewhere else
self.assertEquals(py_item.__module__, value.module)
else:
- self.failUnless(isinstance(py_item, type))
+ self.assertTrue(isinstance(py_item, type))
if py_item.__module__ != moduleName:
continue # skip classes that came from somewhere else
Modified: python/branches/py3k/Lib/test/test_pydoc.py
==============================================================================
--- python/branches/py3k/Lib/test/test_pydoc.py (original)
+++ python/branches/py3k/Lib/test/test_pydoc.py Wed Jul 1 01:06:06 2009
@@ -309,7 +309,7 @@
# Check that pydocfodder module can be described
from test import pydocfodder
doc = pydoc.render_doc(pydocfodder)
- self.assert_("pydocfodder" in doc)
+ self.assertTrue("pydocfodder" in doc)
def test_classic_class(self):
class C: "Classic class"
@@ -317,7 +317,7 @@
self.assertEqual(pydoc.describe(C), 'class C')
self.assertEqual(pydoc.describe(c), 'C')
expected = 'C in module %s' % __name__
- self.assert_(expected in pydoc.render_doc(c))
+ self.assertTrue(expected in pydoc.render_doc(c))
def test_class(self):
class C(object): "New-style class"
@@ -326,7 +326,7 @@
self.assertEqual(pydoc.describe(C), 'class C')
self.assertEqual(pydoc.describe(c), 'C')
expected = 'C in module %s object' % __name__
- self.assert_(expected in pydoc.render_doc(c))
+ self.assertTrue(expected in pydoc.render_doc(c))
def test_main():
Modified: python/branches/py3k/Lib/test/test_queue.py
==============================================================================
--- python/branches/py3k/Lib/test/test_queue.py (original)
+++ python/branches/py3k/Lib/test/test_queue.py Wed Jul 1 01:06:06 2009
@@ -103,12 +103,12 @@
"Didn't seem to queue the correct data!")
for i in range(QUEUE_SIZE-1):
q.put(i)
- self.assert_(q.qsize(), "Queue should not be empty")
- self.assert_(not qfull(q), "Queue should not be full")
+ self.assertTrue(q.qsize(), "Queue should not be empty")
+ self.assertTrue(not qfull(q), "Queue should not be full")
last = 2 * QUEUE_SIZE
full = 3 * 2 * QUEUE_SIZE
q.put(last)
- self.assert_(qfull(q), "Queue should be full")
+ self.assertTrue(qfull(q), "Queue should be full")
try:
q.put(full, block=0)
self.fail("Didn't appear to block with a full queue")
@@ -125,7 +125,7 @@
# Empty it
for i in range(QUEUE_SIZE):
q.get()
- self.assert_(not q.qsize(), "Queue should be empty")
+ self.assertTrue(not q.qsize(), "Queue should be empty")
try:
q.get(block=0)
self.fail("Didn't appear to block with an empty queue")
@@ -247,7 +247,7 @@
except FailingQueueException:
pass
q.put("last")
- self.assert_(qfull(q), "Queue should be full")
+ self.assertTrue(qfull(q), "Queue should be full")
# Test a failing blocking put
q.fail_next_put = True
try:
@@ -269,17 +269,17 @@
# Check the Queue isn't damaged.
# put failed, but get succeeded - re-add
q.put("last")
- self.assert_(qfull(q), "Queue should be full")
+ self.assertTrue(qfull(q), "Queue should be full")
q.get()
- self.assert_(not qfull(q), "Queue should not be full")
+ self.assertTrue(not qfull(q), "Queue should not be full")
q.put("last")
- self.assert_(qfull(q), "Queue should be full")
+ self.assertTrue(qfull(q), "Queue should be full")
# Test a blocking put
self.do_blocking_test(q.put, ("full",), q.get, ())
# Empty it
for i in range(QUEUE_SIZE):
q.get()
- self.assert_(not q.qsize(), "Queue should be empty")
+ self.assertTrue(not q.qsize(), "Queue should be empty")
q.put("first")
q.fail_next_get = True
try:
@@ -287,16 +287,16 @@
self.fail("The queue didn't fail when it should have")
except FailingQueueException:
pass
- self.assert_(q.qsize(), "Queue should not be empty")
+ self.assertTrue(q.qsize(), "Queue should not be empty")
q.fail_next_get = True
try:
q.get(timeout=0.1)
self.fail("The queue didn't fail when it should have")
except FailingQueueException:
pass
- self.assert_(q.qsize(), "Queue should not be empty")
+ self.assertTrue(q.qsize(), "Queue should not be empty")
q.get()
- self.assert_(not q.qsize(), "Queue should be empty")
+ self.assertTrue(not q.qsize(), "Queue should be empty")
q.fail_next_get = True
try:
self.do_exceptional_blocking_test(q.get, (), q.put, ('empty',),
@@ -305,9 +305,9 @@
except FailingQueueException:
pass
# put succeeded, but get failed.
- self.assert_(q.qsize(), "Queue should not be empty")
+ self.assertTrue(q.qsize(), "Queue should not be empty")
q.get()
- self.assert_(not q.qsize(), "Queue should be empty")
+ self.assertTrue(not q.qsize(), "Queue should be empty")
def test_failing_queue(self):
# Test to make sure a queue is functioning correctly.
Modified: python/branches/py3k/Lib/test/test_raise.py
==============================================================================
--- python/branches/py3k/Lib/test/test_raise.py (original)
+++ python/branches/py3k/Lib/test/test_raise.py Wed Jul 1 01:06:06 2009
@@ -28,7 +28,7 @@
try:
raise
except RuntimeError as e:
- self.failUnless("No active exception" in str(e))
+ self.assertTrue("No active exception" in str(e))
else:
self.fail("No exception raised")
@@ -40,7 +40,7 @@
exc1 = e
raise
except IndexError as exc2:
- self.failUnless(exc1 is exc2)
+ self.assertTrue(exc1 is exc2)
else:
self.fail("No exception raised")
@@ -127,7 +127,7 @@
try:
raise IndexError from 5
except TypeError as e:
- self.failUnless("exception cause" in str(e))
+ self.assertTrue("exception cause" in str(e))
else:
self.fail("No exception raised")
@@ -135,7 +135,7 @@
try:
raise IndexError from KeyError
except IndexError as e:
- self.failUnless(isinstance(e.__cause__, KeyError))
+ self.assertTrue(isinstance(e.__cause__, KeyError))
else:
self.fail("No exception raised")
@@ -144,7 +144,7 @@
try:
raise IndexError from cause
except IndexError as e:
- self.failUnless(e.__cause__ is cause)
+ self.assertTrue(e.__cause__ is cause)
else:
self.fail("No exception raised")
@@ -166,7 +166,7 @@
try:
raise IndexError()
except IndexError as e:
- self.failUnless(isinstance(e.__traceback__, types.TracebackType))
+ self.assertTrue(isinstance(e.__traceback__, types.TracebackType))
else:
self.fail("No exception raised")
@@ -203,7 +203,7 @@
raise OSError()
except OSError as e:
self.assertNotEqual(e.__context__, context)
- self.failUnless(isinstance(e.__context__, context))
+ self.assertTrue(isinstance(e.__context__, context))
else:
self.fail("No exception raised")
@@ -216,7 +216,7 @@
raise OSError
except OSError as e:
self.assertNotEqual(e.__context__, context)
- self.failUnless(isinstance(e.__context__, context))
+ self.assertTrue(isinstance(e.__context__, context))
else:
self.fail("No exception raised")
@@ -227,7 +227,7 @@
except:
raise OSError
except OSError as e:
- self.failUnless(isinstance(e.__context__, ZeroDivisionError))
+ self.assertTrue(isinstance(e.__context__, ZeroDivisionError))
else:
self.fail("No exception raised")
@@ -238,7 +238,7 @@
except:
xyzzy
except NameError as e:
- self.failUnless(isinstance(e.__context__, ZeroDivisionError))
+ self.assertTrue(isinstance(e.__context__, ZeroDivisionError))
else:
self.fail("No exception raised")
@@ -249,7 +249,7 @@
finally:
raise OSError
except OSError as e:
- self.failUnless(e.__context__ is None)
+ self.assertTrue(e.__context__ is None)
else:
self.fail("No exception raised")
@@ -260,7 +260,7 @@
finally:
raise OSError
except OSError as e:
- self.failUnless(isinstance(e.__context__, ZeroDivisionError))
+ self.assertTrue(isinstance(e.__context__, ZeroDivisionError))
else:
self.fail("No exception raised")
@@ -274,7 +274,7 @@
with ContextManager():
1/0
except NameError as e:
- self.failUnless(isinstance(e.__context__, ZeroDivisionError))
+ self.assertTrue(isinstance(e.__context__, ZeroDivisionError))
else:
self.fail("No exception raised")
@@ -286,7 +286,7 @@
except ZeroDivisionError as e:
raise e
except ZeroDivisionError as e:
- self.failUnless(e.__context__ is None, e.__context__)
+ self.assertTrue(e.__context__ is None, e.__context__)
def test_reraise_cycle_broken(self):
# Non-trivial context cycles (through re-raising a previous exception)
@@ -300,7 +300,7 @@
except ZeroDivisionError:
raise a
except NameError as e:
- self.failUnless(e.__context__.__context__ is None)
+ self.assertTrue(e.__context__.__context__ is None)
def test_3118(self):
# deleting the generator caused the __context__ to be cleared
@@ -320,7 +320,7 @@
del g
raise KeyError
except Exception as e:
- self.assert_(isinstance(e.__context__, ValueError))
+ self.assertTrue(isinstance(e.__context__, ValueError))
f()
@@ -344,7 +344,7 @@
raise TypeError
except Exception as e:
self.assertNotEqual(e.__context__, None)
- self.assert_(isinstance(e.__context__, AttributeError))
+ self.assertTrue(isinstance(e.__context__, AttributeError))
with support.captured_output("stderr"):
f()
Modified: python/branches/py3k/Lib/test/test_random.py
==============================================================================
--- python/branches/py3k/Lib/test/test_random.py (original)
+++ python/branches/py3k/Lib/test/test_random.py Wed Jul 1 01:06:06 2009
@@ -52,7 +52,7 @@
self.assertEqual(len(s), k)
uniq = set(s)
self.assertEqual(len(uniq), k)
- self.failUnless(uniq <= set(population))
+ self.assertTrue(uniq <= set(population))
self.assertEqual(self.gen.sample([], 0), []) # test edge case N==k==0
def test_sample_distribution(self):
@@ -161,7 +161,7 @@
cum = 0
for i in range(100):
r = self.gen.randrange(span)
- self.assert_(0 <= r < span)
+ self.assertTrue(0 <= r < span)
cum |= r
self.assertEqual(cum, span-1)
@@ -171,7 +171,7 @@
stop = self.gen.randrange(2 ** (i-2))
if stop <= start:
return
- self.assert_(start <= self.gen.randrange(start, stop) < stop)
+ self.assertTrue(start <= self.gen.randrange(start, stop) < stop)
def test_rangelimits(self):
for start, stop in [(-2,0), (-(2**60)-2,-(2**60)), (2**60,2**60+2)]:
@@ -181,7 +181,7 @@
def test_genrandbits(self):
# Verify ranges
for k in range(1, 1000):
- self.assert_(0 <= self.gen.getrandbits(k) < 2**k)
+ self.assertTrue(0 <= self.gen.getrandbits(k) < 2**k)
# Verify all bits active
getbits = self.gen.getrandbits
@@ -211,13 +211,13 @@
n += n - 1 # check 1 below the next power of two
k = int(1.00001 + _log(n, 2))
- self.assert_(k in [numbits, numbits+1])
- self.assert_(2**k > n > 2**(k-2))
+ self.assertTrue(k in [numbits, numbits+1])
+ self.assertTrue(2**k > n > 2**(k-2))
n -= n >> 15 # check a little farther below the next power of two
k = int(1.00001 + _log(n, 2))
self.assertEqual(k, numbits) # note the stronger assertion
- self.assert_(2**k > n > 2**(k-1)) # note the stronger assertion
+ self.assertTrue(2**k > n > 2**(k-1)) # note the stronger assertion
class MersenneTwister_TestBasicOps(TestBasicOps):
@@ -313,7 +313,7 @@
cum = 0
for i in range(100):
r = self.gen.randrange(span)
- self.assert_(0 <= r < span)
+ self.assertTrue(0 <= r < span)
cum |= r
self.assertEqual(cum, span-1)
@@ -323,7 +323,7 @@
stop = self.gen.randrange(2 ** (i-2))
if stop <= start:
return
- self.assert_(start <= self.gen.randrange(start, stop) < stop)
+ self.assertTrue(start <= self.gen.randrange(start, stop) < stop)
def test_rangelimits(self):
for start, stop in [(-2,0), (-(2**60)-2,-(2**60)), (2**60,2**60+2)]:
@@ -337,7 +337,7 @@
97904845777343510404718956115)
# Verify ranges
for k in range(1, 1000):
- self.assert_(0 <= self.gen.getrandbits(k) < 2**k)
+ self.assertTrue(0 <= self.gen.getrandbits(k) < 2**k)
# Verify all bits active
getbits = self.gen.getrandbits
@@ -367,20 +367,20 @@
n += n - 1 # check 1 below the next power of two
k = int(1.00001 + _log(n, 2))
- self.assert_(k in [numbits, numbits+1])
- self.assert_(2**k > n > 2**(k-2))
+ self.assertTrue(k in [numbits, numbits+1])
+ self.assertTrue(2**k > n > 2**(k-2))
n -= n >> 15 # check a little farther below the next power of two
k = int(1.00001 + _log(n, 2))
self.assertEqual(k, numbits) # note the stronger assertion
- self.assert_(2**k > n > 2**(k-1)) # note the stronger assertion
+ self.assertTrue(2**k > n > 2**(k-1)) # note the stronger assertion
def test_randrange_bug_1590891(self):
start = 1000000000000
stop = -100000000000000000000
step = -200
x = self.gen.randrange(start, stop, step)
- self.assert_(stop < x <= start)
+ self.assertTrue(stop < x <= start)
self.assertEqual((x+stop)%step, 0)
def gamma(z, sqrt2pi=(2.0*pi)**0.5):
@@ -458,7 +458,7 @@
def test__all__(self):
# tests validity but not completeness of the __all__ list
- self.failUnless(set(random.__all__) <= set(dir(random)))
+ self.assertTrue(set(random.__all__) <= set(dir(random)))
def test_random_subclass_with_kwargs(self):
# SF bug #1486663 -- this used to erroneously raise a TypeError
Modified: python/branches/py3k/Lib/test/test_range.py
==============================================================================
--- python/branches/py3k/Lib/test/test_range.py (original)
+++ python/branches/py3k/Lib/test/test_range.py Wed Jul 1 01:06:06 2009
@@ -26,18 +26,18 @@
self.assertEqual(list(range(a+4, a, -2)), [a+4, a+2])
seq = list(range(a, b, c))
- self.assert_(a in seq)
- self.assert_(b not in seq)
+ self.assertTrue(a in seq)
+ self.assertTrue(b not in seq)
self.assertEqual(len(seq), 2)
seq = list(range(b, a, -c))
- self.assert_(b in seq)
- self.assert_(a not in seq)
+ self.assertTrue(b in seq)
+ self.assertTrue(a not in seq)
self.assertEqual(len(seq), 2)
seq = list(range(-a, -b, -c))
- self.assert_(-a in seq)
- self.assert_(-b not in seq)
+ self.assertTrue(-a in seq)
+ self.assertTrue(-b not in seq)
self.assertEqual(len(seq), 2)
self.assertRaises(TypeError, range)
Modified: python/branches/py3k/Lib/test/test_re.py
==============================================================================
--- python/branches/py3k/Lib/test/test_re.py (original)
+++ python/branches/py3k/Lib/test/test_re.py Wed Jul 1 01:06:06 2009
@@ -585,7 +585,7 @@
[":", "::", ":::"])
def test_bug_926075(self):
- self.assert_(re.compile('bug_926075') is not
+ self.assertTrue(re.compile('bug_926075') is not
re.compile(b'bug_926075'))
def test_bug_931848(self):
Modified: python/branches/py3k/Lib/test/test_reprlib.py
==============================================================================
--- python/branches/py3k/Lib/test/test_reprlib.py (original)
+++ python/branches/py3k/Lib/test/test_reprlib.py Wed Jul 1 01:06:06 2009
@@ -123,12 +123,12 @@
eq(r(i3), ("<ClassWithFailingRepr instance at %x>"%id(i3)))
s = r(ClassWithFailingRepr)
- self.failUnless(s.startswith("<class "))
- self.failUnless(s.endswith(">"))
- self.failUnless(s.find("...") in [12, 13])
+ self.assertTrue(s.startswith("<class "))
+ self.assertTrue(s.endswith(">"))
+ self.assertTrue(s.find("...") in [12, 13])
def test_lambda(self):
- self.failUnless(repr(lambda x: x).startswith(
+ self.assertTrue(repr(lambda x: x).startswith(
"<function <lambda"))
# XXX anonymous functions? see func_repr
@@ -137,7 +137,7 @@
# Functions
eq(repr(hash), '<built-in function hash>')
# Methods
- self.failUnless(repr(''.split).startswith(
+ self.assertTrue(repr(''.split).startswith(
'<built-in method split of str object at 0x'))
def test_range(self):
@@ -178,9 +178,9 @@
class C:
def foo(cls): pass
x = staticmethod(C.foo)
- self.failUnless(repr(x).startswith('<staticmethod object at 0x'))
+ self.assertTrue(repr(x).startswith('<staticmethod object at 0x'))
x = classmethod(C.foo)
- self.failUnless(repr(x).startswith('<classmethod object at 0x'))
+ self.assertTrue(repr(x).startswith('<classmethod object at 0x'))
def test_unsortable(self):
# Repr.repr() used to call sorted() on sets, frozensets and dicts
@@ -267,7 +267,7 @@
''')
from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import baz
ibaz = baz.baz()
- self.failUnless(repr(ibaz).startswith(
+ self.assertTrue(repr(ibaz).startswith(
"<%s.baz object at 0x" % baz.__name__))
def test_method(self):
@@ -278,11 +278,11 @@
''')
from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import qux
# Unbound methods first
- self.failUnless(repr(qux.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.amethod).startswith(
+ self.assertTrue(repr(qux.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.amethod).startswith(
'<function amethod'))
# Bound method next
iqux = qux.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
- self.failUnless(repr(iqux.amethod).startswith(
+ self.assertTrue(repr(iqux.amethod).startswith(
'<bound method aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.amethod of <%s.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa object at 0x' \
% (qux.__name__,) ))
Modified: python/branches/py3k/Lib/test/test_richcmp.py
==============================================================================
--- python/branches/py3k/Lib/test/test_richcmp.py (original)
+++ python/branches/py3k/Lib/test/test_richcmp.py Wed Jul 1 01:06:06 2009
@@ -106,7 +106,7 @@
self.assertEqual(len(realres), len(expres))
for i in range(len(realres)):
# results are bool, so we can use "is" here
- self.assert_(realres[i] is expres[i])
+ self.assertTrue(realres[i] is expres[i])
def test_mixed(self):
# check that comparisons involving Vector objects
@@ -163,7 +163,7 @@
for op in opmap[opname]:
realres = op(ta, tb)
realres = getattr(realres, "x", realres)
- self.assert_(realres is expres)
+ self.assertTrue(realres is expres)
def test_values(self):
# check all operators and all comparison results
@@ -237,8 +237,8 @@
b.append(17)
# Even recursive lists of different lengths are different,
# but they cannot be ordered
- self.assert_(not (a == b))
- self.assert_(a != b)
+ self.assertTrue(not (a == b))
+ self.assertTrue(a != b)
self.assertRaises(RuntimeError, operator.lt, a, b)
self.assertRaises(RuntimeError, operator.le, a, b)
self.assertRaises(RuntimeError, operator.gt, a, b)
@@ -248,9 +248,9 @@
self.assertRaises(RuntimeError, operator.ne, a, b)
a.insert(0, 11)
b.insert(0, 12)
- self.assert_(not (a == b))
- self.assert_(a != b)
- self.assert_(a < b)
+ self.assertTrue(not (a == b))
+ self.assertTrue(a != b)
+ self.assertTrue(a < b)
class DictTest(unittest.TestCase):
@@ -272,7 +272,7 @@
self.assertEqual(imag1a, imag1a)
self.assertEqual(imag1a, imag1b)
self.assertEqual(imag2, imag2)
- self.assert_(imag1a != imag2)
+ self.assertTrue(imag1a != imag2)
for opname in ("lt", "le", "gt", "ge"):
for op in opmap[opname]:
self.assertRaises(TypeError, op, imag1a, imag2)
@@ -280,7 +280,7 @@
class ListTest(unittest.TestCase):
def assertIs(self, a, b):
- self.assert_(a is b)
+ self.assertTrue(a is b)
def test_coverage(self):
# exercise all comparisons for lists
Modified: python/branches/py3k/Lib/test/test_robotparser.py
==============================================================================
--- python/branches/py3k/Lib/test/test_robotparser.py (original)
+++ python/branches/py3k/Lib/test/test_robotparser.py Wed Jul 1 01:06:06 2009
@@ -22,9 +22,9 @@
url = self.url
agent = self.agent
if self.good:
- self.failUnless(self.parser.can_fetch(agent, url))
+ self.assertTrue(self.parser.can_fetch(agent, url))
else:
- self.failIf(self.parser.can_fetch(agent, url))
+ self.assertFalse(self.parser.can_fetch(agent, url))
def __str__(self):
return self.str
Modified: python/branches/py3k/Lib/test/test_runpy.py
==============================================================================
--- python/branches/py3k/Lib/test/test_runpy.py (original)
+++ python/branches/py3k/Lib/test/test_runpy.py Wed Jul 1 01:06:06 2009
@@ -37,14 +37,14 @@
def test_run_code(self):
saved_argv0 = sys.argv[0]
d = _run_code(self.test_source, {})
- self.failUnless(d["result"] == self.expected_result)
- self.failUnless(d["__name__"] is None)
- self.failUnless(d["__file__"] is None)
- self.failUnless(d["__loader__"] is None)
- self.failUnless(d["__package__"] is None)
- self.failUnless(d["run_argv0"] is saved_argv0)
- self.failUnless("run_name" not in d)
- self.failUnless(sys.argv[0] is saved_argv0)
+ self.assertTrue(d["result"] == self.expected_result)
+ self.assertTrue(d["__name__"] is None)
+ self.assertTrue(d["__file__"] is None)
+ self.assertTrue(d["__loader__"] is None)
+ self.assertTrue(d["__package__"] is None)
+ self.assertTrue(d["run_argv0"] is saved_argv0)
+ self.assertTrue("run_name" not in d)
+ self.assertTrue(sys.argv[0] is saved_argv0)
def test_run_module_code(self):
initial = object()
@@ -60,19 +60,19 @@
file,
loader,
package)
- self.failUnless("result" not in d1)
- self.failUnless(d2["initial"] is initial)
+ self.assertTrue("result" not in d1)
+ self.assertTrue(d2["initial"] is initial)
self.assertEqual(d2["result"], self.expected_result)
self.assertEqual(d2["nested"]["x"], 1)
- self.failUnless(d2["__name__"] is name)
- self.failUnless(d2["run_name_in_sys_modules"])
- self.failUnless(d2["module_in_sys_modules"])
- self.failUnless(d2["__file__"] is file)
- self.failUnless(d2["run_argv0"] is file)
- self.failUnless(d2["__loader__"] is loader)
- self.failUnless(d2["__package__"] is package)
- self.failUnless(sys.argv[0] is saved_argv0)
- self.failUnless(name not in sys.modules)
+ self.assertTrue(d2["__name__"] is name)
+ self.assertTrue(d2["run_name_in_sys_modules"])
+ self.assertTrue(d2["module_in_sys_modules"])
+ self.assertTrue(d2["__file__"] is file)
+ self.assertTrue(d2["run_argv0"] is file)
+ self.assertTrue(d2["__loader__"] is loader)
+ self.assertTrue(d2["__package__"] is package)
+ self.assertTrue(sys.argv[0] is saved_argv0)
+ self.assertTrue(name not in sys.modules)
class RunModuleTest(unittest.TestCase):
@@ -159,14 +159,14 @@
try:
if verbose: print("Running from source:", mod_name)
d1 = run_module(mod_name) # Read from source
- self.failUnless("x" in d1)
+ self.assertTrue("x" in d1)
self.assertEqual(d1["x"], 1)
del d1 # Ensure __loader__ entry doesn't keep file open
__import__(mod_name)
os.remove(mod_fname)
if verbose: print("Running from compiled:", mod_name)
d2 = run_module(mod_name) # Read from bytecode
- self.failUnless("x" in d2)
+ self.assertTrue("x" in d2)
self.assertEqual(d2["x"], 1)
del d2 # Ensure __loader__ entry doesn't keep file open
finally:
@@ -211,19 +211,19 @@
pkg_name = mod_name.rpartition('.')[0]
if verbose: print("Running from source:", mod_name)
d1 = run_module(mod_name, run_name=run_name) # Read from source
- self.failUnless("__package__" in d1)
- self.failUnless(d1["__package__"] == pkg_name)
- self.failUnless("sibling" in d1)
- self.failUnless("nephew" in d1)
+ self.assertTrue("__package__" in d1)
+ self.assertTrue(d1["__package__"] == pkg_name)
+ self.assertTrue("sibling" in d1)
+ self.assertTrue("nephew" in d1)
del d1 # Ensure __loader__ entry doesn't keep file open
__import__(mod_name)
os.remove(mod_fname)
if verbose: print("Running from compiled:", mod_name)
d2 = run_module(mod_name, run_name=run_name) # Read from bytecode
- self.failUnless("__package__" in d2)
- self.failUnless(d2["__package__"] == pkg_name)
- self.failUnless("sibling" in d2)
- self.failUnless("nephew" in d2)
+ self.assertTrue("__package__" in d2)
+ self.assertTrue(d2["__package__"] == pkg_name)
+ self.assertTrue("sibling" in d2)
+ self.assertTrue("nephew" in d2)
del d2 # Ensure __loader__ entry doesn't keep file open
finally:
self._del_pkg(pkg_dir, depth, mod_name)
Modified: python/branches/py3k/Lib/test/test_scope.py
==============================================================================
--- python/branches/py3k/Lib/test/test_scope.py (original)
+++ python/branches/py3k/Lib/test/test_scope.py Wed Jul 1 01:06:06 2009
@@ -443,7 +443,7 @@
locals()['looked_up_by_load_name'] = True
passed = looked_up_by_load_name
-self.assert_(X.passed)
+self.assertTrue(X.passed)
""")
def testLocalsFunction(self):
@@ -458,7 +458,7 @@
return g
d = f(2)(4)
- self.assert_('h' in d)
+ self.assertTrue('h' in d)
del d['h']
self.assertEqual(d, {'x': 2, 'y': 7, 'w': 6})
@@ -492,8 +492,8 @@
return C
varnames = f(1).z
- self.assert_("x" not in varnames)
- self.assert_("y" in varnames)
+ self.assertTrue("x" not in varnames)
+ self.assertTrue("y" in varnames)
def testLocalsClass_WithTrace(self):
# Issue23728: after the trace function returns, the locals()
@@ -671,7 +671,7 @@
c = f(0)
self.assertEqual(c.get(), 1)
- self.assert_("x" not in c.__class__.__dict__)
+ self.assertTrue("x" not in c.__class__.__dict__)
def testNonLocalGenerator(self):
Modified: python/branches/py3k/Lib/test/test_set.py
==============================================================================
--- python/branches/py3k/Lib/test/test_set.py (original)
+++ python/branches/py3k/Lib/test/test_set.py Wed Jul 1 01:06:06 2009
@@ -65,7 +65,7 @@
self.assertEqual(c in self.s, c in self.d)
self.assertRaises(TypeError, self.s.__contains__, [[]])
s = self.thetype([frozenset(self.letters)])
- self.assert_(self.thetype(self.letters) in s)
+ self.assertTrue(self.thetype(self.letters) in s)
def test_union(self):
u = self.s.union(self.otherword)
@@ -125,7 +125,7 @@
actual = s1.isdisjoint(s2)
expected = f(s1, s2)
self.assertEqual(actual, expected)
- self.assert_(actual is True or actual is False)
+ self.assertTrue(actual is True or actual is False)
def test_and(self):
i = self.s.intersection(self.otherword)
@@ -205,19 +205,19 @@
def test_sub_and_super(self):
p, q, r = map(self.thetype, ['ab', 'abcde', 'def'])
- self.assert_(p < q)
- self.assert_(p <= q)
- self.assert_(q <= q)
- self.assert_(q > p)
- self.assert_(q >= p)
- self.failIf(q < r)
- self.failIf(q <= r)
- self.failIf(q > r)
- self.failIf(q >= r)
- self.assert_(set('a').issubset('abc'))
- self.assert_(set('abc').issuperset('a'))
- self.failIf(set('a').issubset('cbs'))
- self.failIf(set('cbs').issuperset('a'))
+ self.assertTrue(p < q)
+ self.assertTrue(p <= q)
+ self.assertTrue(q <= q)
+ self.assertTrue(q > p)
+ self.assertTrue(q >= p)
+ self.assertFalse(q < r)
+ self.assertFalse(q <= r)
+ self.assertFalse(q > r)
+ self.assertFalse(q >= r)
+ self.assertTrue(set('a').issubset('abc'))
+ self.assertTrue(set('abc').issuperset('a'))
+ self.assertFalse(set('a').issubset('cbs'))
+ self.assertFalse(set('cbs').issuperset('a'))
def test_pickling(self):
for i in range(pickle.HIGHEST_PROTOCOL + 1):
@@ -265,7 +265,7 @@
s=H()
f=set()
f.add(s)
- self.assert_(s in f)
+ self.assertTrue(s in f)
f.remove(s)
f.add(s)
f.discard(s)
@@ -334,7 +334,7 @@
obj.x = iter(container)
del obj, container
gc.collect()
- self.assert_(ref() is None, "Cycle was not collected")
+ self.assertTrue(ref() is None, "Cycle was not collected")
class TestSet(TestJointOps):
thetype = set
@@ -375,7 +375,7 @@
def test_add(self):
self.s.add('Q')
- self.assert_('Q' in self.s)
+ self.assertTrue('Q' in self.s)
dup = self.s.copy()
self.s.add('Q')
self.assertEqual(self.s, dup)
@@ -383,13 +383,13 @@
def test_remove(self):
self.s.remove('a')
- self.assert_('a' not in self.s)
+ self.assertTrue('a' not in self.s)
self.assertRaises(KeyError, self.s.remove, 'Q')
self.assertRaises(TypeError, self.s.remove, [])
s = self.thetype([frozenset(self.word)])
- self.assert_(self.thetype(self.word) in s)
+ self.assertTrue(self.thetype(self.word) in s)
s.remove(self.thetype(self.word))
- self.assert_(self.thetype(self.word) not in s)
+ self.assertTrue(self.thetype(self.word) not in s)
self.assertRaises(KeyError, self.s.remove, self.thetype(self.word))
def test_remove_keyerror_unpacking(self):
@@ -408,7 +408,7 @@
try:
self.s.remove(key)
except KeyError as e:
- self.assert_(e.args[0] is key,
+ self.assertTrue(e.args[0] is key,
"KeyError should be {0}, not {1}".format(key,
e.args[0]))
else:
@@ -416,26 +416,26 @@
def test_discard(self):
self.s.discard('a')
- self.assert_('a' not in self.s)
+ self.assertTrue('a' not in self.s)
self.s.discard('Q')
self.assertRaises(TypeError, self.s.discard, [])
s = self.thetype([frozenset(self.word)])
- self.assert_(self.thetype(self.word) in s)
+ self.assertTrue(self.thetype(self.word) in s)
s.discard(self.thetype(self.word))
- self.assert_(self.thetype(self.word) not in s)
+ self.assertTrue(self.thetype(self.word) not in s)
s.discard(self.thetype(self.word))
def test_pop(self):
for i in range(len(self.s)):
elem = self.s.pop()
- self.assert_(elem not in self.s)
+ self.assertTrue(elem not in self.s)
self.assertRaises(KeyError, self.s.pop)
def test_update(self):
retval = self.s.update(self.otherword)
self.assertEqual(retval, None)
for c in (self.word + self.otherword):
- self.assert_(c in self.s)
+ self.assertTrue(c in self.s)
self.assertRaises(PassThru, self.s.update, check_pass_thru())
self.assertRaises(TypeError, self.s.update, [[]])
for p, q in (('cdc', 'abcd'), ('efgfe', 'abcefg'), ('ccb', 'abc'), ('ef', 'abcef')):
@@ -453,16 +453,16 @@
def test_ior(self):
self.s |= set(self.otherword)
for c in (self.word + self.otherword):
- self.assert_(c in self.s)
+ self.assertTrue(c in self.s)
def test_intersection_update(self):
retval = self.s.intersection_update(self.otherword)
self.assertEqual(retval, None)
for c in (self.word + self.otherword):
if c in self.otherword and c in self.word:
- self.assert_(c in self.s)
+ self.assertTrue(c in self.s)
else:
- self.assert_(c not in self.s)
+ self.assertTrue(c not in self.s)
self.assertRaises(PassThru, self.s.intersection_update, check_pass_thru())
self.assertRaises(TypeError, self.s.intersection_update, [[]])
for p, q in (('cdc', 'c'), ('efgfe', ''), ('ccb', 'bc'), ('ef', '')):
@@ -480,18 +480,18 @@
self.s &= set(self.otherword)
for c in (self.word + self.otherword):
if c in self.otherword and c in self.word:
- self.assert_(c in self.s)
+ self.assertTrue(c in self.s)
else:
- self.assert_(c not in self.s)
+ self.assertTrue(c not in self.s)
def test_difference_update(self):
retval = self.s.difference_update(self.otherword)
self.assertEqual(retval, None)
for c in (self.word + self.otherword):
if c in self.word and c not in self.otherword:
- self.assert_(c in self.s)
+ self.assertTrue(c in self.s)
else:
- self.assert_(c not in self.s)
+ self.assertTrue(c not in self.s)
self.assertRaises(PassThru, self.s.difference_update, check_pass_thru())
self.assertRaises(TypeError, self.s.difference_update, [[]])
self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]])
@@ -517,18 +517,18 @@
self.s -= set(self.otherword)
for c in (self.word + self.otherword):
if c in self.word and c not in self.otherword:
- self.assert_(c in self.s)
+ self.assertTrue(c in self.s)
else:
- self.assert_(c not in self.s)
+ self.assertTrue(c not in self.s)
def test_symmetric_difference_update(self):
retval = self.s.symmetric_difference_update(self.otherword)
self.assertEqual(retval, None)
for c in (self.word + self.otherword):
if (c in self.word) ^ (c in self.otherword):
- self.assert_(c in self.s)
+ self.assertTrue(c in self.s)
else:
- self.assert_(c not in self.s)
+ self.assertTrue(c not in self.s)
self.assertRaises(PassThru, self.s.symmetric_difference_update, check_pass_thru())
self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]])
for p, q in (('cdc', 'abd'), ('efgfe', 'abcefg'), ('ccb', 'a'), ('ef', 'abcef')):
@@ -541,9 +541,9 @@
self.s ^= set(self.otherword)
for c in (self.word + self.otherword):
if (c in self.word) ^ (c in self.otherword):
- self.assert_(c in self.s)
+ self.assertTrue(c in self.s)
else:
- self.assert_(c not in self.s)
+ self.assertTrue(c not in self.s)
def test_inplace_on_self(self):
t = self.s.copy()
@@ -586,19 +586,19 @@
myobj = TestRichSetCompare()
myset < myobj
- self.assert_(myobj.gt_called)
+ self.assertTrue(myobj.gt_called)
myobj = TestRichSetCompare()
myset > myobj
- self.assert_(myobj.lt_called)
+ self.assertTrue(myobj.lt_called)
myobj = TestRichSetCompare()
myset <= myobj
- self.assert_(myobj.ge_called)
+ self.assertTrue(myobj.ge_called)
myobj = TestRichSetCompare()
myset >= myobj
- self.assert_(myobj.le_called)
+ self.assertTrue(myobj.le_called)
# C API test only available in a debug build
if hasattr(set, "test_c_api"):
@@ -810,7 +810,7 @@
def test_iteration(self):
for v in self.set:
- self.assert_(v in self.values)
+ self.assertTrue(v in self.values)
setiter = iter(self.set)
# note: __length_hint__ is an internal undocumented API,
# don't rely on it in your own programs
@@ -845,10 +845,10 @@
self.repr = "{3}"
def test_in(self):
- self.failUnless(3 in self.set)
+ self.assertTrue(3 in self.set)
def test_not_in(self):
- self.failUnless(2 not in self.set)
+ self.assertTrue(2 not in self.set)
#------------------------------------------------------------------------------
@@ -862,10 +862,10 @@
self.repr = "{(0, 'zero')}"
def test_in(self):
- self.failUnless((0, "zero") in self.set)
+ self.assertTrue((0, "zero") in self.set)
def test_not_in(self):
- self.failUnless(9 not in self.set)
+ self.assertTrue(9 not in self.set)
#------------------------------------------------------------------------------
@@ -1182,7 +1182,7 @@
popped[self.set.pop()] = None
self.assertEqual(len(popped), len(self.values))
for v in self.values:
- self.failUnless(v in popped)
+ self.assertTrue(v in popped)
def test_update_empty_tuple(self):
self.set.update(())
@@ -1451,7 +1451,7 @@
set_list = sorted(self.set, key=repr)
self.assertEqual(len(dup_list), len(set_list))
for i in range(len(dup_list)):
- self.failUnless(dup_list[i] is set_list[i])
+ self.assertTrue(dup_list[i] is set_list[i])
def test_deep_copy(self):
dup = copy.deepcopy(self.set)
@@ -1501,13 +1501,13 @@
def test_binopsVsSubsets(self):
a, b = self.a, self.b
- self.assert_(a - b < a)
- self.assert_(b - a < b)
- self.assert_(a & b < a)
- self.assert_(a & b < b)
- self.assert_(a | b > a)
- self.assert_(a | b > b)
- self.assert_(a ^ b < a | b)
+ self.assertTrue(a - b < a)
+ self.assertTrue(b - a < b)
+ self.assertTrue(a & b < a)
+ self.assertTrue(a & b < b)
+ self.assertTrue(a | b > a)
+ self.assertTrue(a | b > b)
+ self.assertTrue(a ^ b < a | b)
def test_commutativity(self):
a, b = self.a, self.b
@@ -1756,7 +1756,7 @@
edge = vertex # Cuboctahedron vertices are edges in Cube
self.assertEqual(len(edge), 2) # Two cube vertices define an edge
for cubevert in edge:
- self.assert_(cubevert in g)
+ self.assertTrue(cubevert in g)
#==============================================================================
Modified: python/branches/py3k/Lib/test/test_shutil.py
==============================================================================
--- python/branches/py3k/Lib/test/test_shutil.py (original)
+++ python/branches/py3k/Lib/test/test_shutil.py Wed Jul 1 01:06:06 2009
@@ -63,12 +63,12 @@
self.assertIs(func, os.listdir,
"func must be either os.remove or os.listdir")
self.assertEqual(arg, TESTFN)
- self.failUnless(issubclass(exc[0], OSError))
+ self.assertTrue(issubclass(exc[0], OSError))
self.errorState = 1
else:
self.assertEqual(func, os.rmdir)
self.assertEqual(arg, TESTFN)
- self.failUnless(issubclass(exc[0], OSError))
+ self.assertTrue(issubclass(exc[0], OSError))
self.errorState = 2
def test_rmtree_dont_delete_file(self):
@@ -158,9 +158,9 @@
patterns = shutil.ignore_patterns('*.tmp', 'test_dir2')
shutil.copytree(src_dir, dst_dir, ignore=patterns)
# checking the result: some elements should not be copied
- self.assert_(exists(join(dst_dir, 'test.txt')))
- self.assert_(not exists(join(dst_dir, 'test.tmp')))
- self.assert_(not exists(join(dst_dir, 'test_dir2')))
+ self.assertTrue(exists(join(dst_dir, 'test.txt')))
+ self.assertTrue(not exists(join(dst_dir, 'test.tmp')))
+ self.assertTrue(not exists(join(dst_dir, 'test_dir2')))
finally:
if os.path.exists(dst_dir):
shutil.rmtree(dst_dir)
@@ -168,9 +168,9 @@
patterns = shutil.ignore_patterns('*.tmp', 'subdir*')
shutil.copytree(src_dir, dst_dir, ignore=patterns)
# checking the result: some elements should not be copied
- self.assert_(not exists(join(dst_dir, 'test.tmp')))
- self.assert_(not exists(join(dst_dir, 'test_dir2', 'subdir2')))
- self.assert_(not exists(join(dst_dir, 'test_dir2', 'subdir')))
+ self.assertTrue(not exists(join(dst_dir, 'test.tmp')))
+ self.assertTrue(not exists(join(dst_dir, 'test_dir2', 'subdir2')))
+ self.assertTrue(not exists(join(dst_dir, 'test_dir2', 'subdir')))
finally:
if os.path.exists(dst_dir):
shutil.rmtree(dst_dir)
@@ -192,9 +192,9 @@
shutil.copytree(src_dir, dst_dir, ignore=_filter)
# checking the result: some elements should not be copied
- self.assert_(not exists(join(dst_dir, 'test_dir2', 'subdir2',
+ self.assertTrue(not exists(join(dst_dir, 'test_dir2', 'subdir2',
'test.py')))
- self.assert_(not exists(join(dst_dir, 'test_dir2', 'subdir')))
+ self.assertTrue(not exists(join(dst_dir, 'test_dir2', 'subdir')))
finally:
if os.path.exists(dst_dir):
@@ -393,7 +393,7 @@
for src, dst in [('srcdir', 'srcdir/dest')]:
src = os.path.join(TESTFN, src)
dst = os.path.join(TESTFN, dst)
- self.assert_(shutil._destinsrc(src, dst),
+ self.assertTrue(shutil._destinsrc(src, dst),
msg='_destinsrc() wrongly concluded that '
'dst (%s) is not in src (%s)' % (dst, src))
finally:
@@ -405,7 +405,7 @@
for src, dst in [('srcdir', 'src/dest'), ('srcdir', 'srcdir.new')]:
src = os.path.join(TESTFN, src)
dst = os.path.join(TESTFN, dst)
- self.failIf(shutil._destinsrc(src, dst),
+ self.assertFalse(shutil._destinsrc(src, dst),
msg='_destinsrc() wrongly concluded that '
'dst (%s) is in src (%s)' % (dst, src))
finally:
Modified: python/branches/py3k/Lib/test/test_signal.py
==============================================================================
--- python/branches/py3k/Lib/test/test_signal.py (original)
+++ python/branches/py3k/Lib/test/test_signal.py Wed Jul 1 01:06:06 2009
@@ -217,10 +217,10 @@
# before select is called
time.sleep(self.TIMEOUT_FULL)
mid_time = time.time()
- self.assert_(mid_time - before_time < self.TIMEOUT_HALF)
+ self.assertTrue(mid_time - before_time < self.TIMEOUT_HALF)
select.select([self.read], [], [], self.TIMEOUT_FULL)
after_time = time.time()
- self.assert_(after_time - mid_time < self.TIMEOUT_HALF)
+ self.assertTrue(after_time - mid_time < self.TIMEOUT_HALF)
def test_wakeup_fd_during(self):
import select
@@ -231,7 +231,7 @@
self.assertRaises(select.error, select.select,
[self.read], [], [], self.TIMEOUT_FULL)
after_time = time.time()
- self.assert_(after_time - before_time < self.TIMEOUT_HALF)
+ self.assertTrue(after_time - before_time < self.TIMEOUT_HALF)
def setUp(self):
import fcntl
Modified: python/branches/py3k/Lib/test/test_site.py
==============================================================================
--- python/branches/py3k/Lib/test/test_site.py (original)
+++ python/branches/py3k/Lib/test/test_site.py Wed Jul 1 01:06:06 2009
@@ -47,26 +47,26 @@
path_parts = ("Beginning", "End")
original_dir = os.path.join(*path_parts)
abs_dir, norm_dir = site.makepath(*path_parts)
- self.failUnlessEqual(os.path.abspath(original_dir), abs_dir)
+ self.assertEqual(os.path.abspath(original_dir), abs_dir)
if original_dir == os.path.normcase(original_dir):
- self.failUnlessEqual(abs_dir, norm_dir)
+ self.assertEqual(abs_dir, norm_dir)
else:
- self.failUnlessEqual(os.path.normcase(abs_dir), norm_dir)
+ self.assertEqual(os.path.normcase(abs_dir), norm_dir)
def test_init_pathinfo(self):
dir_set = site._init_pathinfo()
for entry in [site.makepath(path)[1] for path in sys.path
if path and os.path.isdir(path)]:
- self.failUnless(entry in dir_set,
+ self.assertTrue(entry in dir_set,
"%s from sys.path not found in set returned "
"by _init_pathinfo(): %s" % (entry, dir_set))
def pth_file_tests(self, pth_file):
"""Contain common code for testing results of reading a .pth file"""
- self.failUnless(pth_file.imported in sys.modules,
+ self.assertTrue(pth_file.imported in sys.modules,
"%s not in sys.path" % pth_file.imported)
- self.failUnless(site.makepath(pth_file.good_dir_path)[0] in sys.path)
- self.failUnless(not os.path.exists(pth_file.bad_dir_path))
+ self.assertTrue(site.makepath(pth_file.good_dir_path)[0] in sys.path)
+ self.assertTrue(not os.path.exists(pth_file.bad_dir_path))
def test_addpackage(self):
# Make sure addpackage() imports if the line starts with 'import',
@@ -98,7 +98,7 @@
def test_s_option(self):
usersite = site.USER_SITE
- self.assert_(usersite in sys.path)
+ self.assertTrue(usersite in sys.path)
rc = subprocess.call([sys.executable, '-c',
'import sys; sys.exit(%r in sys.path)' % usersite])
@@ -196,7 +196,7 @@
site.abs__file__()
for module in (sys, os, builtins):
try:
- self.failUnless(os.path.isabs(module.__file__), repr(module))
+ self.assertTrue(os.path.isabs(module.__file__), repr(module))
except AttributeError:
continue
# We could try everything in sys.modules; however, when regrtest.py
@@ -209,7 +209,7 @@
site.removeduppaths()
seen_paths = set()
for path in sys.path:
- self.failUnless(path not in seen_paths)
+ self.assertTrue(path not in seen_paths)
seen_paths.add(path)
def test_add_build_dir(self):
@@ -220,17 +220,17 @@
def test_setting_quit(self):
# 'quit' and 'exit' should be injected into builtins
- self.failUnless(hasattr(builtins, "quit"))
- self.failUnless(hasattr(builtins, "exit"))
+ self.assertTrue(hasattr(builtins, "quit"))
+ self.assertTrue(hasattr(builtins, "exit"))
def test_setting_copyright(self):
# 'copyright' and 'credits' should be in builtins
- self.failUnless(hasattr(builtins, "copyright"))
- self.failUnless(hasattr(builtins, "credits"))
+ self.assertTrue(hasattr(builtins, "copyright"))
+ self.assertTrue(hasattr(builtins, "credits"))
def test_setting_help(self):
# 'help' should be set in builtins
- self.failUnless(hasattr(builtins, "help"))
+ self.assertTrue(hasattr(builtins, "help"))
def test_aliasing_mbcs(self):
if sys.platform == "win32":
@@ -244,7 +244,7 @@
def test_setdefaultencoding_removed(self):
# Make sure sys.setdefaultencoding is gone
- self.failUnless(not hasattr(sys, "setdefaultencoding"))
+ self.assertTrue(not hasattr(sys, "setdefaultencoding"))
def test_sitecustomize_executed(self):
# If sitecustomize is available, it should have been imported.
Modified: python/branches/py3k/Lib/test/test_slice.py
==============================================================================
--- python/branches/py3k/Lib/test/test_slice.py (original)
+++ python/branches/py3k/Lib/test/test_slice.py Wed Jul 1 01:06:06 2009
@@ -73,7 +73,7 @@
obj = AnyClass()
s = slice(obj)
- self.assert_(s.stop is obj)
+ self.assertTrue(s.stop is obj)
def test_indices(self):
self.assertEqual(slice(None ).indices(10), (0, 10, 1))
Modified: python/branches/py3k/Lib/test/test_socket.py
==============================================================================
--- python/branches/py3k/Lib/test/test_socket.py (original)
+++ python/branches/py3k/Lib/test/test_socket.py Wed Jul 1 01:06:06 2009
@@ -224,7 +224,7 @@
def test_repr(self):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.assert_(repr(s).startswith("<socket.socket object"))
+ self.assertTrue(repr(s).startswith("<socket.socket object"))
def test_weakref(self):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -247,11 +247,11 @@
raise socket.herror
def raise_gaierror(*args, **kwargs):
raise socket.gaierror
- self.failUnlessRaises(socket.error, raise_error,
+ self.assertRaises(socket.error, raise_error,
"Error raising socket exception.")
- self.failUnlessRaises(socket.error, raise_herror,
+ self.assertRaises(socket.error, raise_herror,
"Error raising socket exception.")
- self.failUnlessRaises(socket.error, raise_gaierror,
+ self.assertRaises(socket.error, raise_gaierror,
"Error raising socket exception.")
def testCrucialConstants(self):
@@ -273,7 +273,7 @@
except socket.error:
# Probably name lookup wasn't set up right; skip this test
return
- self.assert_(ip.find('.') >= 0, "Error resolving host to ip.")
+ self.assertTrue(ip.find('.') >= 0, "Error resolving host to ip.")
try:
hname, aliases, ipaddrs = socket.gethostbyaddr(ip)
except socket.error:
@@ -501,7 +501,7 @@
# it reasonable to get the host's addr in addition to 0.0.0.0.
# At least for eCos. This is required for the S/390 to pass.
my_ip_addr = socket.gethostbyname(socket.gethostname())
- self.assert_(name[0] in ("0.0.0.0", my_ip_addr), '%s invalid' % name[0])
+ self.assertTrue(name[0] in ("0.0.0.0", my_ip_addr), '%s invalid' % name[0])
self.assertEqual(name[1], port)
def testGetSockOpt(self):
@@ -509,14 +509,14 @@
# We know a socket should start without reuse==0
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)
- self.failIf(reuse != 0, "initial mode is reuse")
+ self.assertFalse(reuse != 0, "initial mode is reuse")
def testSetSockOpt(self):
# Testing setsockopt()
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)
- self.failIf(reuse == 0, "failed to set reuse mode")
+ self.assertFalse(reuse == 0, "failed to set reuse mode")
def testSendAfterClose(self):
# testing send() after close() with timeout
@@ -549,10 +549,10 @@
def test_sock_ioctl(self):
if os.name != "nt":
return
- self.assert_(hasattr(socket.socket, 'ioctl'))
- self.assert_(hasattr(socket, 'SIO_RCVALL'))
- self.assert_(hasattr(socket, 'RCVALL_ON'))
- self.assert_(hasattr(socket, 'RCVALL_OFF'))
+ self.assertTrue(hasattr(socket.socket, 'ioctl'))
+ self.assertTrue(hasattr(socket, 'SIO_RCVALL'))
+ self.assertTrue(hasattr(socket, 'RCVALL_ON'))
+ self.assertTrue(hasattr(socket, 'RCVALL_OFF'))
class BasicTCPTest(SocketConnectedTest):
@@ -724,7 +724,7 @@
except socket.error:
pass
end = time.time()
- self.assert_((end - start) < 1.0, "Error setting non-blocking mode.")
+ self.assertTrue((end - start) < 1.0, "Error setting non-blocking mode.")
def _testSetBlocking(self):
pass
@@ -801,7 +801,7 @@
def tearDown(self):
self.serv_file.close()
- self.assert_(self.serv_file.closed)
+ self.assertTrue(self.serv_file.closed)
self.serv_file = None
SocketConnectedTest.tearDown(self)
@@ -811,7 +811,7 @@
def clientTearDown(self):
self.cli_file.close()
- self.assert_(self.cli_file.closed)
+ self.assertTrue(self.cli_file.closed)
self.cli_file = None
SocketConnectedTest.clientTearDown(self)
@@ -879,10 +879,10 @@
self.cli_file.flush()
def testClosedAttr(self):
- self.assert_(not self.serv_file.closed)
+ self.assertTrue(not self.serv_file.closed)
def _testClosedAttr(self):
- self.assert_(not self.cli_file.closed)
+ self.assertTrue(not self.cli_file.closed)
def testAttributes(self):
self.assertEqual(self.serv_file.mode, 'rb')
@@ -977,7 +977,7 @@
def testWithoutServer(self):
port = support.find_unused_port()
- self.failUnlessRaises(
+ self.assertRaises(
socket.error,
lambda: socket.create_connection((HOST, port))
)
@@ -1007,7 +1007,7 @@
testTimeoutDefault = _justAccept
def _testTimeoutDefault(self):
# passing no explicit timeout uses socket's global default
- self.assert_(socket.getdefaulttimeout() is None)
+ self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(42)
try:
self.cli = socket.create_connection((HOST, self.port))
@@ -1018,7 +1018,7 @@
testTimeoutNone = _justAccept
def _testTimeoutNone(self):
# None timeout means the same as sock.settimeout(None)
- self.assert_(socket.getdefaulttimeout() is None)
+ self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
try:
self.cli = socket.create_connection((HOST, self.port), timeout=None)
@@ -1063,7 +1063,7 @@
def _testOutsideTimeout(self):
self.cli = sock = socket.create_connection((HOST, self.port), timeout=1)
- self.failUnlessRaises(socket.timeout, lambda: sock.recv(5))
+ self.assertRaises(socket.timeout, lambda: sock.recv(5))
class TCPTimeoutTest(SocketTCPTest):
@@ -1072,7 +1072,7 @@
def raise_timeout(*args, **kwargs):
self.serv.settimeout(1.0)
self.serv.accept()
- self.failUnlessRaises(socket.timeout, raise_timeout,
+ self.assertRaises(socket.timeout, raise_timeout,
"Error generating a timeout exception (TCP)")
def testTimeoutZero(self):
@@ -1129,7 +1129,7 @@
def raise_timeout(*args, **kwargs):
self.serv.settimeout(1.0)
self.serv.recv(1024)
- self.failUnlessRaises(socket.timeout, raise_timeout,
+ self.assertRaises(socket.timeout, raise_timeout,
"Error generating a timeout exception (UDP)")
def testTimeoutZero(self):
@@ -1149,10 +1149,10 @@
class TestExceptions(unittest.TestCase):
def testExceptionTree(self):
- self.assert_(issubclass(socket.error, Exception))
- self.assert_(issubclass(socket.herror, socket.error))
- self.assert_(issubclass(socket.gaierror, socket.error))
- self.assert_(issubclass(socket.timeout, socket.error))
+ self.assertTrue(issubclass(socket.error, Exception))
+ self.assertTrue(issubclass(socket.herror, socket.error))
+ self.assertTrue(issubclass(socket.gaierror, socket.error))
+ self.assertTrue(issubclass(socket.timeout, socket.error))
class TestLinuxAbstractNamespace(unittest.TestCase):
Modified: python/branches/py3k/Lib/test/test_stringprep.py
==============================================================================
--- python/branches/py3k/Lib/test/test_stringprep.py (original)
+++ python/branches/py3k/Lib/test/test_stringprep.py Wed Jul 1 01:06:06 2009
@@ -8,66 +8,66 @@
class StringprepTests(unittest.TestCase):
def test(self):
- self.failUnless(in_table_a1("\u0221"))
- self.failIf(in_table_a1("\u0222"))
+ self.assertTrue(in_table_a1("\u0221"))
+ self.assertFalse(in_table_a1("\u0222"))
- self.failUnless(in_table_b1("\u00ad"))
- self.failIf(in_table_b1("\u00ae"))
+ self.assertTrue(in_table_b1("\u00ad"))
+ self.assertFalse(in_table_b1("\u00ae"))
- self.failUnless(map_table_b2("\u0041"), "\u0061")
- self.failUnless(map_table_b2("\u0061"), "\u0061")
+ self.assertTrue(map_table_b2("\u0041"), "\u0061")
+ self.assertTrue(map_table_b2("\u0061"), "\u0061")
- self.failUnless(map_table_b3("\u0041"), "\u0061")
- self.failUnless(map_table_b3("\u0061"), "\u0061")
+ self.assertTrue(map_table_b3("\u0041"), "\u0061")
+ self.assertTrue(map_table_b3("\u0061"), "\u0061")
- self.failUnless(in_table_c11("\u0020"))
- self.failIf(in_table_c11("\u0021"))
+ self.assertTrue(in_table_c11("\u0020"))
+ self.assertFalse(in_table_c11("\u0021"))
- self.failUnless(in_table_c12("\u00a0"))
- self.failIf(in_table_c12("\u00a1"))
+ self.assertTrue(in_table_c12("\u00a0"))
+ self.assertFalse(in_table_c12("\u00a1"))
- self.failUnless(in_table_c12("\u00a0"))
- self.failIf(in_table_c12("\u00a1"))
+ self.assertTrue(in_table_c12("\u00a0"))
+ self.assertFalse(in_table_c12("\u00a1"))
- self.failUnless(in_table_c11_c12("\u00a0"))
- self.failIf(in_table_c11_c12("\u00a1"))
+ self.assertTrue(in_table_c11_c12("\u00a0"))
+ self.assertFalse(in_table_c11_c12("\u00a1"))
- self.failUnless(in_table_c21("\u001f"))
- self.failIf(in_table_c21("\u0020"))
+ self.assertTrue(in_table_c21("\u001f"))
+ self.assertFalse(in_table_c21("\u0020"))
- self.failUnless(in_table_c22("\u009f"))
- self.failIf(in_table_c22("\u00a0"))
+ self.assertTrue(in_table_c22("\u009f"))
+ self.assertFalse(in_table_c22("\u00a0"))
- self.failUnless(in_table_c21_c22("\u009f"))
- self.failIf(in_table_c21_c22("\u00a0"))
+ self.assertTrue(in_table_c21_c22("\u009f"))
+ self.assertFalse(in_table_c21_c22("\u00a0"))
- self.failUnless(in_table_c3("\ue000"))
- self.failIf(in_table_c3("\uf900"))
+ self.assertTrue(in_table_c3("\ue000"))
+ self.assertFalse(in_table_c3("\uf900"))
- self.failUnless(in_table_c4("\uffff"))
- self.failIf(in_table_c4("\u0000"))
+ self.assertTrue(in_table_c4("\uffff"))
+ self.assertFalse(in_table_c4("\u0000"))
- self.failUnless(in_table_c5("\ud800"))
- self.failIf(in_table_c5("\ud7ff"))
+ self.assertTrue(in_table_c5("\ud800"))
+ self.assertFalse(in_table_c5("\ud7ff"))
- self.failUnless(in_table_c6("\ufff9"))
- self.failIf(in_table_c6("\ufffe"))
+ self.assertTrue(in_table_c6("\ufff9"))
+ self.assertFalse(in_table_c6("\ufffe"))
- self.failUnless(in_table_c7("\u2ff0"))
- self.failIf(in_table_c7("\u2ffc"))
+ self.assertTrue(in_table_c7("\u2ff0"))
+ self.assertFalse(in_table_c7("\u2ffc"))
- self.failUnless(in_table_c8("\u0340"))
- self.failIf(in_table_c8("\u0342"))
+ self.assertTrue(in_table_c8("\u0340"))
+ self.assertFalse(in_table_c8("\u0342"))
# C.9 is not in the bmp
- # self.failUnless(in_table_c9(u"\U000E0001"))
- # self.failIf(in_table_c8(u"\U000E0002"))
+ # self.assertTrue(in_table_c9(u"\U000E0001"))
+ # self.assertFalse(in_table_c8(u"\U000E0002"))
- self.failUnless(in_table_d1("\u05be"))
- self.failIf(in_table_d1("\u05bf"))
+ self.assertTrue(in_table_d1("\u05be"))
+ self.assertFalse(in_table_d1("\u05bf"))
- self.failUnless(in_table_d2("\u0041"))
- self.failIf(in_table_d2("\u0040"))
+ self.assertTrue(in_table_d2("\u0041"))
+ self.assertFalse(in_table_d2("\u0040"))
# This would generate a hash of all predicates. However, running
# it is quite expensive, and only serves to detect changes in the
Modified: python/branches/py3k/Lib/test/test_strptime.py
==============================================================================
--- python/branches/py3k/Lib/test/test_strptime.py (original)
+++ python/branches/py3k/Lib/test/test_strptime.py Wed Jul 1 01:06:06 2009
@@ -13,7 +13,7 @@
class getlang_Tests(unittest.TestCase):
"""Test _getlang"""
def test_basic(self):
- self.failUnlessEqual(_strptime._getlang(), locale.getlocale(locale.LC_TIME))
+ self.assertEqual(_strptime._getlang(), locale.getlocale(locale.LC_TIME))
class LocaleTime_Tests(unittest.TestCase):
"""Tests for _strptime.LocaleTime.
@@ -36,9 +36,9 @@
"""
strftime_output = time.strftime(directive, self.time_tuple).lower()
comparison = testing[self.time_tuple[tuple_position]]
- self.failUnless(strftime_output in testing, "%s: not found in tuple" %
+ self.assertTrue(strftime_output in testing, "%s: not found in tuple" %
error_msg)
- self.failUnless(comparison == strftime_output,
+ self.assertTrue(comparison == strftime_output,
"%s: position within tuple incorrect; %s != %s" %
(error_msg, comparison, strftime_output))
@@ -61,18 +61,18 @@
def test_am_pm(self):
# Make sure AM/PM representation done properly
strftime_output = time.strftime("%p", self.time_tuple).lower()
- self.failUnless(strftime_output in self.LT_ins.am_pm,
+ self.assertTrue(strftime_output in self.LT_ins.am_pm,
"AM/PM representation not in tuple")
if self.time_tuple[3] < 12: position = 0
else: position = 1
- self.failUnless(strftime_output == self.LT_ins.am_pm[position],
+ self.assertTrue(strftime_output == self.LT_ins.am_pm[position],
"AM/PM representation in the wrong position within the tuple")
def test_timezone(self):
# Make sure timezone is correct
timezone = time.strftime("%Z", self.time_tuple).lower()
if timezone:
- self.failUnless(timezone in self.LT_ins.timezone[0] or \
+ self.assertTrue(timezone in self.LT_ins.timezone[0] or \
timezone in self.LT_ins.timezone[1],
"timezone %s not found in %s" %
(timezone, self.LT_ins.timezone))
@@ -86,26 +86,26 @@
# output.
magic_date = (1999, 3, 17, 22, 44, 55, 2, 76, 0)
strftime_output = time.strftime("%c", magic_date)
- self.failUnless(strftime_output == time.strftime(self.LT_ins.LC_date_time,
+ self.assertTrue(strftime_output == time.strftime(self.LT_ins.LC_date_time,
magic_date),
"LC_date_time incorrect")
strftime_output = time.strftime("%x", magic_date)
- self.failUnless(strftime_output == time.strftime(self.LT_ins.LC_date,
+ self.assertTrue(strftime_output == time.strftime(self.LT_ins.LC_date,
magic_date),
"LC_date incorrect")
strftime_output = time.strftime("%X", magic_date)
- self.failUnless(strftime_output == time.strftime(self.LT_ins.LC_time,
+ self.assertTrue(strftime_output == time.strftime(self.LT_ins.LC_time,
magic_date),
"LC_time incorrect")
LT = _strptime.LocaleTime()
LT.am_pm = ('', '')
- self.failUnless(LT.LC_time, "LocaleTime's LC directives cannot handle "
+ self.assertTrue(LT.LC_time, "LocaleTime's LC directives cannot handle "
"empty strings")
def test_lang(self):
# Make sure lang is set to what _getlang() returns
# Assuming locale has not changed between now and when self.LT_ins was created
- self.failUnlessEqual(self.LT_ins.lang, _strptime._getlang())
+ self.assertEqual(self.LT_ins.lang, _strptime._getlang())
class TimeRETests(unittest.TestCase):
@@ -119,13 +119,13 @@
def test_pattern(self):
# Test TimeRE.pattern
pattern_string = self.time_re.pattern(r"%a %A %d")
- self.failUnless(pattern_string.find(self.locale_time.a_weekday[2]) != -1,
+ self.assertTrue(pattern_string.find(self.locale_time.a_weekday[2]) != -1,
"did not find abbreviated weekday in pattern string '%s'" %
pattern_string)
- self.failUnless(pattern_string.find(self.locale_time.f_weekday[4]) != -1,
+ self.assertTrue(pattern_string.find(self.locale_time.f_weekday[4]) != -1,
"did not find full weekday in pattern string '%s'" %
pattern_string)
- self.failUnless(pattern_string.find(self.time_re['d']) != -1,
+ self.assertTrue(pattern_string.find(self.time_re['d']) != -1,
"did not find 'd' directive pattern string '%s'" %
pattern_string)
@@ -133,23 +133,23 @@
# Make sure any characters in the format string that might be taken as
# regex syntax is escaped.
pattern_string = self.time_re.pattern("\d+")
- self.failUnless(r"\\d\+" in pattern_string,
+ self.assertTrue(r"\\d\+" in pattern_string,
"%s does not have re characters escaped properly" %
pattern_string)
def test_compile(self):
# Check that compiled regex is correct
found = self.time_re.compile(r"%A").match(self.locale_time.f_weekday[6])
- self.failUnless(found and found.group('A') == self.locale_time.f_weekday[6],
+ self.assertTrue(found and found.group('A') == self.locale_time.f_weekday[6],
"re object for '%A' failed")
compiled = self.time_re.compile(r"%a %b")
found = compiled.match("%s %s" % (self.locale_time.a_weekday[4],
self.locale_time.a_month[4]))
- self.failUnless(found,
+ self.assertTrue(found,
"Match failed with '%s' regex and '%s' string" %
(compiled.pattern, "%s %s" % (self.locale_time.a_weekday[4],
self.locale_time.a_month[4])))
- self.failUnless(found.group('a') == self.locale_time.a_weekday[4] and
+ self.assertTrue(found.group('a') == self.locale_time.a_weekday[4] and
found.group('b') == self.locale_time.a_month[4],
"re object couldn't find the abbreviated weekday month in "
"'%s' using '%s'; group 'a' = '%s', group 'b' = %s'" %
@@ -159,7 +159,7 @@
'U','w','W','x','X','y','Y','Z','%'):
compiled = self.time_re.compile("%" + directive)
found = compiled.match(time.strftime("%" + directive))
- self.failUnless(found, "Matching failed on '%s' using '%s' regex" %
+ self.assertTrue(found, "Matching failed on '%s' using '%s' regex" %
(time.strftime("%" + directive),
compiled.pattern))
@@ -168,14 +168,14 @@
# Fixes bug #661354
test_locale = _strptime.LocaleTime()
test_locale.timezone = (frozenset(), frozenset())
- self.failUnless(_strptime.TimeRE(test_locale).pattern("%Z") == '',
+ self.assertTrue(_strptime.TimeRE(test_locale).pattern("%Z") == '',
"with timezone == ('',''), TimeRE().pattern('%Z') != ''")
def test_matching_with_escapes(self):
# Make sure a format that requires escaping of characters works
compiled_re = self.time_re.compile("\w+ %m")
found = compiled_re.match("\w+ 10")
- self.failUnless(found, "Escaping failed of format '\w+ 10'")
+ self.assertTrue(found, "Escaping failed of format '\w+ 10'")
def test_locale_data_w_regex_metacharacters(self):
# Check that if locale data contains regex metacharacters they are
@@ -186,7 +186,7 @@
"Tokyo (standard time)")),
frozenset("Tokyo (daylight time)"))
time_re = _strptime.TimeRE(locale_time)
- self.failUnless(time_re.compile("%Z").match("Tokyo (standard time)"),
+ self.assertTrue(time_re.compile("%Z").match("Tokyo (standard time)"),
"locale data that contains regex metacharacters is not"
" properly escaped")
@@ -195,8 +195,8 @@
# so as to not allow to subpatterns to end up next to each other and
# "steal" characters from each other.
pattern = self.time_re.pattern('%j %H')
- self.failUnless(not re.match(pattern, "180"))
- self.failUnless(re.match(pattern, "18 0"))
+ self.assertTrue(not re.match(pattern, "180"))
+ self.assertTrue(re.match(pattern, "18 0"))
class StrptimeTests(unittest.TestCase):
@@ -229,7 +229,7 @@
"""Helper fxn in testing."""
strf_output = time.strftime("%" + directive, self.time_tuple)
strp_output = _strptime._strptime_time(strf_output, "%" + directive)
- self.failUnless(strp_output[position] == self.time_tuple[position],
+ self.assertTrue(strp_output[position] == self.time_tuple[position],
"testing of '%s' directive failed; '%s' -> %s != %s" %
(directive, strf_output, strp_output[position],
self.time_tuple[position]))
@@ -243,7 +243,7 @@
for bound in bounds:
strp_output = _strptime._strptime_time(bound, '%y')
expected_result = century + int(bound)
- self.failUnless(strp_output[0] == expected_result,
+ self.assertTrue(strp_output[0] == expected_result,
"'y' test failed; passed in '%s' "
"and returned '%s'" % (bound, strp_output[0]))
@@ -261,7 +261,7 @@
self.helper('H', 3)
strf_output = time.strftime("%I %p", self.time_tuple)
strp_output = _strptime._strptime_time(strf_output, "%I %p")
- self.failUnless(strp_output[3] == self.time_tuple[3],
+ self.assertTrue(strp_output[3] == self.time_tuple[3],
"testing of '%%I %%p' directive failed; '%s' -> %s != %s" %
(strf_output, strp_output[3], self.time_tuple[3]))
@@ -294,9 +294,9 @@
# Check for equal timezone names deals with bad locale info when this
# occurs; first found in FreeBSD 4.4.
strp_output = _strptime._strptime_time("UTC", "%Z")
- self.failUnlessEqual(strp_output.tm_isdst, 0)
+ self.assertEqual(strp_output.tm_isdst, 0)
strp_output = _strptime._strptime_time("GMT", "%Z")
- self.failUnlessEqual(strp_output.tm_isdst, 0)
+ self.assertEqual(strp_output.tm_isdst, 0)
if sys.platform == "mac":
# Timezones don't really work on MacOS9
return
@@ -305,11 +305,11 @@
strp_output = _strptime._strptime_time(strf_output, "%Z")
locale_time = _strptime.LocaleTime()
if time.tzname[0] != time.tzname[1] or not time.daylight:
- self.failUnless(strp_output[8] == time_tuple[8],
+ self.assertTrue(strp_output[8] == time_tuple[8],
"timezone check failed; '%s' -> %s != %s" %
(strf_output, strp_output[8], time_tuple[8]))
else:
- self.failUnless(strp_output[8] == -1,
+ self.assertTrue(strp_output[8] == -1,
"LocaleTime().timezone has duplicate values and "
"time.daylight but timezone value not set to -1")
@@ -327,7 +327,7 @@
time.tzname = (tz_name, tz_name)
time.daylight = 1
tz_value = _strptime._strptime_time(tz_name, "%Z")[8]
- self.failUnlessEqual(tz_value, -1,
+ self.assertEqual(tz_value, -1,
"%s lead to a timezone value of %s instead of -1 when "
"time.daylight set to %s and passing in %s" %
(time.tzname, tz_value, time.daylight, tz_name))
@@ -354,25 +354,25 @@
# Make sure % signs are handled properly
strf_output = time.strftime("%m %% %Y", self.time_tuple)
strp_output = _strptime._strptime_time(strf_output, "%m %% %Y")
- self.failUnless(strp_output[0] == self.time_tuple[0] and
+ self.assertTrue(strp_output[0] == self.time_tuple[0] and
strp_output[1] == self.time_tuple[1],
"handling of percent sign failed")
def test_caseinsensitive(self):
# Should handle names case-insensitively.
strf_output = time.strftime("%B", self.time_tuple)
- self.failUnless(_strptime._strptime_time(strf_output.upper(), "%B"),
+ self.assertTrue(_strptime._strptime_time(strf_output.upper(), "%B"),
"strptime does not handle ALL-CAPS names properly")
- self.failUnless(_strptime._strptime_time(strf_output.lower(), "%B"),
+ self.assertTrue(_strptime._strptime_time(strf_output.lower(), "%B"),
"strptime does not handle lowercase names properly")
- self.failUnless(_strptime._strptime_time(strf_output.capitalize(), "%B"),
+ self.assertTrue(_strptime._strptime_time(strf_output.capitalize(), "%B"),
"strptime does not handle capword names properly")
def test_defaults(self):
# Default return value should be (1900, 1, 1, 0, 0, 0, 0, 1, 0)
defaults = (1900, 1, 1, 0, 0, 0, 0, 1, -1)
strp_output = _strptime._strptime_time('1', '%m')
- self.failUnless(strp_output == defaults,
+ self.assertTrue(strp_output == defaults,
"Default values for strptime() are incorrect;"
" %s != %s" % (strp_output, defaults))
@@ -383,7 +383,7 @@
# escaped.
# Test instigated by bug #796149 .
need_escaping = ".^$*+?{}\[]|)("
- self.failUnless(_strptime._strptime_time(need_escaping, need_escaping))
+ self.assertTrue(_strptime._strptime_time(need_escaping, need_escaping))
class Strptime12AMPMTests(unittest.TestCase):
"""Test a _strptime regression in '%I %p' at 12 noon (12 PM)"""
@@ -416,7 +416,7 @@
format_string = "%Y %m %d %H %M %S %w %Z"
result = _strptime._strptime_time(time.strftime(format_string, self.time_tuple),
format_string)
- self.failUnless(result.tm_yday == self.time_tuple.tm_yday,
+ self.assertTrue(result.tm_yday == self.time_tuple.tm_yday,
"Calculation of tm_yday failed; %s != %s" %
(result.tm_yday, self.time_tuple.tm_yday))
@@ -425,7 +425,7 @@
format_string = "%Y %H %M %S %w %j %Z"
result = _strptime._strptime_time(time.strftime(format_string, self.time_tuple),
format_string)
- self.failUnless(result.tm_year == self.time_tuple.tm_year and
+ self.assertTrue(result.tm_year == self.time_tuple.tm_year and
result.tm_mon == self.time_tuple.tm_mon and
result.tm_mday == self.time_tuple.tm_mday,
"Calculation of Gregorian date failed;"
@@ -439,7 +439,7 @@
format_string = "%Y %m %d %H %S %j %Z"
result = _strptime._strptime_time(time.strftime(format_string, self.time_tuple),
format_string)
- self.failUnless(result.tm_wday == self.time_tuple.tm_wday,
+ self.assertTrue(result.tm_wday == self.time_tuple.tm_wday,
"Calculation of day of the week failed;"
"%s != %s" % (result.tm_wday, self.time_tuple.tm_wday))
@@ -452,7 +452,7 @@
dt_date = datetime_date(*ymd_tuple)
strp_input = dt_date.strftime(format_string)
strp_output = _strptime._strptime_time(strp_input, format_string)
- self.failUnless(strp_output[:3] == ymd_tuple,
+ self.assertTrue(strp_output[:3] == ymd_tuple,
"%s(%s) test failed w/ '%s': %s != %s (%s != %s)" %
(test_reason, directive, strp_input,
strp_output[:3], ymd_tuple,
@@ -495,8 +495,8 @@
_strptime._TimeRE_cache.locale_time.lang = "Ni"
original_time_re = id(_strptime._TimeRE_cache)
_strptime._strptime_time("10", "%d")
- self.failIfEqual(original_time_re, id(_strptime._TimeRE_cache))
- self.failUnlessEqual(len(_strptime._regex_cache), 1)
+ self.assertNotEqual(original_time_re, id(_strptime._TimeRE_cache))
+ self.assertEqual(len(_strptime._regex_cache), 1)
def test_regex_cleanup(self):
# Make sure cached regexes are discarded when cache becomes "full".
@@ -509,7 +509,7 @@
_strptime._regex_cache[bogus_key] = None
bogus_key += 1
_strptime._strptime_time("10", "%d")
- self.failUnlessEqual(len(_strptime._regex_cache), 1)
+ self.assertEqual(len(_strptime._regex_cache), 1)
def test_new_localetime(self):
# A new LocaleTime instance should be created when a new TimeRE object
@@ -517,7 +517,7 @@
locale_time_id = id(_strptime._TimeRE_cache.locale_time)
_strptime._TimeRE_cache.locale_time.lang = "Ni"
_strptime._strptime_time("10", "%d")
- self.failIfEqual(locale_time_id,
+ self.assertNotEqual(locale_time_id,
id(_strptime._TimeRE_cache.locale_time))
def test_TimeRE_recreation(self):
@@ -538,7 +538,7 @@
# Get the new cache object's id.
second_time_re_id = id(_strptime._TimeRE_cache)
# They should not be equal.
- self.failIfEqual(first_time_re_id, second_time_re_id)
+ self.assertNotEqual(first_time_re_id, second_time_re_id)
# Possible test locale is not supported while initial locale is.
# If this is the case just suppress the exception and fall-through
# to the reseting to the original locale.
Modified: python/branches/py3k/Lib/test/test_struct.py
==============================================================================
--- python/branches/py3k/Lib/test/test_struct.py (original)
+++ python/branches/py3k/Lib/test/test_struct.py Wed Jul 1 01:06:06 2009
@@ -126,7 +126,7 @@
# encoding of the string when packed.
arg = bytes(arg, 'latin1')
if rev != arg:
- self.assert_(asy)
+ self.assertTrue(asy)
def test_native_qQ(self):
# can't pack -1 as unsigned regardless
@@ -192,7 +192,7 @@
expected = x
if x < 0:
expected += 1 << self.bitsize
- self.assert_(expected > 0)
+ self.assertTrue(expected > 0)
expected = hex(expected)[2:] # chop "0x"
if len(expected) & 1:
expected = "0" + expected
Modified: python/branches/py3k/Lib/test/test_structseq.py
==============================================================================
--- python/branches/py3k/Lib/test/test_structseq.py (original)
+++ python/branches/py3k/Lib/test/test_structseq.py Wed Jul 1 01:06:06 2009
@@ -28,7 +28,7 @@
def test_repr(self):
t = time.gmtime()
- self.assert_(repr(t))
+ self.assertTrue(repr(t))
t = time.gmtime(0)
self.assertEqual(repr(t),
"time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, "
@@ -50,8 +50,8 @@
def test_contains(self):
t1 = time.gmtime()
for item in t1:
- self.assert_(item in t1)
- self.assert_(-42 not in t1)
+ self.assertTrue(item in t1)
+ self.assertTrue(-42 not in t1)
def test_hash(self):
t1 = time.gmtime()
@@ -61,11 +61,11 @@
t1 = time.gmtime()
t2 = type(t1)(t1)
self.assertEqual(t1, t2)
- self.assert_(not (t1 < t2))
- self.assert_(t1 <= t2)
- self.assert_(not (t1 > t2))
- self.assert_(t1 >= t2)
- self.assert_(not (t1 != t2))
+ self.assertTrue(not (t1 < t2))
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(not (t1 > t2))
+ self.assertTrue(t1 >= t2)
+ self.assertTrue(not (t1 != t2))
def test_fields(self):
t = time.gmtime()
Modified: python/branches/py3k/Lib/test/test_subprocess.py
==============================================================================
--- python/branches/py3k/Lib/test/test_subprocess.py (original)
+++ python/branches/py3k/Lib/test/test_subprocess.py Wed Jul 1 01:06:06 2009
@@ -491,7 +491,7 @@
# but, based on system scheduling we can't control, it's possible
# poll() never returned None. It "should be" very rare that it
# didn't go around at least twice.
- self.assert_(count >= 2)
+ self.assertTrue(count >= 2)
# Subsequent invocations should just return the returncode
self.assertEqual(p.poll(), 0)
@@ -657,7 +657,7 @@
p = subprocess.Popen([sys.executable,
"-c", "input()"])
- self.assert_(p.poll() is None, p.poll())
+ self.assertTrue(p.poll() is None, p.poll())
p.send_signal(signal.SIGINT)
self.assertNotEqual(p.wait(), 0)
@@ -665,7 +665,7 @@
p = subprocess.Popen([sys.executable,
"-c", "input()"])
- self.assert_(p.poll() is None, p.poll())
+ self.assertTrue(p.poll() is None, p.poll())
p.kill()
self.assertEqual(p.wait(), -signal.SIGKILL)
@@ -673,7 +673,7 @@
p = subprocess.Popen([sys.executable,
"-c", "input()"])
- self.assert_(p.poll() is None, p.poll())
+ self.assertTrue(p.poll() is None, p.poll())
p.terminate()
self.assertEqual(p.wait(), -signal.SIGTERM)
@@ -751,7 +751,7 @@
p = subprocess.Popen([sys.executable,
"-c", "input()"])
- self.assert_(p.poll() is None, p.poll())
+ self.assertTrue(p.poll() is None, p.poll())
p.send_signal(signal.SIGTERM)
self.assertNotEqual(p.wait(), 0)
@@ -759,7 +759,7 @@
p = subprocess.Popen([sys.executable,
"-c", "input()"])
- self.assert_(p.poll() is None, p.poll())
+ self.assertTrue(p.poll() is None, p.poll())
p.kill()
self.assertNotEqual(p.wait(), 0)
@@ -767,7 +767,7 @@
p = subprocess.Popen([sys.executable,
"-c", "input()"])
- self.assert_(p.poll() is None, p.poll())
+ self.assertTrue(p.poll() is None, p.poll())
p.terminate()
self.assertNotEqual(p.wait(), 0)
Modified: python/branches/py3k/Lib/test/test_symtable.py
==============================================================================
--- python/branches/py3k/Lib/test/test_symtable.py (original)
+++ python/branches/py3k/Lib/test/test_symtable.py Wed Jul 1 01:06:06 2009
@@ -122,7 +122,7 @@
self.assertTrue(self.top.lookup("namespace_test").is_namespace())
self.assertFalse(self.spam.lookup("x").is_namespace())
- self.assert_(self.top.lookup("spam").get_namespace() is self.spam)
+ self.assertTrue(self.top.lookup("spam").get_namespace() is self.spam)
ns_test = self.top.lookup("namespace_test")
self.assertEqual(len(ns_test.get_namespaces()), 2)
self.assertRaises(ValueError, ns_test.get_namespace)
Modified: python/branches/py3k/Lib/test/test_sys.py
==============================================================================
--- python/branches/py3k/Lib/test/test_sys.py (original)
+++ python/branches/py3k/Lib/test/test_sys.py Wed Jul 1 01:06:06 2009
@@ -30,7 +30,7 @@
dh(None)
self.assertEqual(out.getvalue(), "")
- self.assert_(not hasattr(builtins, "_"))
+ self.assertTrue(not hasattr(builtins, "_"))
dh(42)
self.assertEqual(out.getvalue(), "42\n")
self.assertEqual(builtins._, 42)
@@ -62,12 +62,12 @@
except ValueError as exc:
eh(*sys.exc_info())
- self.assert_(err.getvalue().endswith("ValueError: 42\n"))
+ self.assertTrue(err.getvalue().endswith("ValueError: 42\n"))
def test_excepthook(self):
with test.support.captured_output("stderr") as stderr:
sys.excepthook(1, '1', 1)
- self.assert_("TypeError: print_exception(): Exception expected for " \
+ self.assertTrue("TypeError: print_exception(): Exception expected for " \
"value, str found" in stderr.getvalue())
# FIXME: testing the code for a lost or replaced excepthook in
@@ -136,7 +136,7 @@
def test_getdefaultencoding(self):
self.assertRaises(TypeError, sys.getdefaultencoding, 42)
# can't check more than the type, as the user might have changed it
- self.assert_(isinstance(sys.getdefaultencoding(), str))
+ self.assertTrue(isinstance(sys.getdefaultencoding(), str))
# testing sys.settrace() is done in test_trace.py
# testing sys.setprofile() is done in test_profile.py
@@ -203,20 +203,20 @@
def test_getwindowsversion(self):
if hasattr(sys, "getwindowsversion"):
v = sys.getwindowsversion()
- self.assert_(isinstance(v, tuple))
+ self.assertTrue(isinstance(v, tuple))
self.assertEqual(len(v), 5)
- self.assert_(isinstance(v[0], int))
- self.assert_(isinstance(v[1], int))
- self.assert_(isinstance(v[2], int))
- self.assert_(isinstance(v[3], int))
- self.assert_(isinstance(v[4], str))
+ self.assertTrue(isinstance(v[0], int))
+ self.assertTrue(isinstance(v[1], int))
+ self.assertTrue(isinstance(v[2], int))
+ self.assertTrue(isinstance(v[3], int))
+ self.assertTrue(isinstance(v[4], str))
def test_call_tracing(self):
self.assertRaises(TypeError, sys.call_tracing, type, 2)
def test_dlopenflags(self):
if hasattr(sys, "setdlopenflags"):
- self.assert_(hasattr(sys, "getdlopenflags"))
+ self.assertTrue(hasattr(sys, "getdlopenflags"))
self.assertRaises(TypeError, sys.getdlopenflags, 42)
oldflags = sys.getdlopenflags()
self.assertRaises(TypeError, sys.setdlopenflags)
@@ -237,12 +237,12 @@
del n
self.assertEqual(sys.getrefcount(None), c)
if hasattr(sys, "gettotalrefcount"):
- self.assert_(isinstance(sys.gettotalrefcount(), int))
+ self.assertTrue(isinstance(sys.gettotalrefcount(), int))
def test_getframe(self):
self.assertRaises(TypeError, sys._getframe, 42, 42)
self.assertRaises(ValueError, sys._getframe, 2000000000)
- self.assert_(
+ self.assertTrue(
SysModuleTest.test_getframe.__code__ \
is sys._getframe().f_code
)
@@ -293,12 +293,12 @@
d = sys._current_frames()
main_id = _thread.get_ident()
- self.assert_(main_id in d)
- self.assert_(thread_id in d)
+ self.assertTrue(main_id in d)
+ self.assertTrue(thread_id in d)
# Verify that the captured main-thread frame is _this_ frame.
frame = d.pop(main_id)
- self.assert_(frame is sys._getframe())
+ self.assertTrue(frame is sys._getframe())
# Verify that the captured thread frame is blocked in g456, called
# from f123. This is a litte tricky, since various bits of
@@ -316,7 +316,7 @@
# And the next record must be for g456().
filename, lineno, funcname, sourceline = stack[i+1]
self.assertEqual(funcname, "g456")
- self.assert_(sourceline in ["leave_g.wait()", "entered_g.set()"])
+ self.assertTrue(sourceline in ["leave_g.wait()", "entered_g.set()"])
# Reap the spawned thread.
leave_g.set()
@@ -328,50 +328,50 @@
# "thread id" 0.
d = sys._current_frames()
self.assertEqual(len(d), 1)
- self.assert_(0 in d)
- self.assert_(d[0] is sys._getframe())
+ self.assertTrue(0 in d)
+ self.assertTrue(d[0] is sys._getframe())
def test_attributes(self):
- self.assert_(isinstance(sys.api_version, int))
- self.assert_(isinstance(sys.argv, list))
- self.assert_(sys.byteorder in ("little", "big"))
- self.assert_(isinstance(sys.builtin_module_names, tuple))
- self.assert_(isinstance(sys.copyright, str))
- self.assert_(isinstance(sys.exec_prefix, str))
- self.assert_(isinstance(sys.executable, str))
+ self.assertTrue(isinstance(sys.api_version, int))
+ self.assertTrue(isinstance(sys.argv, list))
+ self.assertTrue(sys.byteorder in ("little", "big"))
+ self.assertTrue(isinstance(sys.builtin_module_names, tuple))
+ self.assertTrue(isinstance(sys.copyright, str))
+ self.assertTrue(isinstance(sys.exec_prefix, str))
+ self.assertTrue(isinstance(sys.executable, str))
self.assertEqual(len(sys.float_info), 11)
self.assertEqual(sys.float_info.radix, 2)
self.assertEqual(len(sys.int_info), 2)
- self.assert_(sys.int_info.bits_per_digit % 5 == 0)
- self.assert_(sys.int_info.sizeof_digit >= 1)
+ self.assertTrue(sys.int_info.bits_per_digit % 5 == 0)
+ self.assertTrue(sys.int_info.sizeof_digit >= 1)
self.assertEqual(type(sys.int_info.bits_per_digit), int)
self.assertEqual(type(sys.int_info.sizeof_digit), int)
- self.assert_(isinstance(sys.hexversion, int))
- self.assert_(isinstance(sys.maxsize, int))
- self.assert_(isinstance(sys.maxunicode, int))
- self.assert_(isinstance(sys.platform, str))
- self.assert_(isinstance(sys.prefix, str))
- self.assert_(isinstance(sys.version, str))
+ self.assertTrue(isinstance(sys.hexversion, int))
+ self.assertTrue(isinstance(sys.maxsize, int))
+ self.assertTrue(isinstance(sys.maxunicode, int))
+ self.assertTrue(isinstance(sys.platform, str))
+ self.assertTrue(isinstance(sys.prefix, str))
+ self.assertTrue(isinstance(sys.version, str))
vi = sys.version_info
- self.assert_(isinstance(vi[:], tuple))
+ self.assertTrue(isinstance(vi[:], tuple))
self.assertEqual(len(vi), 5)
- self.assert_(isinstance(vi[0], int))
- self.assert_(isinstance(vi[1], int))
- self.assert_(isinstance(vi[2], int))
- self.assert_(vi[3] in ("alpha", "beta", "candidate", "final"))
- self.assert_(isinstance(vi[4], int))
- self.assert_(isinstance(vi.major, int))
- self.assert_(isinstance(vi.minor, int))
- self.assert_(isinstance(vi.micro, int))
- self.assert_(vi.releaselevel in
+ self.assertTrue(isinstance(vi[0], int))
+ self.assertTrue(isinstance(vi[1], int))
+ self.assertTrue(isinstance(vi[2], int))
+ self.assertTrue(vi[3] in ("alpha", "beta", "candidate", "final"))
+ self.assertTrue(isinstance(vi[4], int))
+ self.assertTrue(isinstance(vi.major, int))
+ self.assertTrue(isinstance(vi.minor, int))
+ self.assertTrue(isinstance(vi.micro, int))
+ self.assertTrue(vi.releaselevel in
("alpha", "beta", "candidate", "final"))
- self.assert_(isinstance(vi.serial, int))
+ self.assertTrue(isinstance(vi.serial, int))
self.assertEqual(vi[0], vi.major)
self.assertEqual(vi[1], vi.minor)
self.assertEqual(vi[2], vi.micro)
self.assertEqual(vi[3], vi.releaselevel)
self.assertEqual(vi[4], vi.serial)
- self.assert_(vi > (1,0,0))
+ self.assertTrue(vi > (1,0,0))
def test_43581(self):
# Can't use sys.stdout, as this is a StringIO object when
@@ -381,9 +381,9 @@
def test_intern(self):
self.assertRaises(TypeError, sys.intern)
s = "never interned before"
- self.assert_(sys.intern(s) is s)
+ self.assertTrue(sys.intern(s) is s)
s2 = s.swapcase().swapcase()
- self.assert_(sys.intern(s2) is s)
+ self.assertTrue(sys.intern(s2) is s)
# Subclasses of string can't be interned, because they
# provide too much opportunity for insane things to happen.
@@ -398,15 +398,15 @@
def test_sys_flags(self):
- self.failUnless(sys.flags)
+ self.assertTrue(sys.flags)
attrs = ("debug", "division_warning",
"inspect", "interactive", "optimize", "dont_write_bytecode",
"no_user_site", "no_site", "ignore_environment", "verbose",
"bytes_warning")
for attr in attrs:
- self.assert_(hasattr(sys.flags, attr), attr)
+ self.assertTrue(hasattr(sys.flags, attr), attr)
self.assertEqual(type(getattr(sys.flags, attr)), int, attr)
- self.assert_(repr(sys.flags))
+ self.assertTrue(repr(sys.flags))
self.assertEqual(len(sys.flags), len(attrs))
def test_clear_type_cache(self):
Modified: python/branches/py3k/Lib/test/test_tarfile.py
==============================================================================
--- python/branches/py3k/Lib/test/test_tarfile.py (original)
+++ python/branches/py3k/Lib/test/test_tarfile.py Wed Jul 1 01:06:06 2009
@@ -57,7 +57,7 @@
tarinfo = self.tar.getmember("ustar/regtype")
fobj = self.tar.extractfile(tarinfo)
data = fobj.read()
- self.assert_((len(data), md5sum(data)) == (tarinfo.size, md5_regtype),
+ self.assertTrue((len(data), md5sum(data)) == (tarinfo.size, md5_regtype),
"regular file extraction failed")
def test_fileobj_readlines(self):
@@ -68,11 +68,11 @@
lines1 = fobj1.readlines()
lines2 = fobj2.readlines()
- self.assert_(lines1 == lines2,
+ self.assertTrue(lines1 == lines2,
"fileobj.readlines() failed")
- self.assert_(len(lines2) == 114,
+ self.assertTrue(len(lines2) == 114,
"fileobj.readlines() failed")
- self.assert_(lines2[83] == \
+ self.assertTrue(lines2[83] == \
"I will gladly admit that Python is not the fastest running scripting language.\n",
"fileobj.readlines() failed")
@@ -83,7 +83,7 @@
fobj2 = self.tar.extractfile(tarinfo)
lines1 = fobj1.readlines()
lines2 = list(io.TextIOWrapper(fobj2))
- self.assert_(lines1 == lines2,
+ self.assertTrue(lines1 == lines2,
"fileobj.__iter__() failed")
def test_fileobj_seek(self):
@@ -109,12 +109,12 @@
self.assertEqual(2048, fobj.tell(),
"seek() to positive relative position failed")
s = fobj.read(10)
- self.assert_(s == data[2048:2058],
+ self.assertTrue(s == data[2048:2058],
"read() after seek failed")
fobj.seek(0, 2)
self.assertEqual(tarinfo.size, fobj.tell(),
"seek() to file's end failed")
- self.assert_(fobj.read() == b"",
+ self.assertTrue(fobj.read() == b"",
"read() at file's end did not return empty string")
fobj.seek(-tarinfo.size, 2)
self.assertEqual(0, fobj.tell(),
@@ -123,13 +123,13 @@
s1 = fobj.readlines()
fobj.seek(512)
s2 = fobj.readlines()
- self.assert_(s1 == s2,
+ self.assertTrue(s1 == s2,
"readlines() after seek failed")
fobj.seek(0)
self.assertEqual(len(fobj.readline()), fobj.tell(),
"tell() after readline() failed")
fobj.seek(512)
- self.assert_(len(fobj.readline()) + 512 == fobj.tell(),
+ self.assertTrue(len(fobj.readline()) + 512 == fobj.tell(),
"tell() after seek() and readline() failed")
fobj.seek(0)
line = fobj.readline()
@@ -204,7 +204,7 @@
# Old V7 tars create directory members using an AREGTYPE
# header with a "/" appended to the filename field.
tarinfo = self.tar.getmember("misc/dirtype-old-v7")
- self.assert_(tarinfo.type == tarfile.DIRTYPE,
+ self.assertTrue(tarinfo.type == tarfile.DIRTYPE,
"v7 dirtype failed")
def test_xstar_type(self):
@@ -218,15 +218,15 @@
def test_check_members(self):
for tarinfo in self.tar:
- self.assert_(int(tarinfo.mtime) == 0o7606136617,
+ self.assertTrue(int(tarinfo.mtime) == 0o7606136617,
"wrong mtime for %s" % tarinfo.name)
if not tarinfo.name.startswith("ustar/"):
continue
- self.assert_(tarinfo.uname == "tarfile",
+ self.assertTrue(tarinfo.uname == "tarfile",
"wrong uname for %s" % tarinfo.name)
def test_find_members(self):
- self.assert_(self.tar.getmembers()[-1].name == "misc/eof",
+ self.assertTrue(self.tar.getmembers()[-1].name == "misc/eof",
"could not find all members")
def test_extract_hardlink(self):
@@ -275,7 +275,7 @@
tarinfo = self.tar.next() # get "regtype" (can't use getmember)
fobj = self.tar.extractfile(tarinfo)
data = fobj.read()
- self.assert_((len(data), md5sum(data)) == (tarinfo.size, md5_regtype),
+ self.assertTrue((len(data), md5sum(data)) == (tarinfo.size, md5_regtype),
"regular file extraction failed")
def test_provoke_stream_error(self):
@@ -292,7 +292,7 @@
t2 = tar2.next()
if t1 is None:
break
- self.assert_(t2 is not None, "stream.next() failed.")
+ self.assertTrue(t2 is not None, "stream.next() failed.")
if t2.islnk() or t2.issym():
self.assertRaises(tarfile.StreamError, tar2.extractfile, t2)
@@ -302,7 +302,7 @@
v2 = tar2.extractfile(t2)
if v1 is None:
continue
- self.assert_(v2 is not None, "stream.extractfile() failed")
+ self.assertTrue(v2 is not None, "stream.extractfile() failed")
self.assertEqual(v1.read(), v2.read(), "stream extraction failed")
tar1.close()
@@ -364,7 +364,7 @@
def _test_member(self, tarinfo, chksum=None, **kwargs):
if chksum is not None:
- self.assert_(md5sum(self.tar.extractfile(tarinfo).read()) == chksum,
+ self.assertTrue(md5sum(self.tar.extractfile(tarinfo).read()) == chksum,
"wrong md5sum for %s" % tarinfo.name)
kwargs["mtime"] = 0o7606136617
@@ -375,7 +375,7 @@
kwargs["uname"] = "tarfile"
kwargs["gname"] = "tarfile"
for k, v in kwargs.items():
- self.assert_(getattr(tarinfo, k) == v,
+ self.assertTrue(getattr(tarinfo, k) == v,
"wrong value in %s field of %s" % (k, tarinfo.name))
def test_find_regtype(self):
@@ -424,7 +424,7 @@
def test_find_ustar_longname(self):
name = "ustar/" + "12345/" * 39 + "1234567/longname"
- self.assert_(name in self.tar.getnames())
+ self.assertTrue(name in self.tar.getnames())
def test_find_regtype_oldv7(self):
tarinfo = self.tar.getmember("misc/regtype-old-v7")
@@ -445,7 +445,7 @@
tarinfo = self.tar.getmember(longname)
except KeyError:
self.fail("longname not found")
- self.assert_(tarinfo.type != tarfile.DIRTYPE, "read longname as dirtype")
+ self.assertTrue(tarinfo.type != tarfile.DIRTYPE, "read longname as dirtype")
def test_read_longlink(self):
longname = self.subdir + "/" + "123/" * 125 + "longname"
@@ -454,7 +454,7 @@
tarinfo = self.tar.getmember(longlink)
except KeyError:
self.fail("longlink not found")
- self.assert_(tarinfo.linkname == longname, "linkname wrong")
+ self.assertTrue(tarinfo.linkname == longname, "linkname wrong")
def test_truncated_longname(self):
longname = self.subdir + "/" + "123/" * 125 + "longname"
@@ -534,7 +534,7 @@
tar = tarfile.open(fileobj=fobj, mode=self.mode)
tar.addfile(tarfile.TarInfo("foo"))
tar.close()
- self.assert_(fobj.closed is False, "external fileobjs must never closed")
+ self.assertTrue(fobj.closed is False, "external fileobjs must never closed")
class WriteTest(WriteTestBase):
@@ -553,7 +553,7 @@
tar.close()
tar = tarfile.open(tmpname)
- self.assert_(tar.getnames()[0] == name,
+ self.assertTrue(tar.getnames()[0] == name,
"failed to store 100 char filename")
tar.close()
@@ -566,7 +566,7 @@
fobj.close()
tar.add(path)
tar.close()
- self.assert_(os.path.getsize(tmpname) > 0,
+ self.assertTrue(os.path.getsize(tmpname) > 0,
"tarfile is empty")
# The test_*_size tests test for bug #1167128.
@@ -627,16 +627,16 @@
dstname = os.path.abspath(tmpname)
tar = tarfile.open(tmpname, self.mode)
- self.assert_(tar.name == dstname, "archive name must be absolute")
+ self.assertTrue(tar.name == dstname, "archive name must be absolute")
tar.add(dstname)
- self.assert_(tar.getnames() == [], "added the archive to itself")
+ self.assertTrue(tar.getnames() == [], "added the archive to itself")
cwd = os.getcwd()
os.chdir(TEMPDIR)
tar.add(dstname)
os.chdir(cwd)
- self.assert_(tar.getnames() == [], "added the archive to itself")
+ self.assertTrue(tar.getnames() == [], "added the archive to itself")
def test_exclude(self):
tempdir = os.path.join(TEMPDIR, "exclude")
@@ -677,14 +677,14 @@
dec = bz2.BZ2Decompressor()
data = open(tmpname, "rb").read()
data = dec.decompress(data)
- self.assert_(len(dec.unused_data) == 0,
+ self.assertTrue(len(dec.unused_data) == 0,
"found trailing data")
else:
fobj = open(tmpname, "rb")
data = fobj.read()
fobj.close()
- self.assert_(data.count(b"\0") == tarfile.RECORDSIZE,
+ self.assertTrue(data.count(b"\0") == tarfile.RECORDSIZE,
"incorrect zero padding")
@@ -724,14 +724,14 @@
v1 = self._calc_size(name, link)
v2 = tar.offset
- self.assert_(v1 == v2, "GNU longname/longlink creation failed")
+ self.assertTrue(v1 == v2, "GNU longname/longlink creation failed")
tar.close()
tar = tarfile.open(tmpname)
member = tar.next()
- self.failIf(member is None, "unable to read longname member")
- self.assert_(tarinfo.name == member.name and \
+ self.assertFalse(member is None, "unable to read longname member")
+ self.assertTrue(tarinfo.name == member.name and \
tarinfo.linkname == member.linkname, \
"unable to read longname member")
@@ -791,18 +791,18 @@
# The same name will be added as a REGTYPE every
# time regardless of st_nlink.
tarinfo = self.tar.gettarinfo(self.foo)
- self.assert_(tarinfo.type == tarfile.REGTYPE,
+ self.assertTrue(tarinfo.type == tarfile.REGTYPE,
"add file as regular failed")
def test_add_hardlink(self):
tarinfo = self.tar.gettarinfo(self.bar)
- self.assert_(tarinfo.type == tarfile.LNKTYPE,
+ self.assertTrue(tarinfo.type == tarfile.LNKTYPE,
"add file as hardlink failed")
def test_dereference_hardlink(self):
self.tar.dereference = True
tarinfo = self.tar.gettarinfo(self.bar)
- self.assert_(tarinfo.type == tarfile.REGTYPE,
+ self.assertTrue(tarinfo.type == tarfile.REGTYPE,
"dereferencing hardlink failed")
@@ -822,10 +822,10 @@
tar = tarfile.open(tmpname)
if link:
l = tar.getmembers()[0].linkname
- self.assert_(link == l, "PAX longlink creation failed")
+ self.assertTrue(link == l, "PAX longlink creation failed")
else:
n = tar.getmembers()[0].name
- self.assert_(name == n, "PAX longname creation failed")
+ self.assertTrue(name == n, "PAX longname creation failed")
def test_pax_global_header(self):
pax_headers = {
@@ -847,8 +847,8 @@
# Test if all the fields are strings.
for key, val in tar.pax_headers.items():
- self.assert_(type(key) is not bytes)
- self.assert_(type(val) is not bytes)
+ self.assertTrue(type(key) is not bytes)
+ self.assertTrue(type(val) is not bytes)
if key in tarfile.PAX_NUMBER_FIELDS:
try:
tarfile.PAX_NUMBER_FIELDS[key](val)
@@ -916,10 +916,10 @@
def test_unicode_argument(self):
tar = tarfile.open(tarname, "r", encoding="iso8859-1", errors="strict")
for t in tar:
- self.assert_(type(t.name) is str)
- self.assert_(type(t.linkname) is str)
- self.assert_(type(t.uname) is str)
- self.assert_(type(t.gname) is str)
+ self.assertTrue(type(t.name) is str)
+ self.assertTrue(type(t.linkname) is str)
+ self.assertTrue(type(t.uname) is str)
+ self.assertTrue(type(t.gname) is str)
tar.close()
def test_uname_unicode(self):
Modified: python/branches/py3k/Lib/test/test_tempfile.py
==============================================================================
--- python/branches/py3k/Lib/test/test_tempfile.py (original)
+++ python/branches/py3k/Lib/test/test_tempfile.py Wed Jul 1 01:06:06 2009
@@ -59,7 +59,7 @@
"file '%s' does not end with '%s'" % (nbase, suf))
nbase = nbase[len(pre):len(nbase)-len(suf)]
- self.assert_(self.str_check.match(nbase),
+ self.assertTrue(self.str_check.match(nbase),
"random string '%s' does not match /^[a-zA-Z0-9_-]{6}$/"
% nbase)
@@ -88,7 +88,7 @@
for key in dict:
if key[0] != '_' and key not in expected:
unexp.append(key)
- self.failUnless(len(unexp) == 0,
+ self.assertTrue(len(unexp) == 0,
"unexpected keys: %s" % unexp)
test_classes.append(test_exports)
@@ -113,7 +113,7 @@
for i in range(TEST_FILES):
s = next(r)
self.nameCheck(s, '', '', '')
- self.failIf(s in dict)
+ self.assertFalse(s in dict)
dict[s] = 1
def supports_iter(self):
@@ -140,9 +140,9 @@
cand = tempfile._candidate_tempdir_list()
- self.failIf(len(cand) == 0)
+ self.assertFalse(len(cand) == 0)
for c in cand:
- self.assert_(isinstance(c, str),
+ self.assertTrue(isinstance(c, str),
"%s is not a string" % c)
def test_wanted_dirs(self):
@@ -160,14 +160,14 @@
for envname in 'TMPDIR', 'TEMP', 'TMP':
dirname = os.getenv(envname)
if not dirname: raise ValueError
- self.assert_(dirname in cand)
+ self.assertTrue(dirname in cand)
try:
dirname = os.getcwd()
except (AttributeError, os.error):
dirname = os.curdir
- self.assert_(dirname in cand)
+ self.assertTrue(dirname in cand)
# Not practical to try to verify the presence of OS-specific
# paths in this list.
@@ -184,14 +184,14 @@
def test_retval(self):
# _get_candidate_names returns a _RandomNameSequence object
obj = tempfile._get_candidate_names()
- self.assert_(isinstance(obj, tempfile._RandomNameSequence))
+ self.assertTrue(isinstance(obj, tempfile._RandomNameSequence))
def test_same_thing(self):
# _get_candidate_names always returns the same object
a = tempfile._get_candidate_names()
b = tempfile._get_candidate_names()
- self.assert_(a is b)
+ self.assertTrue(a is b)
test_classes.append(test__get_candidate_names)
@@ -300,9 +300,9 @@
decorated = sys.executable
retval = os.spawnl(os.P_WAIT, sys.executable, decorated, tester, v, fd)
- self.failIf(retval < 0,
+ self.assertFalse(retval < 0,
"child process caught fatal signal %d" % -retval)
- self.failIf(retval > 0, "child process reports failure %d"%retval)
+ self.assertFalse(retval > 0, "child process reports failure %d"%retval)
def test_textmode(self):
# _mkstemp_inner can create files in text mode
@@ -322,8 +322,8 @@
# gettempprefix returns a nonempty prefix string
p = tempfile.gettempprefix()
- self.assert_(isinstance(p, str))
- self.assert_(len(p) > 0)
+ self.assertTrue(isinstance(p, str))
+ self.assertTrue(len(p) > 0)
def test_usable_template(self):
# gettempprefix returns a usable prefix string
@@ -354,9 +354,9 @@
# gettempdir returns a directory which exists
dir = tempfile.gettempdir()
- self.assert_(os.path.isabs(dir) or dir == os.curdir,
+ self.assertTrue(os.path.isabs(dir) or dir == os.curdir,
"%s is not an absolute path" % dir)
- self.assert_(os.path.isdir(dir),
+ self.assertTrue(os.path.isdir(dir),
"%s is not a directory" % dir)
def test_directory_writable(self):
@@ -377,7 +377,7 @@
a = tempfile.gettempdir()
b = tempfile.gettempdir()
- self.assert_(a is b)
+ self.assertTrue(a is b)
test_classes.append(test_gettempdir)
@@ -580,7 +580,7 @@
def test_creates_named(self):
# NamedTemporaryFile creates files with names
f = tempfile.NamedTemporaryFile()
- self.failUnless(os.path.exists(f.name),
+ self.assertTrue(os.path.exists(f.name),
"NamedTemporaryFile %s does not exist" % f.name)
def test_del_on_close(self):
@@ -590,7 +590,7 @@
f = tempfile.NamedTemporaryFile(dir=dir)
f.write(b'blat')
f.close()
- self.failIf(os.path.exists(f.name),
+ self.assertFalse(os.path.exists(f.name),
"NamedTemporaryFile %s exists after close" % f.name)
finally:
os.rmdir(dir)
@@ -604,7 +604,7 @@
tmp = f.name
f.write(b'blat')
f.close()
- self.failUnless(os.path.exists(f.name),
+ self.assertTrue(os.path.exists(f.name),
"NamedTemporaryFile %s missing after close" % f.name)
finally:
if tmp is not None:
@@ -625,12 +625,12 @@
def test_context_manager(self):
# A NamedTemporaryFile can be used as a context manager
with tempfile.NamedTemporaryFile() as f:
- self.failUnless(os.path.exists(f.name))
- self.failIf(os.path.exists(f.name))
+ self.assertTrue(os.path.exists(f.name))
+ self.assertFalse(os.path.exists(f.name))
def use_closed():
with f:
pass
- self.failUnlessRaises(ValueError, use_closed)
+ self.assertRaises(ValueError, use_closed)
# How to test the mode and bufsize parameters?
@@ -653,21 +653,21 @@
def test_basic(self):
# SpooledTemporaryFile can create files
f = self.do_create()
- self.failIf(f._rolled)
+ self.assertFalse(f._rolled)
f = self.do_create(max_size=100, pre="a", suf=".txt")
- self.failIf(f._rolled)
+ self.assertFalse(f._rolled)
def test_del_on_close(self):
# A SpooledTemporaryFile is deleted when closed
dir = tempfile.mkdtemp()
try:
f = tempfile.SpooledTemporaryFile(max_size=10, dir=dir)
- self.failIf(f._rolled)
+ self.assertFalse(f._rolled)
f.write(b'blat ' * 5)
- self.failUnless(f._rolled)
+ self.assertTrue(f._rolled)
filename = f.name
f.close()
- self.failIf(isinstance(filename, str) and os.path.exists(filename),
+ self.assertFalse(isinstance(filename, str) and os.path.exists(filename),
"SpooledTemporaryFile %s exists after close" % filename)
finally:
os.rmdir(dir)
@@ -675,46 +675,46 @@
def test_rewrite_small(self):
# A SpooledTemporaryFile can be written to multiple within the max_size
f = self.do_create(max_size=30)
- self.failIf(f._rolled)
+ self.assertFalse(f._rolled)
for i in range(5):
f.seek(0, 0)
f.write(b'x' * 20)
- self.failIf(f._rolled)
+ self.assertFalse(f._rolled)
def test_write_sequential(self):
# A SpooledTemporaryFile should hold exactly max_size bytes, and roll
# over afterward
f = self.do_create(max_size=30)
- self.failIf(f._rolled)
+ self.assertFalse(f._rolled)
f.write(b'x' * 20)
- self.failIf(f._rolled)
+ self.assertFalse(f._rolled)
f.write(b'x' * 10)
- self.failIf(f._rolled)
+ self.assertFalse(f._rolled)
f.write(b'x')
- self.failUnless(f._rolled)
+ self.assertTrue(f._rolled)
def test_sparse(self):
# A SpooledTemporaryFile that is written late in the file will extend
# when that occurs
f = self.do_create(max_size=30)
- self.failIf(f._rolled)
+ self.assertFalse(f._rolled)
f.seek(100, 0)
- self.failIf(f._rolled)
+ self.assertFalse(f._rolled)
f.write(b'x')
- self.failUnless(f._rolled)
+ self.assertTrue(f._rolled)
def test_fileno(self):
# A SpooledTemporaryFile should roll over to a real file on fileno()
f = self.do_create(max_size=30)
- self.failIf(f._rolled)
- self.failUnless(f.fileno() > 0)
- self.failUnless(f._rolled)
+ self.assertFalse(f._rolled)
+ self.assertTrue(f.fileno() > 0)
+ self.assertTrue(f._rolled)
def test_multiple_close_before_rollover(self):
# A SpooledTemporaryFile can be closed many times without error
f = tempfile.SpooledTemporaryFile()
f.write(b'abc\n')
- self.failIf(f._rolled)
+ self.assertFalse(f._rolled)
f.close()
try:
f.close()
@@ -726,7 +726,7 @@
# A SpooledTemporaryFile can be closed many times without error
f = tempfile.SpooledTemporaryFile(max_size=1)
f.write(b'abc\n')
- self.failUnless(f._rolled)
+ self.assertTrue(f._rolled)
f.close()
try:
f.close()
@@ -768,51 +768,51 @@
f.write("\u039B\r\n")
f.seek(0)
self.assertEqual(f.read(), "\u039B\r\n")
- self.failIf(f._rolled)
+ self.assertFalse(f._rolled)
f.write("\u039B" * 20 + "\r\n")
f.seek(0)
self.assertEqual(f.read(), "\u039B\r\n" + ("\u039B" * 20) + "\r\n")
- self.failUnless(f._rolled)
+ self.assertTrue(f._rolled)
def test_context_manager_before_rollover(self):
# A SpooledTemporaryFile can be used as a context manager
with tempfile.SpooledTemporaryFile(max_size=1) as f:
- self.failIf(f._rolled)
- self.failIf(f.closed)
- self.failUnless(f.closed)
+ self.assertFalse(f._rolled)
+ self.assertFalse(f.closed)
+ self.assertTrue(f.closed)
def use_closed():
with f:
pass
- self.failUnlessRaises(ValueError, use_closed)
+ self.assertRaises(ValueError, use_closed)
def test_context_manager_during_rollover(self):
# A SpooledTemporaryFile can be used as a context manager
with tempfile.SpooledTemporaryFile(max_size=1) as f:
- self.failIf(f._rolled)
+ self.assertFalse(f._rolled)
f.write(b'abc\n')
f.flush()
- self.failUnless(f._rolled)
- self.failIf(f.closed)
- self.failUnless(f.closed)
+ self.assertTrue(f._rolled)
+ self.assertFalse(f.closed)
+ self.assertTrue(f.closed)
def use_closed():
with f:
pass
- self.failUnlessRaises(ValueError, use_closed)
+ self.assertRaises(ValueError, use_closed)
def test_context_manager_after_rollover(self):
# A SpooledTemporaryFile can be used as a context manager
f = tempfile.SpooledTemporaryFile(max_size=1)
f.write(b'abc\n')
f.flush()
- self.failUnless(f._rolled)
+ self.assertTrue(f._rolled)
with f:
- self.failIf(f.closed)
- self.failUnless(f.closed)
+ self.assertFalse(f.closed)
+ self.assertTrue(f.closed)
def use_closed():
with f:
pass
- self.failUnlessRaises(ValueError, use_closed)
+ self.assertRaises(ValueError, use_closed)
test_classes.append(test_SpooledTemporaryFile)
Modified: python/branches/py3k/Lib/test/test_threading.py
==============================================================================
--- python/branches/py3k/Lib/test/test_threading.py (original)
+++ python/branches/py3k/Lib/test/test_threading.py Wed Jul 1 01:06:06 2009
@@ -41,7 +41,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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
Modified: python/branches/py3k/Lib/test/test_threading_local.py
==============================================================================
--- python/branches/py3k/Lib/test/test_threading_local.py (original)
+++ python/branches/py3k/Lib/test/test_threading_local.py Wed Jul 1 01:06:06 2009
@@ -40,7 +40,7 @@
local.someothervar = None
gc.collect()
deadlist = [weak for weak in weaklist if weak() is None]
- self.assert_(len(deadlist) in (n-1, n), (n, len(deadlist)))
+ self.assertTrue(len(deadlist) in (n-1, n), (n, len(deadlist)))
def test_derived(self):
# Issue 3088: if there is a threads switch inside the __init__
Modified: python/branches/py3k/Lib/test/test_time.py
==============================================================================
--- python/branches/py3k/Lib/test/test_time.py (original)
+++ python/branches/py3k/Lib/test/test_time.py Wed Jul 1 01:06:06 2009
@@ -18,9 +18,9 @@
time.clock()
def test_conversions(self):
- self.assert_(time.ctime(self.t)
+ self.assertTrue(time.ctime(self.t)
== time.asctime(time.localtime(self.t)))
- self.assert_(int(time.mktime(time.localtime(self.t)))
+ self.assertTrue(int(time.mktime(time.localtime(self.t)))
== int(self.t))
def test_sleep(self):
@@ -153,36 +153,36 @@
time.tzset()
environ['TZ'] = utc
time.tzset()
- self.failUnlessEqual(
+ self.assertEqual(
time.gmtime(xmas2002), time.localtime(xmas2002)
)
- self.failUnlessEqual(time.daylight, 0)
- self.failUnlessEqual(time.timezone, 0)
- self.failUnlessEqual(time.localtime(xmas2002).tm_isdst, 0)
+ self.assertEqual(time.daylight, 0)
+ self.assertEqual(time.timezone, 0)
+ self.assertEqual(time.localtime(xmas2002).tm_isdst, 0)
# Make sure we can switch to US/Eastern
environ['TZ'] = eastern
time.tzset()
- self.failIfEqual(time.gmtime(xmas2002), time.localtime(xmas2002))
- self.failUnlessEqual(time.tzname, ('EST', 'EDT'))
- self.failUnlessEqual(len(time.tzname), 2)
- self.failUnlessEqual(time.daylight, 1)
- self.failUnlessEqual(time.timezone, 18000)
- self.failUnlessEqual(time.altzone, 14400)
- self.failUnlessEqual(time.localtime(xmas2002).tm_isdst, 0)
- self.failUnlessEqual(len(time.tzname), 2)
+ self.assertNotEqual(time.gmtime(xmas2002), time.localtime(xmas2002))
+ self.assertEqual(time.tzname, ('EST', 'EDT'))
+ self.assertEqual(len(time.tzname), 2)
+ self.assertEqual(time.daylight, 1)
+ self.assertEqual(time.timezone, 18000)
+ self.assertEqual(time.altzone, 14400)
+ self.assertEqual(time.localtime(xmas2002).tm_isdst, 0)
+ self.assertEqual(len(time.tzname), 2)
# Now go to the southern hemisphere.
environ['TZ'] = victoria
time.tzset()
- self.failIfEqual(time.gmtime(xmas2002), time.localtime(xmas2002))
- self.failUnless(time.tzname[0] == 'AEST', str(time.tzname[0]))
- self.failUnless(time.tzname[1] == 'AEDT', str(time.tzname[1]))
- self.failUnlessEqual(len(time.tzname), 2)
- self.failUnlessEqual(time.daylight, 1)
- self.failUnlessEqual(time.timezone, -36000)
- self.failUnlessEqual(time.altzone, -39600)
- self.failUnlessEqual(time.localtime(xmas2002).tm_isdst, 1)
+ self.assertNotEqual(time.gmtime(xmas2002), time.localtime(xmas2002))
+ self.assertTrue(time.tzname[0] == 'AEST', str(time.tzname[0]))
+ self.assertTrue(time.tzname[1] == 'AEDT', str(time.tzname[1]))
+ self.assertEqual(len(time.tzname), 2)
+ self.assertEqual(time.daylight, 1)
+ self.assertEqual(time.timezone, -36000)
+ self.assertEqual(time.altzone, -39600)
+ self.assertEqual(time.localtime(xmas2002).tm_isdst, 1)
finally:
# Repair TZ environment variable in case any other tests
@@ -214,14 +214,14 @@
gt1 = time.gmtime(None)
t0 = time.mktime(gt0)
t1 = time.mktime(gt1)
- self.assert_(0 <= (t1-t0) < 0.2)
+ self.assertTrue(0 <= (t1-t0) < 0.2)
def test_localtime_without_arg(self):
lt0 = time.localtime()
lt1 = time.localtime(None)
t0 = time.mktime(lt0)
t1 = time.mktime(lt1)
- self.assert_(0 <= (t1-t0) < 0.2)
+ self.assertTrue(0 <= (t1-t0) < 0.2)
class TestLocale(unittest.TestCase):
def setUp(self):
Modified: python/branches/py3k/Lib/test/test_timeout.py
==============================================================================
--- python/branches/py3k/Lib/test/test_timeout.py (original)
+++ python/branches/py3k/Lib/test/test_timeout.py Wed Jul 1 01:06:06 2009
@@ -119,11 +119,11 @@
self.sock.settimeout(_timeout)
_t1 = time.time()
- self.failUnlessRaises(socket.error, self.sock.connect, addr)
+ self.assertRaises(socket.error, self.sock.connect, addr)
_t2 = time.time()
_delta = abs(_t1 - _t2)
- self.assert_(_delta < _timeout + self.fuzz,
+ self.assertTrue(_delta < _timeout + self.fuzz,
"timeout (%g) is more than %g seconds more than expected (%g)"
%(_delta, self.fuzz, _timeout))
@@ -134,11 +134,11 @@
self.sock.settimeout(_timeout)
_t1 = time.time()
- self.failUnlessRaises(socket.error, self.sock.recv, 1024)
+ self.assertRaises(socket.error, self.sock.recv, 1024)
_t2 = time.time()
_delta = abs(_t1 - _t2)
- self.assert_(_delta < _timeout + self.fuzz,
+ self.assertTrue(_delta < _timeout + self.fuzz,
"timeout (%g) is %g seconds more than expected (%g)"
%(_delta, self.fuzz, _timeout))
@@ -150,11 +150,11 @@
self.sock.listen(5)
_t1 = time.time()
- self.failUnlessRaises(socket.error, self.sock.accept)
+ self.assertRaises(socket.error, self.sock.accept)
_t2 = time.time()
_delta = abs(_t1 - _t2)
- self.assert_(_delta < _timeout + self.fuzz,
+ self.assertTrue(_delta < _timeout + self.fuzz,
"timeout (%g) is %g seconds more than expected (%g)"
%(_delta, self.fuzz, _timeout))
@@ -166,11 +166,11 @@
self.sock.bind(self.addr_local)
_t1 = time.time()
- self.failUnlessRaises(socket.error, self.sock.recvfrom, 8192)
+ self.assertRaises(socket.error, self.sock.recvfrom, 8192)
_t2 = time.time()
_delta = abs(_t1 - _t2)
- self.assert_(_delta < _timeout + self.fuzz,
+ self.assertTrue(_delta < _timeout + self.fuzz,
"timeout (%g) is %g seconds more than expected (%g)"
%(_delta, self.fuzz, _timeout))
Modified: python/branches/py3k/Lib/test/test_tokenize.py
==============================================================================
--- python/branches/py3k/Lib/test/test_tokenize.py (original)
+++ python/branches/py3k/Lib/test/test_tokenize.py Wed Jul 1 01:06:06 2009
@@ -629,7 +629,7 @@
behaviour of the interpreter when it encounters a similar condition.
"""
f = 'tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt'
- self.failUnlessRaises(SyntaxError, self._testFile, f)
+ self.assertRaises(SyntaxError, self._testFile, f)
def test_no_coding_cookie_and_utf8_bom(self):
f = 'tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt'
Modified: python/branches/py3k/Lib/test/test_traceback.py
==============================================================================
--- python/branches/py3k/Lib/test/test_traceback.py (original)
+++ python/branches/py3k/Lib/test/test_traceback.py Wed Jul 1 01:06:06 2009
@@ -40,15 +40,15 @@
err = self.get_exception_format(self.syntax_error_with_caret,
SyntaxError)
self.assertEqual(len(err), 4)
- self.assert_(err[1].strip() == "return x!")
- self.assert_("^" in err[2]) # third line has caret
+ self.assertTrue(err[1].strip() == "return x!")
+ self.assertTrue("^" in err[2]) # third line has caret
self.assertEqual(err[1].find("!"), err[2].find("^")) # in the right place
err = self.get_exception_format(self.syntax_error_with_caret_2,
SyntaxError)
- self.assert_("^" in err[2]) # third line has caret
- self.assert_(err[2].count('\n') == 1) # and no additional newline
- self.assert_(err[1].find("+") == err[2].find("^")) # in the right place
+ self.assertTrue("^" in err[2]) # third line has caret
+ self.assertTrue(err[2].count('\n') == 1) # and no additional newline
+ self.assertTrue(err[1].find("+") == err[2].find("^")) # in the right place
def test_nocaret(self):
if is_jython:
@@ -57,14 +57,14 @@
err = self.get_exception_format(self.syntax_error_without_caret,
SyntaxError)
self.assertEqual(len(err), 3)
- self.assert_(err[1].strip() == "[x for x in x] = x")
+ self.assertTrue(err[1].strip() == "[x for x in x] = x")
def test_bad_indentation(self):
err = self.get_exception_format(self.syntax_error_bad_indentation,
IndentationError)
self.assertEqual(len(err), 4)
self.assertEqual(err[1].strip(), "print(2)")
- self.assert_("^" in err[2])
+ self.assertTrue("^" in err[2])
self.assertEqual(err[1].find(")"), err[2].find("^"))
def test_base_exception(self):
@@ -131,13 +131,13 @@
err_line = "raise RuntimeError('{0}')".format(message_ascii)
err_msg = "RuntimeError: {0}".format(message_ascii)
- self.assert_(("line %s" % lineno) in stdout[1],
+ self.assertTrue(("line %s" % lineno) in stdout[1],
"Invalid line number: {0!r} instead of {1}".format(
stdout[1], lineno))
- self.assert_(stdout[2].endswith(err_line),
+ self.assertTrue(stdout[2].endswith(err_line),
"Invalid traceback line: {0!r} instead of {1!r}".format(
stdout[2], err_line))
- self.assert_(stdout[3] == err_msg,
+ self.assertTrue(stdout[3] == err_msg,
"Invalid error message: {0!r} instead of {1!r}".format(
stdout[3], err_msg))
@@ -177,9 +177,9 @@
tb_lines = python_fmt.splitlines()
self.assertEquals(len(tb_lines), 3)
banner, location, source_line = tb_lines
- self.assert_(banner.startswith('Traceback'))
- self.assert_(location.startswith(' File'))
- self.assert_(source_line.startswith(' raise'))
+ self.assertTrue(banner.startswith('Traceback'))
+ self.assertTrue(location.startswith(' File'))
+ self.assertTrue(source_line.startswith(' raise'))
cause_message = (
@@ -209,9 +209,9 @@
def check_zero_div(self, msg):
lines = msg.splitlines()
- self.assert_(lines[-3].startswith(' File'))
- self.assert_('1/0 # In zero_div' in lines[-2], lines[-2])
- self.assert_(lines[-1].startswith('ZeroDivisionError'), lines[-1])
+ self.assertTrue(lines[-3].startswith(' File'))
+ self.assertTrue('1/0 # In zero_div' in lines[-2], lines[-2])
+ self.assertTrue(lines[-1].startswith('ZeroDivisionError'), lines[-1])
def test_simple(self):
try:
@@ -220,10 +220,10 @@
e = _
lines = self.get_report(e).splitlines()
self.assertEquals(len(lines), 4)
- self.assert_(lines[0].startswith('Traceback'))
- self.assert_(lines[1].startswith(' File'))
- self.assert_('1/0 # Marker' in lines[2])
- self.assert_(lines[3].startswith('ZeroDivisionError'))
+ self.assertTrue(lines[0].startswith('Traceback'))
+ self.assertTrue(lines[1].startswith(' File'))
+ self.assertTrue('1/0 # Marker' in lines[2])
+ self.assertTrue(lines[3].startswith('ZeroDivisionError'))
def test_cause(self):
def inner_raise():
@@ -237,7 +237,7 @@
self.assertEquals(len(blocks), 3)
self.assertEquals(blocks[1], cause_message)
self.check_zero_div(blocks[0])
- self.assert_('inner_raise() # Marker' in blocks[2])
+ self.assertTrue('inner_raise() # Marker' in blocks[2])
def test_context(self):
def inner_raise():
@@ -251,7 +251,7 @@
self.assertEquals(len(blocks), 3)
self.assertEquals(blocks[1], context_message)
self.check_zero_div(blocks[0])
- self.assert_('inner_raise() # Marker' in blocks[2])
+ self.assertTrue('inner_raise() # Marker' in blocks[2])
def test_cause_recursive(self):
def inner_raise():
@@ -269,11 +269,11 @@
self.assertEquals(len(blocks), 3)
self.assertEquals(blocks[1], cause_message)
# The first block is the KeyError raised from the ZeroDivisionError
- self.assert_('raise KeyError from e' in blocks[0])
- self.assert_('1/0' not in blocks[0])
+ self.assertTrue('raise KeyError from e' in blocks[0])
+ self.assertTrue('1/0' not in blocks[0])
# The second block (apart from the boundary) is the ZeroDivisionError
# re-raised from the KeyError
- self.assert_('inner_raise() # Marker' in blocks[2])
+ self.assertTrue('inner_raise() # Marker' in blocks[2])
self.check_zero_div(blocks[2])
Modified: python/branches/py3k/Lib/test/test_tuple.py
==============================================================================
--- python/branches/py3k/Lib/test/test_tuple.py (original)
+++ python/branches/py3k/Lib/test/test_tuple.py Wed Jul 1 01:06:06 2009
@@ -11,7 +11,7 @@
self.assertEqual(tuple(), ())
t0_3 = (0, 1, 2, 3)
t0_3_bis = tuple(t0_3)
- self.assert_(t0_3 is t0_3_bis)
+ self.assertTrue(t0_3 is t0_3_bis)
self.assertEqual(tuple([]), ())
self.assertEqual(tuple([0, 1, 2, 3]), (0, 1, 2, 3))
self.assertEqual(tuple(''), ())
@@ -19,8 +19,8 @@
def test_truth(self):
super().test_truth()
- self.assert_(not ())
- self.assert_((42, ))
+ self.assertTrue(not ())
+ self.assertTrue((42, ))
def test_len(self):
super().test_len()
@@ -33,14 +33,14 @@
u = (0, 1)
u2 = u
u += (2, 3)
- self.assert_(u is not u2)
+ self.assertTrue(u is not u2)
def test_imul(self):
super().test_imul()
u = (0, 1)
u2 = u
u *= 3
- self.assert_(u is not u2)
+ self.assertTrue(u is not u2)
def test_tupleresizebug(self):
# Check that a specific bug in _PyTuple_Resize() is squashed.
@@ -71,7 +71,7 @@
inps = base + [(i, j) for i in base for j in xp] + \
[(i, j) for i in xp for j in base] + xp + list(zip(base))
collisions = len(inps) - len(set(map(hash, inps)))
- self.assert_(collisions <= 15)
+ self.assertTrue(collisions <= 15)
def test_repr(self):
l0 = tuple()
Modified: python/branches/py3k/Lib/test/test_types.py
==============================================================================
--- python/branches/py3k/Lib/test/test_types.py (original)
+++ python/branches/py3k/Lib/test/test_types.py Wed Jul 1 01:06:06 2009
@@ -549,13 +549,13 @@
result = f.__format__(fmt)
self.assertEqual(len(result), 98)
self.assertEqual(result[-7], '.')
- self.assert_(result[:12] in ('112340000000', '112339999999'))
+ self.assertTrue(result[:12] in ('112340000000', '112339999999'))
f = 1.1234e200
for fmt in 'f', 'F':
result = f.__format__(fmt)
self.assertEqual(len(result), 208)
self.assertEqual(result[-7], '.')
- self.assert_(result[:12] in ('112340000000', '112339999999'))
+ self.assertTrue(result[:12] in ('112340000000', '112339999999'))
test( 1.0, 'e', '1.000000e+00')
Modified: python/branches/py3k/Lib/test/test_unary.py
==============================================================================
--- python/branches/py3k/Lib/test/test_unary.py (original)
+++ python/branches/py3k/Lib/test/test_unary.py Wed Jul 1 01:06:06 2009
@@ -6,12 +6,12 @@
class UnaryOpTestCase(unittest.TestCase):
def test_negative(self):
- self.assert_(-2 == 0 - 2)
+ self.assertTrue(-2 == 0 - 2)
self.assertEqual(-0, 0)
self.assertEqual(--2, 2)
- self.assert_(-2 == 0 - 2)
- self.assert_(-2.0 == 0 - 2.0)
- self.assert_(-2j == 0 - 2j)
+ self.assertTrue(-2 == 0 - 2)
+ self.assertTrue(-2.0 == 0 - 2.0)
+ self.assertTrue(-2j == 0 - 2j)
def test_positive(self):
self.assertEqual(+2, 2)
@@ -22,16 +22,16 @@
self.assertEqual(+2j, 2j)
def test_invert(self):
- self.assert_(-2 == 0 - 2)
+ self.assertTrue(-2 == 0 - 2)
self.assertEqual(-0, 0)
self.assertEqual(--2, 2)
- self.assert_(-2 == 0 - 2)
+ self.assertTrue(-2 == 0 - 2)
def test_no_overflow(self):
nines = "9" * 32
- self.assert_(eval("+" + nines) == 10**32-1)
- self.assert_(eval("-" + nines) == -(10**32-1))
- self.assert_(eval("~" + nines) == ~(10**32-1))
+ self.assertTrue(eval("+" + nines) == 10**32-1)
+ self.assertTrue(eval("-" + nines) == -(10**32-1))
+ self.assertTrue(eval("~" + nines) == ~(10**32-1))
def test_negation_of_exponentiation(self):
# Make sure '**' does the right thing; these form a
Modified: python/branches/py3k/Lib/test/test_unicode.py
==============================================================================
--- python/branches/py3k/Lib/test/test_unicode.py (original)
+++ python/branches/py3k/Lib/test/test_unicode.py Wed Jul 1 01:06:06 2009
@@ -48,7 +48,7 @@
method = getattr(object, methodname)
realresult = method(*args)
self.assertEqual(realresult, result)
- self.assert_(type(realresult) is type(result))
+ self.assertTrue(type(realresult) is type(result))
# if the original is returned make sure that
# this doesn't happen with subclasses
@@ -60,7 +60,7 @@
method = getattr(object, methodname)
realresult = method(*args)
self.assertEqual(realresult, result)
- self.assert_(object is not realresult)
+ self.assertTrue(object is not realresult)
def test_literals(self):
self.assertEqual('\xff', '\u00ff')
@@ -294,25 +294,25 @@
self.assertEqual('abc', 'abc')
self.assertEqual('abc', 'abc')
self.assertEqual('abc', 'abc')
- self.assert_('abcd' > 'abc')
- self.assert_('abcd' > 'abc')
- self.assert_('abcd' > 'abc')
- self.assert_('abc' < 'abcd')
- self.assert_('abc' < 'abcd')
- self.assert_('abc' < 'abcd')
+ self.assertTrue('abcd' > 'abc')
+ self.assertTrue('abcd' > 'abc')
+ self.assertTrue('abcd' > 'abc')
+ self.assertTrue('abc' < 'abcd')
+ self.assertTrue('abc' < 'abcd')
+ self.assertTrue('abc' < 'abcd')
if 0:
# Move these tests to a Unicode collation module test...
# Testing UTF-16 code point order comparisons...
# No surrogates, no fixup required.
- self.assert_('\u0061' < '\u20ac')
+ self.assertTrue('\u0061' < '\u20ac')
# Non surrogate below surrogate value, no fixup required
- self.assert_('\u0061' < '\ud800\udc02')
+ self.assertTrue('\u0061' < '\ud800\udc02')
# Non surrogate above surrogate value, fixup required
def test_lecmp(s, s2):
- self.assert_(s < s2)
+ self.assertTrue(s < s2)
def test_fixup(s):
s2 = '\ud800\udc01'
@@ -352,7 +352,7 @@
test_fixup('\uff61')
# Surrogates on both sides, no fixup required
- self.assert_('\ud800\udc02' < '\ud84d\udc56')
+ self.assertTrue('\ud800\udc02' < '\ud84d\udc56')
def test_islower(self):
string_tests.MixinStrUnicodeUserStringTest.test_islower(self)
@@ -436,32 +436,32 @@
def test_contains(self):
# Testing Unicode contains method
- self.assert_('a' in 'abdb')
- self.assert_('a' in 'bdab')
- self.assert_('a' in 'bdaba')
- self.assert_('a' in 'bdba')
- self.assert_('a' not in 'bdb')
- self.assert_('a' in 'bdba')
- self.assert_('a' in ('a',1,None))
- self.assert_('a' in (1,None,'a'))
- self.assert_('a' in ('a',1,None))
- self.assert_('a' in (1,None,'a'))
- self.assert_('a' not in ('x',1,'y'))
- self.assert_('a' not in ('x',1,None))
- self.assert_('abcd' not in 'abcxxxx')
- self.assert_('ab' in 'abcd')
- self.assert_('ab' in 'abc')
- self.assert_('ab' in (1,None,'ab'))
- self.assert_('' in 'abc')
- self.assert_('' in '')
- self.assert_('' in 'abc')
- self.assert_('\0' not in 'abc')
- self.assert_('\0' in '\0abc')
- self.assert_('\0' in 'abc\0')
- self.assert_('a' in '\0abc')
- self.assert_('asdf' in 'asdf')
- self.assert_('asdf' not in 'asd')
- self.assert_('asdf' not in '')
+ self.assertTrue('a' in 'abdb')
+ self.assertTrue('a' in 'bdab')
+ self.assertTrue('a' in 'bdaba')
+ self.assertTrue('a' in 'bdba')
+ self.assertTrue('a' not in 'bdb')
+ self.assertTrue('a' in 'bdba')
+ self.assertTrue('a' in ('a',1,None))
+ self.assertTrue('a' in (1,None,'a'))
+ self.assertTrue('a' in ('a',1,None))
+ self.assertTrue('a' in (1,None,'a'))
+ self.assertTrue('a' not in ('x',1,'y'))
+ self.assertTrue('a' not in ('x',1,None))
+ self.assertTrue('abcd' not in 'abcxxxx')
+ self.assertTrue('ab' in 'abcd')
+ self.assertTrue('ab' in 'abc')
+ self.assertTrue('ab' in (1,None,'ab'))
+ self.assertTrue('' in 'abc')
+ self.assertTrue('' in '')
+ self.assertTrue('' in 'abc')
+ self.assertTrue('\0' not in 'abc')
+ self.assertTrue('\0' in '\0abc')
+ self.assertTrue('\0' in 'abc\0')
+ self.assertTrue('a' in '\0abc')
+ self.assertTrue('asdf' in 'asdf')
+ self.assertTrue('asdf' not in 'asd')
+ self.assertTrue('asdf' not in '')
self.assertRaises(TypeError, "abc".__contains__)
Modified: python/branches/py3k/Lib/test/test_unicode_file.py
==============================================================================
--- python/branches/py3k/Lib/test/test_unicode_file.py (original)
+++ python/branches/py3k/Lib/test/test_unicode_file.py Wed Jul 1 01:06:06 2009
@@ -25,19 +25,19 @@
# Do all the tests we can given only a single filename. The file should
# exist.
def _do_single(self, filename):
- self.failUnless(os.path.exists(filename))
- self.failUnless(os.path.isfile(filename))
- self.failUnless(os.access(filename, os.R_OK))
- self.failUnless(os.path.exists(os.path.abspath(filename)))
- self.failUnless(os.path.isfile(os.path.abspath(filename)))
- self.failUnless(os.access(os.path.abspath(filename), os.R_OK))
+ self.assertTrue(os.path.exists(filename))
+ self.assertTrue(os.path.isfile(filename))
+ self.assertTrue(os.access(filename, os.R_OK))
+ self.assertTrue(os.path.exists(os.path.abspath(filename)))
+ self.assertTrue(os.path.isfile(os.path.abspath(filename)))
+ self.assertTrue(os.access(os.path.abspath(filename), os.R_OK))
os.chmod(filename, 0o777)
os.utime(filename, None)
os.utime(filename, (time.time(), time.time()))
# Copy/rename etc tests using the same filename
self._do_copyish(filename, filename)
# Filename should appear in glob output
- self.failUnless(
+ self.assertTrue(
os.path.abspath(filename)==os.path.abspath(glob.glob(filename)[0]))
# basename should appear in listdir.
path, base = os.path.split(os.path.abspath(filename))
@@ -47,7 +47,7 @@
base = unicodedata.normalize("NFD", base)
file_list = [unicodedata.normalize("NFD", f) for f in file_list]
- self.failUnless(base in file_list)
+ self.assertTrue(base in file_list)
# Do as many "equivalancy' tests as we can - ie, check that although we
# have different types for the filename, they refer to the same file.
@@ -55,12 +55,12 @@
# Note we only check "filename1 against filename2" - we don't bother
# checking "filename2 against 1", as we assume we are called again with
# the args reversed.
- self.failUnless(type(filename1)!=type(filename2),
+ self.assertTrue(type(filename1)!=type(filename2),
"No point checking equivalent filenames of the same type")
# stat and lstat should return the same results.
- self.failUnlessEqual(os.stat(filename1),
+ self.assertEqual(os.stat(filename1),
os.stat(filename2))
- self.failUnlessEqual(os.lstat(filename1),
+ self.assertEqual(os.lstat(filename1),
os.lstat(filename2))
# Copy/rename etc tests using equivalent filename
self._do_copyish(filename1, filename2)
@@ -68,19 +68,19 @@
# Tests that copy, move, etc one file to another.
def _do_copyish(self, filename1, filename2):
# Should be able to rename the file using either name.
- self.failUnless(os.path.isfile(filename1)) # must exist.
+ self.assertTrue(os.path.isfile(filename1)) # must exist.
os.rename(filename1, filename2 + ".new")
- self.failUnless(os.path.isfile(filename1+".new"))
+ self.assertTrue(os.path.isfile(filename1+".new"))
os.rename(filename1 + ".new", filename2)
- self.failUnless(os.path.isfile(filename2))
+ self.assertTrue(os.path.isfile(filename2))
shutil.copy(filename1, filename2 + ".new")
os.unlink(filename1 + ".new") # remove using equiv name.
# And a couple of moves, one using each name.
shutil.move(filename1, filename2 + ".new")
- self.failUnless(not os.path.exists(filename2))
+ self.assertTrue(not os.path.exists(filename2))
shutil.move(filename1 + ".new", filename2)
- self.failUnless(os.path.exists(filename1))
+ self.assertTrue(os.path.exists(filename1))
# Note - due to the implementation of shutil.move,
# it tries a rename first. This only