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

Method test_methods_in_c

Lib/test/test_descr.py:2168–2188  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2166
2167 @support.impl_detail("testing error message from implementation")
2168 def test_methods_in_c(self):
2169 # This test checks error messages in builtin method descriptor.
2170 # It is allowed that other Python implementations use
2171 # different error messages.
2172 set_add = set.add
2173
2174 expected_errmsg = "unbound method set.add() needs an argument"
2175
2176 with self.assertRaises(TypeError) as cm:
2177 set_add()
2178 self.assertEqual(cm.exception.args[0], expected_errmsg)
2179
2180 expected_errmsg = "descriptor 'add' for 'set' objects doesn't apply to a 'int' object"
2181
2182 with self.assertRaises(TypeError) as cm:
2183 set_add(0)
2184 self.assertEqual(cm.exception.args[0], expected_errmsg)
2185
2186 with self.assertRaises(TypeError) as cm:
2187 set_add.__get__(0)
2188 self.assertEqual(cm.exception.args[0], expected_errmsg)
2189
2190 def test_special_method_lookup(self):
2191 # The lookup of special methods bypasses __getattr__ and

Callers

nothing calls this directly

Calls 3

assertRaisesMethod · 0.45
assertEqualMethod · 0.45
__get__Method · 0.45

Tested by

no test coverage detected