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

Method test_add

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

Source from the content-addressed store, hash-verified

149 # CRASHES: contains(NULL, NULL)
150
151 def test_add(self):
152 add = _testlimitedcapi.set_add
153 for cls in (set, set_subclass):
154 with self.subTest(cls=cls):
155 instance = cls((1, 2))
156 self.assertEqual(add(instance, 1), 0)
157 self.assertEqual(instance, {1, 2})
158 self.assertEqual(add(instance, 3), 0)
159 self.assertEqual(instance, {1, 2, 3})
160 with self.assertRaisesRegex(TypeError, "unhashable type: 'list'"):
161 add(instance, [])
162 with self.assertRaises(SystemError):
163 add(object(), 1)
164 self.assertImmutable(add, 1)
165 # CRASHES: add(NULL, object())
166 # CRASHES: add(instance, NULL)
167 # CRASHES: add(NULL, NULL)
168
169 def test_add_frozenset(self):
170 add = _testlimitedcapi.set_add

Callers

nothing calls this directly

Calls 7

assertRaisesRegexMethod · 0.80
assertImmutableMethod · 0.80
clsClass · 0.50
addFunction · 0.50
subTestMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected