[Python-checkins] r79259 - in python/branches/py3k: Doc/library/gzip.rst Doc/library/logging.rst Doc/tutorial/introduction.rst Lib/compileall.py Lib/ctypes/test/test_internals.py Lib/logging/__init__.py Lib/test/test_importhooks.py Lib/test/test_tarfile.py Lib/test/test_unittest.py Lib/test/test_xml_etree.py Lib/unittest/loader.py Makefile.pre.in Misc/Porting

benjamin.peterson python-checkins at python.org
Mon Mar 22 00:13:07 CET 2010


Author: benjamin.peterson
Date: Mon Mar 22 00:13:07 2010
New Revision: 79259
Log:
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 (2010年3月14日) | 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 (2010年3月14日) | 1 line
 
 this little exception dance is pointless
........
 r79018 | collin.winter | 2010年03月16日 22:04:01 -0500 (2010年3月16日) | 1 line
 
 Delete unused import.
........
 r79026 | vinay.sajip | 2010年03月17日 10:05:57 -0500 (2010年3月17日) | 1 line
 
 Issue #8162: logging: Clarified docstring and documentation for disable function.
........
 r79027 | collin.winter | 2010年03月17日 12:36:16 -0500 (2010年3月17日) | 1 line
 
 Avoid hardcoding refcounts in tests.
........
 r79055 | benjamin.peterson | 2010年03月18日 16:30:48 -0500 (2010年3月18日) | 1 line
 
 remove installation of deleted test/output dir
........
 r79156 | florent.xicluna | 2010年03月20日 17:21:02 -0500 (2010年3月20日) | 2 lines
 
 Cleanup test_struct using check_warnings.
........
 r79159 | florent.xicluna | 2010年03月20日 17:26:42 -0500 (2010年3月20日) | 2 lines
 
 Cleanup test_tarfile, and use check_warnings.
........
 r79163 | michael.foord | 2010年03月20日 19:53:39 -0500 (2010年3月20日) | 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 (2010年3月20日) | 1 line
 
 Change order of arguments in a unittest function.
........
 r79173 | georg.brandl | 2010年03月21日 04:09:38 -0500 (2010年3月21日) | 1 line
 
 Document that GzipFile supports iteration.
........
 r79176 | georg.brandl | 2010年03月21日 04:17:41 -0500 (2010年3月21日) | 1 line
 
 Introduce copy by slicing, used in later chapters.
........
 r79194 | florent.xicluna | 2010年03月21日 06:58:11 -0500 (2010年3月21日) | 2 lines
 
 Use assertRaises and add a specific warning filter.
........
 r79208 | andrew.kuchling | 2010年03月21日 13:47:12 -0500 (2010年3月21日) | 1 line
 
 Add items
........
 r79212 | georg.brandl | 2010年03月21日 14:01:38 -0500 (2010年3月21日) | 1 line
 
 Fix plural.
........
Modified:
 python/branches/py3k/ (props changed)
 python/branches/py3k/Doc/library/gzip.rst
 python/branches/py3k/Doc/library/logging.rst
 python/branches/py3k/Doc/tutorial/introduction.rst
 python/branches/py3k/Lib/compileall.py
 python/branches/py3k/Lib/ctypes/test/test_internals.py
 python/branches/py3k/Lib/logging/__init__.py
 python/branches/py3k/Lib/test/test_importhooks.py
 python/branches/py3k/Lib/test/test_tarfile.py
 python/branches/py3k/Lib/test/test_unittest.py
 python/branches/py3k/Lib/test/test_xml_etree.py
 python/branches/py3k/Lib/unittest/loader.py
 python/branches/py3k/Makefile.pre.in
 python/branches/py3k/Misc/Porting
Modified: python/branches/py3k/Doc/library/gzip.rst
==============================================================================
--- python/branches/py3k/Doc/library/gzip.rst	(original)
+++ python/branches/py3k/Doc/library/gzip.rst	Mon Mar 22 00:13:07 2010
@@ -67,7 +67,7 @@
 writing as *fileobj*, and retrieve the resulting memory buffer using the
 :class:`StringIO` object's :meth:`getvalue` method.
 
- :class:`GzipFile` supports the :keyword:`with` statement.
+ :class:`GzipFile` supports iteration and the :keyword:`with` statement.
 
 .. versionchanged:: 3.1
 Support for the :keyword:`with` statement was added.
Modified: python/branches/py3k/Doc/library/logging.rst
==============================================================================
--- python/branches/py3k/Doc/library/logging.rst	(original)
+++ python/branches/py3k/Doc/library/logging.rst	Mon Mar 22 00:13:07 2010
@@ -734,7 +734,11 @@
 
 Provides an overriding level *lvl* for all loggers which takes precedence over
 the logger's own level. When the need arises to temporarily throttle logging
- output down across the whole application, this function can be useful.
+ output down across the whole application, this function can be useful. Its
+ effect is to disable all logging calls of severity *lvl* and below, so that
+ if you call it with a value of INFO, then all INFO and DEBUG events would be
+ discarded, whereas those of severity WARNING and above would be processed
+ according to the logger's effective level.
 
 
 .. function:: addLevelName(lvl, levelName)
Modified: python/branches/py3k/Doc/tutorial/introduction.rst
==============================================================================
--- python/branches/py3k/Doc/tutorial/introduction.rst	(original)
+++ python/branches/py3k/Doc/tutorial/introduction.rst	Mon Mar 22 00:13:07 2010
@@ -482,6 +482,12 @@
 >>> 3*a[:3] + ['Boo!']
 ['spam', 'eggs', 100, 'spam', 'eggs', 100, 'spam', 'eggs', 100, 'Boo!']
 
+All slice operations return a new list containing the requested elements. This
+means that the following slice returns a shallow copy of the list *a*::
+
+ >>> a[:]
+ ['spam', 'eggs', 100, 1234]
+
 Unlike strings, which are *immutable*, it is possible to change individual
 elements of a list::
 
Modified: python/branches/py3k/Lib/compileall.py
==============================================================================
--- python/branches/py3k/Lib/compileall.py	(original)
+++ python/branches/py3k/Lib/compileall.py	Mon Mar 22 00:13:07 2010
@@ -97,8 +97,6 @@
 print('Compiling', fullname, '...')
 try:
 ok = py_compile.compile(fullname, None, dfile, True)
- except KeyboardInterrupt:
- raise KeyboardInterrupt
 except py_compile.PyCompileError as err:
 if quiet:
 print('*** Error compiling', fullname, '...')
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	Mon Mar 22 00:13:07 2010
@@ -23,16 +23,16 @@
 
 def test_ints(self):
 i = 42000123
- rc = grc(i)
+ refcnt = grc(i)
 ci = c_int(i)
- self.assertEqual(rc, grc(i))
+ self.assertEqual(refcnt, grc(i))
 self.assertEqual(ci._objects, None)
 
 def test_c_char_p(self):
 s = b"Hello, World"
- rc = grc(s)
+ refcnt = grc(s)
 cs = c_char_p(s)
- self.assertEqual(rc + 1, grc(s))
+ self.assertEqual(refcnt + 1, grc(s))
 self.assertSame(cs._objects, s)
 
 def test_simple_struct(self):
Modified: python/branches/py3k/Lib/logging/__init__.py
==============================================================================
--- python/branches/py3k/Lib/logging/__init__.py	(original)
+++ python/branches/py3k/Lib/logging/__init__.py	Mon Mar 22 00:13:07 2010
@@ -1555,7 +1555,7 @@
 
 def disable(level):
 """
- Disable all logging calls less severe than 'level'.
+ Disable all logging calls of severity 'level' and below.
 """
 root.manager.disable = level
 
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	Mon Mar 22 00:13:07 2010
@@ -221,15 +221,9 @@
 
 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()
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	Mon Mar 22 00:13:07 2010
@@ -68,7 +68,7 @@
 "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 @@
 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 @@
 
 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 @@
 "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()
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	Mon Mar 22 00:13:07 2010
@@ -291,6 +291,21 @@
 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()
 
Modified: python/branches/py3k/Lib/test/test_xml_etree.py
==============================================================================
--- python/branches/py3k/Lib/test/test_xml_etree.py	(original)
+++ python/branches/py3k/Lib/test/test_xml_etree.py	Mon Mar 22 00:13:07 2010
@@ -597,8 +597,8 @@
 </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>
Modified: python/branches/py3k/Lib/unittest/loader.py
==============================================================================
--- python/branches/py3k/Lib/unittest/loader.py	(original)
+++ python/branches/py3k/Lib/unittest/loader.py	Mon Mar 22 00:13:07 2010
@@ -23,12 +23,18 @@
 # Python 2.3 compatibility
 # format_exc returns two frames of discover.py as well
 message += '\n%s' % traceback.format_exc()
+ return _make_failed_test('ModuleImportFailure', name, ImportError(message),
+ suiteClass)
 
- def testImportFailure(self):
- raise ImportError(message)
- attrs = {name: testImportFailure}
- ModuleImportFailure = type('ModuleImportFailure', (case.TestCase,), attrs)
- return suiteClass((ModuleImportFailure(name),))
+def _make_failed_load_tests(name, exception, suiteClass):
+ return _make_failed_test('LoadTestsFailure', name, exception, suiteClass)
+
+def _make_failed_test(classname, methodname, exception, suiteClass):
+ def testFailure(self):
+ raise exception
+ attrs = {methodname: testFailure}
+ TestClass = type(classname, (case.TestCase,), attrs)
+ return suiteClass((TestClass(methodname),))
 
 
 class TestLoader(object):
@@ -63,7 +69,11 @@
 load_tests = getattr(module, 'load_tests', None)
 tests = self.suiteClass(tests)
 if use_load_tests and load_tests is not None:
- return load_tests(self, tests, None)
+ try:
+ return load_tests(self, tests, None)
+ except Exception as e:
+ return _make_failed_load_tests(module.__name__, e,
+ self.suiteClass)
 return tests
 
 def loadTestsFromName(self, name, module=None):
@@ -234,7 +244,11 @@
 for test in self._find_tests(full_path, pattern):
 yield test
 else:
- yield load_tests(self, tests, pattern)
+ try:
+ yield load_tests(self, tests, pattern)
+ except Exception as e:
+ yield _make_failed_load_tests(package.__name__, e,
+ self.suiteClass)
 
 defaultTestLoader = TestLoader()
 
Modified: python/branches/py3k/Makefile.pre.in
==============================================================================
--- python/branches/py3k/Makefile.pre.in	(original)
+++ python/branches/py3k/Makefile.pre.in	Mon Mar 22 00:13:07 2010
@@ -836,7 +836,7 @@
 MACHDEPS=	$(PLATDIR) $(EXTRAPLATDIR)
 XMLLIBSUBDIRS= xml xml/dom xml/etree xml/parsers xml/sax
 LIBSUBDIRS=	tkinter tkinter/test tkinter/test/test_tkinter \
- tkinter/test/test_ttk site-packages test test/data \
+ tkinter/test/test_ttk site-packages test \
 		test/decimaltestdata test/xmltestdata \
 		encodings \
 		email email/mime email/test email/test/data \
Modified: python/branches/py3k/Misc/Porting
==============================================================================
--- python/branches/py3k/Misc/Porting	(original)
+++ python/branches/py3k/Misc/Porting	Mon Mar 22 00:13:07 2010
@@ -31,7 +31,7 @@
 it out of the config.c file.
 
 Bang on it until you get a >>> prompt. (You may have to disable the
-importing of "site.py" by passing the -S options.)
+importing of "site.py" by passing the -S option.)
 
 Then bang on it until it executes very simple Python statements.
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /