MCPcopy Index your code
hub / github.com/python/cpython / test_set_doc

Method test_set_doc

Lib/test/test_descr.py:5157–5170  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5155 self.assertEqual("'foo' in __slots__ conflicts with class variable", m)
5156
5157 def test_set_doc(self):
5158 class X:
5159 "elephant"
5160 X.__doc__ = "banana"
5161 self.assertEqual(X.__doc__, "banana")
5162
5163 with self.assertRaises(TypeError) as cm:
5164 type(list).__dict__["__doc__"].__set__(list, "blah")
5165 self.assertIn("cannot set '__doc__' attribute of immutable type 'list'", str(cm.exception))
5166
5167 with self.assertRaises(TypeError) as cm:
5168 type(X).__dict__["__doc__"].__delete__(X)
5169 self.assertIn("cannot delete '__doc__' attribute of type 'X'", str(cm.exception))
5170 self.assertEqual(X.__doc__, "banana")
5171
5172 def test_qualname(self):
5173 descriptors = [str.lower, complex.real, float.real, int.__add__]

Callers

nothing calls this directly

Calls 6

strFunction · 0.85
assertInMethod · 0.80
assertEqualMethod · 0.45
assertRaisesMethod · 0.45
__set__Method · 0.45
__delete__Method · 0.45

Tested by

no test coverage detected