diff options
| author | R. David Murray <rdmurray@bitdance.com> | 2010-02-23 00:24:49 (GMT) |
|---|---|---|
| committer | R. David Murray <rdmurray@bitdance.com> | 2010-02-23 00:24:49 (GMT) |
| commit | f28fd24c36310541a1f3ec74e92e8d38629dd5d8 (patch) | |
| tree | ca85998492ba91f8874ba63fecd77397f65ad3d6 /Lib/test/test_functools.py | |
| parent | 87bcb243acfd758b3e91e194bf8f1198ae68a792 (diff) | |
| download | cpython-f28fd24c36310541a1f3ec74e92e8d38629dd5d8.zip cpython-f28fd24c36310541a1f3ec74e92e8d38629dd5d8.tar.gz cpython-f28fd24c36310541a1f3ec74e92e8d38629dd5d8.tar.bz2 | |
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.
Diffstat (limited to 'Lib/test/test_functools.py')
| -rw-r--r-- | Lib/test/test_functools.py | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py index b88e9b7..2549e05 100644 --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -1,4 +1,5 @@ import functools +import sys import unittest from test import test_support from weakref import proxy @@ -179,7 +180,7 @@ class TestUpdateWrapper(unittest.TestCase): 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 @@ class TestUpdateWrapper(unittest.TestCase): 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 TestUpdateWrapper(unittest.TestCase): class TestWraps(TestUpdateWrapper): - def test_default_update(self): + def _default_update(self): def f(): """This is a test""" pass @@ -241,10 +251,19 @@ class TestWraps(TestUpdateWrapper): 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 @@ class TestReduce(unittest.TestCase): def test_main(verbose=None): - import sys test_classes = ( TestPartial, TestPartialSubclass, |
