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

Method test_large_size

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

Source from the content-addressed store, hash-verified

545
546 @support.requires_resource('cpu')
547 def test_large_size(self):
548 n = support.exceeds_recursion_limit()
549 names = list(set(''.join([choice(string.ascii_letters)
550 for j in range(10)]) for i in range(n)))
551 n = len(names)
552 Big = namedtuple('Big', names)
553 b = Big(*range(n))
554 self.assertEqual(b, tuple(range(n)))
555 self.assertEqual(Big._make(range(n)), tuple(range(n)))
556 for pos, name in enumerate(names):
557 self.assertEqual(getattr(b, name), pos)
558 repr(b) # make sure repr() doesn't blow-up
559 d = b._asdict()
560 d_expected = dict(zip(names, range(n)))
561 self.assertEqual(d, d_expected)
562 b2 = b._replace(**dict([(names[1], 999),(names[-5], 42)]))
563 b2_expected = list(range(n))
564 b2_expected[1] = 999
565 b2_expected[-5] = 42
566 self.assertEqual(b2, tuple(b2_expected))
567 self.assertEqual(b._fields, tuple(names))
568
569 def test_pickle(self):
570 p = TestNT(x=10, y=20, z=30)

Callers

nothing calls this directly

Calls 10

namedtupleFunction · 0.90
listClass · 0.85
setFunction · 0.85
choiceFunction · 0.85
BigClass · 0.85
enumerateFunction · 0.85
joinMethod · 0.45
assertEqualMethod · 0.45
_makeMethod · 0.45
_replaceMethod · 0.45

Tested by

no test coverage detected