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.
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 77ce7ed..4246b23 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -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