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

Method test_set_update

Lib/test/test_capi/test_set.py:230–252  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

228
229class TestInternalCAPI(BaseSetTests, unittest.TestCase):
230 def test_set_update(self):
231 update = _testinternalcapi.set_update
232 for cls in (set, set_subclass):
233 for it in ('ab', ('a', 'b'), ['a', 'b'],
234 set('ab'), set_subclass('ab'),
235 frozenset('ab'), frozenset_subclass('ab')):
236 with self.subTest(cls=cls, it=it):
237 instance = cls()
238 self.assertEqual(update(instance, it), 0)
239 self.assertEqual(instance, {'a', 'b'})
240 instance = cls(it)
241 self.assertEqual(update(instance, it), 0)
242 self.assertEqual(instance, {'a', 'b'})
243 with self.assertRaisesRegex(TypeError, 'object is not iterable'):
244 update(cls(), 1)
245 with self.assertRaisesRegex(TypeError, "unhashable type: 'dict'"):
246 update(cls(), [{}])
247 with self.assertRaises(SystemError):
248 update(object(), 'ab')
249 self.assertImmutable(update, 'ab')
250 # CRASHES: update(NULL, object())
251 # CRASHES: update(instance, NULL)
252 # CRASHES: update(NULL, NULL)
253
254 def test_set_next_entry(self):
255 set_next = _testinternalcapi.set_next_entry

Callers

nothing calls this directly

Calls 10

setFunction · 0.85
set_subclassClass · 0.85
frozenset_subclassClass · 0.85
updateFunction · 0.85
assertRaisesRegexMethod · 0.80
assertImmutableMethod · 0.80
clsClass · 0.50
subTestMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected