[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.81,1.82 test_doctest2.py,1.2,1.3
Tim Peters
tim_one@users.sourceforge.net
Wed, 03 Oct 2001 22:27:02 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv1972/python/Lib/test
Modified Files:
test_descr.py test_doctest2.py
Log Message:
SF bug [#467331] ClassType.__doc__ always None.
For a dynamically constructed type object, fill in the tp_doc slot with
a copy of the argument dict's "__doc__" value, provided the latter exists
and is a string.
NOTE: I don't know what to do if it's a Unicode string, so in that case
tp_doc is left NULL (which shows up as Py_None if you do Class.__doc__).
Note that tp_doc holds a char*, not a general PyObject*.
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.81
retrieving revision 1.82
diff -C2 -d -r1.81 -r1.82
*** test_descr.py 2001/10/03 13:59:54 1.81
--- test_descr.py 2001/10/04 05:27:00 1.82
***************
*** 89,92 ****
--- 89,124 ----
verify(dict['a'] == res)
+ def class_docstrings():
+ class Classic:
+ "A classic docstring."
+ verify(Classic.__doc__ == "A classic docstring.")
+ verify(Classic.__dict__['__doc__'] == "A classic docstring.")
+
+ class Classic2:
+ pass
+ verify(Classic2.__doc__ is None)
+
+ class NewStatic:
+ "Another docstring."
+ __dynamic__ = 0
+ verify(NewStatic.__doc__ == "Another docstring.")
+ verify(NewStatic.__dict__['__doc__'] == "Another docstring.")
+
+ class NewStatic2:
+ __dynamic__ = 0
+ pass
+ verify(NewStatic2.__doc__ is None)
+
+ class NewDynamic:
+ "Another docstring."
+ __dynamic__ = 1
+ verify(NewDynamic.__doc__ == "Another docstring.")
+ verify(NewDynamic.__dict__['__doc__'] == "Another docstring.")
+
+ class NewDynamic2:
+ __dynamic__ = 1
+ pass
+ verify(NewDynamic2.__doc__ is None)
+
def lists():
if verbose: print "Testing list operations..."
***************
*** 2169,2173 ****
else:
return I(pow(int(other), int(self), int(mod)))
!
vereq(`I(1) + I(2)`, "I(3)")
vereq(`I(1) + 2`, "I(3)")
--- 2201,2205 ----
else:
return I(pow(int(other), int(self), int(mod)))
!
vereq(`I(1) + I(2)`, "I(3)")
vereq(`I(1) + 2`, "I(3)")
***************
*** 2183,2186 ****
--- 2215,2219 ----
def test_main():
+ class_docstrings()
lists()
dicts()
Index: test_doctest2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest2.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** test_doctest2.py 2001/10/03 04:15:28 1.2
--- test_doctest2.py 2001/10/04 05:27:00 1.3
***************
*** 8,12 ****
import test_support
- # XXX The class docstring is skipped.
class C(object):
"""Class C.
--- 8,11 ----
***************
*** 30,34 ****
return "42"
- # XXX The class docstring is skipped.
class D(object):
"""A nested D class.
--- 29,32 ----
***************
*** 97,103 ****
def test_main():
import test_doctest2
! # XXX 2 class docstrings are skipped.
! # EXPECTED = 19
! EXPECTED = 17
f, t = test_support.run_doctest(test_doctest2)
if t != EXPECTED:
--- 95,99 ----
def test_main():
import test_doctest2
! EXPECTED = 19
f, t = test_support.run_doctest(test_doctest2)
if t != EXPECTED: