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

Method test_recursive_set

Lib/test/pickletester.py:2790–2812  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2788 self._test_recursive_tuple_and_dict_key(REX_seven, asdict=lambda x: x.table)
2789
2790 def test_recursive_set(self):
2791 if self.py_version < (3, 4):
2792 self.skipTest('not supported in Python < 3.4')
2793 # Set containing an immutable object containing the original set.
2794 y = set()
2795 y.add(K(y))
2796 for proto in range(4, pickle.HIGHEST_PROTOCOL + 1):
2797 s = self.dumps(y, proto)
2798 x = self.loads(s)
2799 self.assertIsInstance(x, set)
2800 self.assertEqual(len(x), 1)
2801 self.assertIsInstance(list(x)[0], K)
2802 self.assertIs(list(x)[0].value, x)
2803
2804 # Immutable object containing a set containing the original object.
2805 y, = y
2806 for proto in range(4, pickle.HIGHEST_PROTOCOL + 1):
2807 s = self.dumps(y, proto)
2808 x = self.loads(s)
2809 self.assertIsInstance(x, K)
2810 self.assertIsInstance(x.value, set)
2811 self.assertEqual(len(x.value), 1)
2812 self.assertIs(list(x.value)[0], x)
2813
2814 def test_recursive_inst(self):
2815 # Mutable object containing itself.

Callers

nothing calls this directly

Calls 10

setFunction · 0.85
listClass · 0.85
skipTestMethod · 0.80
assertIsInstanceMethod · 0.80
KClass · 0.70
addMethod · 0.45
dumpsMethod · 0.45
loadsMethod · 0.45
assertEqualMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected