summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-10-04 05:27:00 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-10-04 05:27:00 (GMT)
commit2f93e28a19e3f250e8c19f9f4334cfa76f5e3645 (patch)
tree22e884413dc23251e95f9737bd9e14daaf43bd0f /Lib/test/test_descr.py
parentf137f75ab82019b7b4db6d45bd69e2c0b155b2eb (diff)
downloadcpython-2f93e28a19e3f250e8c19f9f4334cfa76f5e3645.zip
cpython-2f93e28a19e3f250e8c19f9f4334cfa76f5e3645.tar.gz
cpython-2f93e28a19e3f250e8c19f9f4334cfa76f5e3645.tar.bz2
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*.
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py35
1 files changed, 34 insertions, 1 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 4ed6853..cd65c2c 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -88,6 +88,38 @@ def testset3op(a, b, c, d, res, stmt="a[b:c]=d", meth="__setslice__"):
bm(b, c, d)
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..."
testbinop([1], [2], [1,2], "a+b", "__add__")
@@ -2168,7 +2200,7 @@ def binopoverride():
return I(pow(int(other), int(self), mod))
else:
return I(pow(int(other), int(self), int(mod)))
-
+
vereq(`I(1) + I(2)`, "I(3)")
vereq(`I(1) + 2`, "I(3)")
vereq(`1 + I(2)`, "I(3)")
@@ -2182,6 +2214,7 @@ def binopoverride():
def test_main():
+ class_docstrings()
lists()
dicts()
dict_constructor()