summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-03-21 23:13:07 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-03-21 23:13:07 (GMT)
commit886af966d8f5ae3a2333e559c43d721ac70d83d8 (patch)
tree425c5806e776b83c9caeddaca034ce1d7ae4ee3d /Lib/test
parent11dbfd41957b3602d3adcbe24108b508c4a71356 (diff)
downloadcpython-886af966d8f5ae3a2333e559c43d721ac70d83d8.zip
cpython-886af966d8f5ae3a2333e559c43d721ac70d83d8.tar.gz
cpython-886af966d8f5ae3a2333e559c43d721ac70d83d8.tar.bz2
Merged revisions 78966,78970,79018,79026-79027,79055,79156,79159,79163-79164,79173,79176,79194,79208,79212 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r78966 | florent.xicluna | 2010-03-14 10:20:59 -0500 (Sun, 14 Mar 2010) | 2 lines Do not hardcode Expat version. It's possible to build Python with --with-system-expat option. ........ r78970 | benjamin.peterson | 2010-03-14 21:58:24 -0500 (Sun, 14 Mar 2010) | 1 line this little exception dance is pointless ........ r79018 | collin.winter | 2010-03-16 22:04:01 -0500 (Tue, 16 Mar 2010) | 1 line Delete unused import. ........ r79026 | vinay.sajip | 2010-03-17 10:05:57 -0500 (Wed, 17 Mar 2010) | 1 line Issue #8162: logging: Clarified docstring and documentation for disable function. ........ r79027 | collin.winter | 2010-03-17 12:36:16 -0500 (Wed, 17 Mar 2010) | 1 line Avoid hardcoding refcounts in tests. ........ r79055 | benjamin.peterson | 2010-03-18 16:30:48 -0500 (Thu, 18 Mar 2010) | 1 line remove installation of deleted test/output dir ........ r79156 | florent.xicluna | 2010-03-20 17:21:02 -0500 (Sat, 20 Mar 2010) | 2 lines Cleanup test_struct using check_warnings. ........ r79159 | florent.xicluna | 2010-03-20 17:26:42 -0500 (Sat, 20 Mar 2010) | 2 lines Cleanup test_tarfile, and use check_warnings. ........ r79163 | michael.foord | 2010-03-20 19:53:39 -0500 (Sat, 20 Mar 2010) | 1 line A faulty load_tests in a test module no longer halts test discovery. A placeholder test, that reports the failure, is created instead. ........ r79164 | michael.foord | 2010-03-20 19:55:58 -0500 (Sat, 20 Mar 2010) | 1 line Change order of arguments in a unittest function. ........ r79173 | georg.brandl | 2010-03-21 04:09:38 -0500 (Sun, 21 Mar 2010) | 1 line Document that GzipFile supports iteration. ........ r79176 | georg.brandl | 2010-03-21 04:17:41 -0500 (Sun, 21 Mar 2010) | 1 line Introduce copy by slicing, used in later chapters. ........ r79194 | florent.xicluna | 2010-03-21 06:58:11 -0500 (Sun, 21 Mar 2010) | 2 lines Use assertRaises and add a specific warning filter. ........ r79208 | andrew.kuchling | 2010-03-21 13:47:12 -0500 (Sun, 21 Mar 2010) | 1 line Add items ........ r79212 | georg.brandl | 2010-03-21 14:01:38 -0500 (Sun, 21 Mar 2010) | 1 line Fix plural. ........
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_importhooks.py10
-rw-r--r--Lib/test/test_tarfile.py21
-rw-r--r--Lib/test/test_unittest.py15
-rw-r--r--Lib/test/test_xml_etree.py4
4 files changed, 31 insertions, 19 deletions
diff --git a/Lib/test/test_importhooks.py b/Lib/test/test_importhooks.py
index 1da30b7..ec6730e 100644
--- a/Lib/test/test_importhooks.py
+++ b/Lib/test/test_importhooks.py
@@ -221,15 +221,9 @@ class ImportHooksTestCase(ImportHooksBaseTestCase):
def testBlocker(self):
mname = "exceptions" # an arbitrary harmless builtin module
- if mname in sys.modules:
- del sys.modules[mname]
+ support.unload(mname)
sys.meta_path.append(ImportBlocker(mname))
- try:
- __import__(mname)
- except ImportError:
- pass
- else:
- self.fail("'%s' was not supposed to be importable" % mname)
+ self.assertRaises(ImportError, __import__, mname)
def testImpWrapper(self):
i = ImpWrapper()
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index 89a2583..ff04ef8 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -68,7 +68,7 @@ class UstarReadTest(ReadTest):
"fileobj.readlines() failed")
self.assertTrue(len(lines2) == 114,
"fileobj.readlines() failed")
- self.assertTrue(lines2[83] == \
+ self.assertTrue(lines2[83] ==
"I will gladly admit that Python is not the fastest running scripting language.\n",
"fileobj.readlines() failed")
@@ -706,11 +706,12 @@ class WriteTest(WriteTestBase):
name = os.path.join(tempdir, name)
open(name, "wb").close()
- def exclude(name):
- return os.path.isfile(name)
+ exclude = os.path.isfile
tar = tarfile.open(tmpname, self.mode, encoding="iso8859-1")
- tar.add(tempdir, arcname="empty_dir", exclude=exclude)
+ with support.check_warnings(("use the filter argument",
+ DeprecationWarning)):
+ tar.add(tempdir, arcname="empty_dir", exclude=exclude)
tar.close()
tar = tarfile.open(tmpname, "r")
@@ -888,10 +889,12 @@ class GNUWriteTest(unittest.TestCase):
tar = tarfile.open(tmpname)
member = tar.next()
- 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")
+ self.assertIsNotNone(member,
+ "unable to read longname member")
+ self.assertEqual(tarinfo.name, member.name,
+ "unable to read longname member")
+ self.assertEqual(tarinfo.linkname, member.linkname,
+ "unable to read longname member")
def test_longname_1023(self):
self._test(("longnam/" * 127) + "longnam")
@@ -993,7 +996,7 @@ class PaxWriteTest(GNUWriteTest):
"test": "\xe4\xf6\xfc",
"\xe4\xf6\xfc": "test"}
- tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT, \
+ tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT,
pax_headers=pax_headers)
tar.addfile(tarfile.TarInfo("test"))
tar.close()
diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py
index f24a929..b4716a4 100644
--- a/Lib/test/test_unittest.py
+++ b/Lib/test/test_unittest.py
@@ -291,6 +291,21 @@ class Test_TestLoader(TestCase):
suite = loader.loadTestsFromModule(m, use_load_tests=False)
self.assertEquals(load_tests_args, [])
+ def test_loadTestsFromModule__faulty_load_tests(self):
+ m = types.ModuleType('m')
+
+ def load_tests(loader, tests, pattern):
+ raise TypeError('some failure')
+ m.load_tests = load_tests
+
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromModule(m)
+ self.assertIsInstance(suite, unittest.TestSuite)
+ self.assertEqual(suite.countTestCases(), 1)
+ test = list(suite)[0]
+
+ self.assertRaisesRegexp(TypeError, "some failure", test.m)
+
################################################################
### /Tests for TestLoader.loadTestsFromModule()
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 3051540..f1990d1 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -597,8 +597,8 @@ def parsefile():
</ns0:root>
>>> parser = ET.XMLParser()
- >>> parser.version # XXX: Upgrade to 2.0.1?
- 'Expat 2.0.0'
+ >>> parser.version # doctest: +ELLIPSIS
+ 'Expat ...'
>>> parser.feed(open(SIMPLE_XMLFILE).read())
>>> print(serialize(parser.close()))
<root>