MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_methods_in_c

Method test_methods_in_c

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

Source from the content-addressed store, hash-verified

2069
2070 @support.impl_detail("testing error message from implementation")
2071 def test_methods_in_c(self):
2072 # This test checks error messages in builtin method descriptor.
2073 # It is allowed that other Python implementations use
2074 # different error messages.
2075 set_add = set.add
2076
2077 expected_errmsg = "unbound method set.add() needs an argument"
2078
2079 with self.assertRaises(TypeError) as cm:
2080 set_add()
2081 self.assertEqual(cm.exception.args[0], expected_errmsg)
2082
2083 expected_errmsg = "descriptor 'add' for 'set' objects doesn't apply to a 'int' object"
2084
2085 with self.assertRaises(TypeError) as cm:
2086 set_add(0)
2087 self.assertEqual(cm.exception.args[0], expected_errmsg)
2088
2089 with self.assertRaises(TypeError) as cm:
2090 set_add.__get__(0)
2091 self.assertEqual(cm.exception.args[0], expected_errmsg)
2092
2093 @unittest.expectedFailure # TODO: RUSTPYTHON
2094 def test_special_method_lookup(self):

Callers

nothing calls this directly

Calls 3

assertRaisesMethod · 0.45
assertEqualMethod · 0.45
__get__Method · 0.45

Tested by

no test coverage detected