MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_readonly

Method test_readonly

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

Source from the content-addressed store, hash-verified

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