summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_property.py
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2010-02-24 01:46:21 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2010-02-24 01:46:21 (GMT)
commit378c0cf5abb4c49c1a95597d3c5284dc93dd7822 (patch)
tree0a7c9a724887dff98a5abefd9b09da0de6889731 /Lib/test/test_property.py
parent72aee3dcabf98a0b8a7a60cccab4fbd1ef63fbd2 (diff)
downloadcpython-378c0cf5abb4c49c1a95597d3c5284dc93dd7822.zip
cpython-378c0cf5abb4c49c1a95597d3c5284dc93dd7822.tar.gz
cpython-378c0cf5abb4c49c1a95597d3c5284dc93dd7822.tar.bz2
Merged revisions 78351 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r78351 | r.david.murray | 2010-02-22 19:24:49 -0500 (Mon, 22 Feb 2010) | 5 lines 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_property.py')
-rw-r--r--Lib/test/test_property.py41
1 files changed, 30 insertions, 11 deletions
diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py
index d9469d9..5d44fb0 100644
--- a/Lib/test/test_property.py
+++ b/Lib/test/test_property.py
@@ -1,6 +1,7 @@
# Test case for property
# more tests are in test_descr
+import sys
import unittest
from test.support import run_unittest
@@ -91,7 +92,6 @@ class PropertyTests(unittest.TestCase):
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 @@ class PropertyTests(unittest.TestCase):
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 PropertySubSlots(property):
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 @@ class PropertySubclassTests(unittest.TestCase):
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 @@ class PropertySubclassTests(unittest.TestCase):
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):