[Python-checkins] r78351 - in python/trunk: Lib/distutils/tests/test_build_py.py Lib/distutils/tests/test_extension.py Lib/distutils/tests/test_install_lib.py Lib/doctest.py Lib/lib2to3/tests/test_refactor.py Lib/test/test_collections.py Lib/test/test_contextlib.py Lib/test/test_descr.py Lib/test/test_doctest2.py Lib/test/test_docxmlrpc.py Lib/test/test_functools.py Lib/test/test_inspect.py Lib/test/test_pkg.py Lib/test/test_property.py Lib/test/test_pydoc.py Lib/test/test_unittest.py Lib/test/test_xmlrpc.py Misc/ACKS Misc/NEWS

r.david.murray python-checkins at python.org
Tue Feb 23 01:24:50 CET 2010


Author: r.david.murray
Date: Tue Feb 23 01:24:49 2010
New Revision: 78351
Log:
Issue 6292: for the moment at least, the test suite passes if run
with -OO. Tests requiring docstrings are skipped. Patch by
Brian Curtin, thanks to Matias Torchinsky for helping review and
improve the patch.
Modified:
 python/trunk/Lib/distutils/tests/test_build_py.py
 python/trunk/Lib/distutils/tests/test_extension.py
 python/trunk/Lib/distutils/tests/test_install_lib.py
 python/trunk/Lib/doctest.py
 python/trunk/Lib/lib2to3/tests/test_refactor.py
 python/trunk/Lib/test/test_collections.py
 python/trunk/Lib/test/test_contextlib.py
 python/trunk/Lib/test/test_descr.py
 python/trunk/Lib/test/test_doctest2.py
 python/trunk/Lib/test/test_docxmlrpc.py
 python/trunk/Lib/test/test_functools.py
 python/trunk/Lib/test/test_inspect.py
 python/trunk/Lib/test/test_pkg.py
 python/trunk/Lib/test/test_property.py
 python/trunk/Lib/test/test_pydoc.py
 python/trunk/Lib/test/test_unittest.py
 python/trunk/Lib/test/test_xmlrpc.py
 python/trunk/Misc/ACKS
 python/trunk/Misc/NEWS
Modified: python/trunk/Lib/distutils/tests/test_build_py.py
==============================================================================
--- python/trunk/Lib/distutils/tests/test_build_py.py	(original)
+++ python/trunk/Lib/distutils/tests/test_build_py.py	Tue Feb 23 01:24:49 2010
@@ -16,7 +16,7 @@
 support.LoggingSilencer,
 unittest.TestCase):
 
- def test_package_data(self):
+ def _setup_package_data(self):
 sources = self.mkdtemp()
 f = open(os.path.join(sources, "__init__.py"), "w")
 f.write("# Pretend this is a package.")
@@ -52,10 +52,19 @@
 self.assertEqual(len(cmd.get_outputs()), 3)
 pkgdest = os.path.join(destination, "pkg")
 files = os.listdir(pkgdest)
+ return files
+
+ def test_package_data(self):
+ files = self._setup_package_data()
 self.assertTrue("__init__.py" in files)
- self.assertTrue("__init__.pyc" in files)
 self.assertTrue("README.txt" in files)
 
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "pyc files are not written with -O2 and above")
+ def test_package_data_pyc(self):
+ files = self._setup_package_data()
+ self.assertTrue("__init__.pyc" in files)
+
 def test_empty_package_dir (self):
 # See SF 1668596/1720897.
 cwd = os.getcwd()
Modified: python/trunk/Lib/distutils/tests/test_extension.py
==============================================================================
--- python/trunk/Lib/distutils/tests/test_extension.py	(original)
+++ python/trunk/Lib/distutils/tests/test_extension.py	Tue Feb 23 01:24:49 2010
@@ -1,6 +1,7 @@
 """Tests for distutils.extension."""
-import unittest
 import os
+import sys
+import unittest
 import warnings
 
 from test.test_support import check_warnings
@@ -32,16 +33,22 @@
 
 self.assertEquals(names, wanted)
 
- def test_extension_init(self):
- # the first argument, which is the name, must be a string
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Assertions are omitted with -O2 and above")
+ def test_extension_init_assertions(self):
+ # The first argument, which is the name, must be a string.
 self.assertRaises(AssertionError, Extension, 1, [])
- ext = Extension('name', [])
- self.assertEquals(ext.name, 'name')
 
 # the second argument, which is the list of files, must
 # be a list of strings
 self.assertRaises(AssertionError, Extension, 'name', 'file')
 self.assertRaises(AssertionError, Extension, 'name', ['file', 1])
+
+ def test_extension_init(self):
+ ext = Extension('name', [])
+ self.assertEquals(ext.name, 'name')
+
+
 ext = Extension('name', ['file1', 'file2'])
 self.assertEquals(ext.sources, ['file1', 'file2'])
 
Modified: python/trunk/Lib/distutils/tests/test_install_lib.py
==============================================================================
--- python/trunk/Lib/distutils/tests/test_install_lib.py	(original)
+++ python/trunk/Lib/distutils/tests/test_install_lib.py	Tue Feb 23 01:24:49 2010
@@ -1,6 +1,6 @@
 """Tests for distutils.command.install_data."""
-import sys
 import os
+import sys
 import unittest
 
 from distutils.command.install_lib import install_lib
@@ -31,9 +31,7 @@
 cmd.finalize_options()
 self.assertEquals(cmd.optimize, 2)
 
- @unittest.skipUnless(not sys.dont_write_bytecode,
- 'byte-compile not supported')
- def test_byte_compile(self):
+ def _setup_byte_compile(self):
 pkg_dir, dist = self.create_dist()
 cmd = install_lib(dist)
 cmd.compile = cmd.optimize = 1
@@ -41,8 +39,15 @@
 f = os.path.join(pkg_dir, 'foo.py')
 self.write_file(f, '# python file')
 cmd.byte_compile([f])
- self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyc')))
- self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyo')))
+ return pkg_dir
+
+ @unittest.skipIf(sys.dont_write_bytecode, 'byte-compile not enabled')
+ def test_byte_compile(self):
+ pkg_dir = self._setup_byte_compile()
+ if sys.flags.optimize < 1:
+ self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyc')))
+ else:
+ self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyo')))
 
 def test_get_outputs(self):
 pkg_dir, dist = self.create_dist()
Modified: python/trunk/Lib/doctest.py
==============================================================================
--- python/trunk/Lib/doctest.py	(original)
+++ python/trunk/Lib/doctest.py	Tue Feb 23 01:24:49 2010
@@ -2240,6 +2240,19 @@
 def shortDescription(self):
 return "Doctest: " + self._dt_test.name
 
+class SkipDocTestCase(DocTestCase):
+ def __init__(self):
+ DocTestCase.__init__(self, None)
+
+ def setUp(self):
+ self.skipTest("DocTestSuite will not work with -O2 and above")
+
+ def test_skip(self):
+ pass
+
+ def shortDescription(self):
+ return "Skipping tests from %s" % module.__name__
+
 def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None,
 **options):
 """
@@ -2282,13 +2295,20 @@
 
 module = _normalize_module(module)
 tests = test_finder.find(module, globs=globs, extraglobs=extraglobs)
- if not tests:
+
+ if not tests and sys.flags.optimize >=2:
+ # Skip doctests when running with -O2
+ suite = unittest.TestSuite()
+ suite.addTest(SkipDocTestCase())
+ return suite
+ elif not tests:
 # Why do we want to do this? Because it reveals a bug that might
 # otherwise be hidden.
 raise ValueError(module, "has no tests")
 
 tests.sort()
 suite = unittest.TestSuite()
+
 for test in tests:
 if len(test.examples) == 0:
 continue
Modified: python/trunk/Lib/lib2to3/tests/test_refactor.py
==============================================================================
--- python/trunk/Lib/lib2to3/tests/test_refactor.py	(original)
+++ python/trunk/Lib/lib2to3/tests/test_refactor.py	Tue Feb 23 01:24:49 2010
@@ -239,6 +239,9 @@
 finally:
 os.linesep = old_sep
 
+
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
 def test_refactor_docstring(self):
 rt = self.rt()
 
Modified: python/trunk/Lib/test/test_collections.py
==============================================================================
--- python/trunk/Lib/test/test_collections.py	(original)
+++ python/trunk/Lib/test/test_collections.py	Tue Feb 23 01:24:49 2010
@@ -8,6 +8,7 @@
 from random import randrange, shuffle
 import keyword
 import re
+import sys
 from collections import Hashable, Iterable, Iterator
 from collections import Sized, Container, Callable
 from collections import Set, MutableSet
@@ -21,7 +22,6 @@
 def test_factory(self):
 Point = namedtuple('Point', 'x y')
 self.assertEqual(Point.__name__, 'Point')
- self.assertEqual(Point.__doc__, 'Point(x, y)')
 self.assertEqual(Point.__slots__, ())
 self.assertEqual(Point.__module__, __name__)
 self.assertEqual(Point.__getitem__, tuple.__getitem__)
@@ -48,6 +48,12 @@
 self.assertRaises(TypeError, Point._make, [11]) # catch too few args
 self.assertRaises(TypeError, Point._make, [11, 22, 33]) # catch too many args
 
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def test_factory_doc_attr(self):
+ Point = namedtuple('Point', 'x y')
+ self.assertEqual(Point.__doc__, 'Point(x, y)')
+
 def test_name_fixer(self):
 for spec, renamed in [
 [('efg', 'g%hi'), ('efg', '_1')], # field with non-alpha char
Modified: python/trunk/Lib/test/test_contextlib.py
==============================================================================
--- python/trunk/Lib/test/test_contextlib.py	(original)
+++ python/trunk/Lib/test/test_contextlib.py	Tue Feb 23 01:24:49 2010
@@ -2,6 +2,7 @@
 
 
 import os
+import sys
 import tempfile
 import unittest
 import threading
@@ -84,7 +85,7 @@
 raise ZeroDivisionError(999)
 self.assertEqual(state, [1, 42, 999])
 
- def test_contextmanager_attribs(self):
+ def _create_contextmanager_attribs(self):
 def attribs(**kw):
 def decorate(func):
 for k,v in kw.items():
@@ -95,8 +96,17 @@
 @attribs(foo='bar')
 def baz(spam):
 """Whee!"""
+ return baz
+
+ def test_contextmanager_attribs(self):
+ baz = self._create_contextmanager_attribs()
 self.assertEqual(baz.__name__,'baz')
 self.assertEqual(baz.foo, 'bar')
+
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def test_contextmanager_doc_attrib(self):
+ baz = self._create_contextmanager_attribs()
 self.assertEqual(baz.__doc__, "Whee!")
 
 class NestedTestCase(unittest.TestCase):
Modified: python/trunk/Lib/test/test_descr.py
==============================================================================
--- python/trunk/Lib/test/test_descr.py	(original)
+++ python/trunk/Lib/test/test_descr.py	Tue Feb 23 01:24:49 2010
@@ -2057,6 +2057,9 @@
 else:
 self.fail("expected ZeroDivisionError from bad property")
 
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def test_properties_doc_attrib(self):
 class E(object):
 def getter(self):
 "getter method"
@@ -2069,6 +2072,7 @@
 prop2 = property(fset=setter)
 self.assertEqual(prop2.__doc__, None)
 
+ def test_testcapi_no_segfault(self):
 # this segfaulted in 2.5b2
 try:
 import _testcapi
Modified: python/trunk/Lib/test/test_doctest2.py
==============================================================================
--- python/trunk/Lib/test/test_doctest2.py	(original)
+++ python/trunk/Lib/test/test_doctest2.py	Tue Feb 23 01:24:49 2010
@@ -12,7 +12,11 @@
 
 """
 
+import sys
+import unittest
 from test import test_support
+if sys.flags.optimize >= 2:
+ raise unittest.SkipTest("Cannot test docstrings with -O2")
 
 class C(object):
 u"""Class C.
Modified: python/trunk/Lib/test/test_docxmlrpc.py
==============================================================================
--- python/trunk/Lib/test/test_docxmlrpc.py	(original)
+++ python/trunk/Lib/test/test_docxmlrpc.py	Tue Feb 23 01:24:49 2010
@@ -1,5 +1,6 @@
 from DocXMLRPCServer import DocXMLRPCServer
 import httplib
+import sys
 from test import test_support
 import threading
 import time
@@ -8,6 +9,20 @@
 
 PORT = None
 
+def make_request_and_skipIf(condition, reason):
+ # If we skip the test, we have to make a request because the
+ # the server created in setUp blocks expecting one to come in.
+ if not condition:
+ return lambda func: func
+ def decorator(func):
+ def make_request_and_skip(self):
+ self.client.request("GET", "/")
+ self.client.getresponse()
+ raise unittest.SkipTest(reason)
+ return make_request_and_skip
+ return decorator
+
+
 def server(evt, numrequests):
 serv = DocXMLRPCServer(("localhost", 0), logRequests=False)
 
@@ -111,10 +126,12 @@
 '&lt;lambda&gt;</strong></a>(x, y)</dt></dl>',
 response.read())
 
+ @make_request_and_skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
 def test_autolinking(self):
- """Test that the server correctly automatically wraps references to PEPS
- and RFCs with links, and that it linkifies text starting with http or
- ftp protocol prefixes.
+ """Test that the server correctly automatically wraps references to
+ PEPS and RFCs with links, and that it linkifies text starting with
+ http or ftp protocol prefixes.
 
 The documentation for the "add" method contains the test material.
 """
@@ -133,11 +150,13 @@
 'auto-linked,&nbsp;too:<br>\n<a href="http://google.com">'
 'http://google.com</a>.</tt></dd></dl>'), response.read())
 
+ @make_request_and_skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
 def test_system_methods(self):
 """Test the precense of three consecutive system.* methods.
 
- This also tests their use of parameter type recognition and the systems
- related to that process.
+ This also tests their use of parameter type recognition and the
+ systems related to that process.
 """
 self.client.request("GET", "/")
 response = self.client.getresponse()
Modified: python/trunk/Lib/test/test_functools.py
==============================================================================
--- python/trunk/Lib/test/test_functools.py	(original)
+++ python/trunk/Lib/test/test_functools.py	Tue Feb 23 01:24:49 2010
@@ -1,4 +1,5 @@
 import functools
+import sys
 import unittest
 from test import test_support
 from weakref import proxy
@@ -179,7 +180,7 @@
 for key in wrapped_attr:
 self.assertTrue(wrapped_attr[key] is wrapper_attr[key])
 
- def test_default_update(self):
+ def _default_update(self):
 def f():
 """This is a test"""
 pass
@@ -187,11 +188,20 @@
 def wrapper():
 pass
 functools.update_wrapper(wrapper, f)
+ return wrapper, f
+
+ def test_default_update(self):
+ wrapper, f = self._default_update()
 self.check_wrapper(wrapper, f)
 self.assertEqual(wrapper.__name__, 'f')
- self.assertEqual(wrapper.__doc__, 'This is a test')
 self.assertEqual(wrapper.attr, 'This is also a test')
 
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def test_default_update_doc(self):
+ wrapper, f = self._default_update()
+ self.assertEqual(wrapper.__doc__, 'This is a test')
+
 def test_no_update(self):
 def f():
 """This is a test"""
@@ -232,7 +242,7 @@
 
 class TestWraps(TestUpdateWrapper):
 
- def test_default_update(self):
+ def _default_update(self):
 def f():
 """This is a test"""
 pass
@@ -241,10 +251,19 @@
 def wrapper():
 pass
 self.check_wrapper(wrapper, f)
+ return wrapper
+
+ def test_default_update(self):
+ wrapper = self._default_update()
 self.assertEqual(wrapper.__name__, 'f')
- self.assertEqual(wrapper.__doc__, 'This is a test')
 self.assertEqual(wrapper.attr, 'This is also a test')
 
+ @unittest.skipIf(not sys.flags.optimize <= 1,
+ "Docstrings are omitted with -O2 and above")
+ def test_default_update_doc(self):
+ wrapper = self._default_update()
+ self.assertEqual(wrapper.__doc__, 'This is a test')
+
 def test_no_update(self):
 def f():
 """This is a test"""
@@ -323,7 +342,6 @@
 
 
 def test_main(verbose=None):
- import sys
 test_classes = (
 TestPartial,
 TestPartialSubclass,
Modified: python/trunk/Lib/test/test_inspect.py
==============================================================================
--- python/trunk/Lib/test/test_inspect.py	(original)
+++ python/trunk/Lib/test/test_inspect.py	Tue Feb 23 01:24:49 2010
@@ -230,6 +230,8 @@
 self.assertEqual(functions, [('eggs', mod.eggs),
 ('spam', mod.spam)])
 
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
 def test_getdoc(self):
 self.assertEqual(inspect.getdoc(mod), 'A module docstring.')
 self.assertEqual(inspect.getdoc(mod.StupidGit),
Modified: python/trunk/Lib/test/test_pkg.py
==============================================================================
--- python/trunk/Lib/test/test_pkg.py	(original)
+++ python/trunk/Lib/test/test_pkg.py	Tue Feb 23 01:24:49 2010
@@ -51,7 +51,8 @@
 
 def tearDown(self):
 sys.path[:] = self.syspath
- cleanout(self.root)
+ if self.root: # Only clean if the test was actually run
+ cleanout(self.root)
 
 # delete all modules concerning the tested hiearchy
 if self.pkgname:
@@ -101,9 +102,6 @@
 ]
 self.mkhier(hier)
 
- import t2
- self.assertEqual(t2.__doc__, "doc for t2")
-
 import t2.sub
 import t2.sub.subsub
 self.assertEqual(t2.__name__, "t2")
@@ -274,6 +272,17 @@
 self.assertFalse(sub)
 self.assertFalse(subsub)
 
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def test_8(self):
+ hier = [
+ ("t8", None),
+ ("t8 __init__"+os.extsep+"py", "'doc for t8'"),
+ ]
+ self.mkhier(hier)
+
+ import t8
+ self.assertEqual(t8.__doc__, "doc for t8")
 
 def test_main():
 test_support.run_unittest(__name__)
Modified: python/trunk/Lib/test/test_property.py
==============================================================================
--- python/trunk/Lib/test/test_property.py	(original)
+++ python/trunk/Lib/test/test_property.py	Tue Feb 23 01:24:49 2010
@@ -1,6 +1,7 @@
 # Test case for property
 # more tests are in test_descr
 
+import sys
 import unittest
 from test.test_support import run_unittest
 
@@ -91,7 +92,6 @@
 base.spam = 20
 self.assertEqual(base.spam, 20)
 self.assertEqual(base._spam, 20)
- self.assertEqual(base.__class__.spam.__doc__, "BaseClass.getter")
 
 def test_property_decorator_subclass(self):
 # see #1620
@@ -99,14 +99,27 @@
 self.assertRaises(PropertyGet, getattr, sub, "spam")
 self.assertRaises(PropertySet, setattr, sub, "spam", None)
 self.assertRaises(PropertyDel, delattr, sub, "spam")
+
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def test_property_decorator_subclass_doc(self):
+ sub = SubClass()
 self.assertEqual(sub.__class__.spam.__doc__, "SubClass.getter")
 
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def test_property_decorator_baseclass_doc(self):
+ base = BaseClass()
+ self.assertEqual(base.__class__.spam.__doc__, "BaseClass.getter")
+
 def test_property_decorator_doc(self):
 base = PropertyDocBase()
 sub = PropertyDocSub()
 self.assertEqual(base.__class__.spam.__doc__, "spam spam spam")
 self.assertEqual(sub.__class__.spam.__doc__, "spam spam spam")
 
+ @unittest.skipIf(sys.flags.optimize >= 1,
+ "Docstrings are omitted with -O2 and above")
 def test_property_getter_doc_override(self):
 newgettersub = PropertySubNewGetter()
 self.assertEqual(newgettersub.spam, 5)
@@ -126,16 +139,6 @@
 
 class PropertySubclassTests(unittest.TestCase):
 
- def test_docstring_copy(self):
- class Foo(object):
- @PropertySub
- def spam(self):
- """spam wrapped in property subclass"""
- return 1
- self.assertEqual(
- Foo.spam.__doc__,
- "spam wrapped in property subclass")
-
 def test_slots_docstring_copy_exception(self):
 try:
 class Foo(object):
@@ -148,6 +151,20 @@
 else:
 raise Exception("AttributeError not raised")
 
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
+ def test_docstring_copy(self):
+ class Foo(object):
+ @PropertySub
+ def spam(self):
+ """spam wrapped in property subclass"""
+ return 1
+ self.assertEqual(
+ Foo.spam.__doc__,
+ "spam wrapped in property subclass")
+
+ @unittest.skipIf(sys.flags.optimize <= 2,
+ "Docstrings are omitted with -O2 and above")
 def test_property_setter_copies_getter_docstring(self):
 class Foo(object):
 def __init__(self): self._spam = 1
@@ -179,6 +196,8 @@
 FooSub.spam.__doc__,
 "spam wrapped in property subclass")
 
+ @unittest.skipIf(sys.flags.optimize <= 2,
+ "Docstrings are omitted with -O2 and above")
 def test_property_new_getter_new_docstring(self):
 
 class Foo(object):
Modified: python/trunk/Lib/test/test_pydoc.py
==============================================================================
--- python/trunk/Lib/test/test_pydoc.py	(original)
+++ python/trunk/Lib/test/test_pydoc.py	Tue Feb 23 01:24:49 2010
@@ -219,6 +219,8 @@
 
 class PyDocDocTest(unittest.TestCase):
 
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
 def test_html_doc(self):
 result, doc_loc = get_pydoc_html(pydoc_mod)
 mod_file = inspect.getabsfile(pydoc_mod)
@@ -232,6 +234,8 @@
 print_diffs(expected_html, result)
 self.fail("outputs are not equal, see diff above")
 
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
 def test_text_doc(self):
 result, doc_loc = get_pydoc_text(pydoc_mod)
 expected_text = expected_text_pattern % \
Modified: python/trunk/Lib/test/test_unittest.py
==============================================================================
--- python/trunk/Lib/test/test_unittest.py	(original)
+++ python/trunk/Lib/test/test_unittest.py	Tue Feb 23 01:24:49 2010
@@ -2041,6 +2041,8 @@
 'testGetDescriptionWithoutDocstring (' + __name__ +
 '.Test_TestResult)')
 
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
 def testGetDescriptionWithOneLineDocstring(self):
 """Tests getDescription() for a method with a docstring."""
 result = unittest.TextTestResult(None, True, 1)
@@ -2050,6 +2052,8 @@
 '(' + __name__ + '.Test_TestResult)\n'
 'Tests getDescription() for a method with a docstring.'))
 
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
 def testGetDescriptionWithMultiLineDocstring(self):
 """Tests getDescription() for a method with a longer docstring.
 The second line of the docstring.
@@ -2525,12 +2529,16 @@
 def testShortDescriptionWithoutDocstring(self):
 self.assertIsNone(self.shortDescription())
 
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
 def testShortDescriptionWithOneLineDocstring(self):
 """Tests shortDescription() for a method with a docstring."""
 self.assertEqual(
 self.shortDescription(),
 'Tests shortDescription() for a method with a docstring.')
 
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
 def testShortDescriptionWithMultiLineDocstring(self):
 """Tests shortDescription() for a method with a longer docstring.
 
Modified: python/trunk/Lib/test/test_xmlrpc.py
==============================================================================
--- python/trunk/Lib/test/test_xmlrpc.py	(original)
+++ python/trunk/Lib/test/test_xmlrpc.py	Tue Feb 23 01:24:49 2010
@@ -505,6 +505,8 @@
 # protocol error; provide additional information in test output
 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
 
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
 def test_introspection3(self):
 try:
 # test native doc
Modified: python/trunk/Misc/ACKS
==============================================================================
--- python/trunk/Misc/ACKS	(original)
+++ python/trunk/Misc/ACKS	Tue Feb 23 01:24:49 2010
@@ -755,6 +755,7 @@
 Frank J. Tobin
 R Lindsay Todd
 Bennett Todd
+Matias Torchinsky
 Richard Townsend
 Laurence Tratt
 John Tromp
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Tue Feb 23 01:24:49 2010
@@ -57,6 +57,9 @@
 Tests
 -----
 
+- Issue #6292: for the moment at least, the test suite runs cleanly if python
+ is run with the -OO flag. Tests requiring docstrings are skipped.
+
 - Issue #7712: test_support gained a new `temp_cwd` context manager which is
 now also used by regrtest to run all the tests in a temporary directory.
 The original CWD is saved in `test_support.SAVEDCWD`.


More information about the Python-checkins mailing list

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