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

Method test_readonly

Lib/test/test_collections.py:400–412  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

398 self.assertEqual(Point(), (10, 20))
399
400 def test_readonly(self):
401 Point = namedtuple('Point', 'x y')
402 p = Point(11, 22)
403 with self.assertRaises(AttributeError):
404 p.x = 33
405 with self.assertRaises(AttributeError):
406 del p.x
407 with self.assertRaises(TypeError):
408 p[0] = 33
409 with self.assertRaises(TypeError):
410 del p[0]
411 self.assertEqual(p.x, 11)
412 self.assertEqual(p[0], 11)
413
414 @unittest.skipIf(sys.flags.optimize >= 2,
415 "Docstrings are omitted with -O2 and above")

Callers

nothing calls this directly

Calls 4

namedtupleFunction · 0.90
PointClass · 0.70
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected