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

Method test_meth_class_get

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

Source from the content-addressed store, hash-verified

4371
4372 @support.impl_detail("testing an internal kind of method object")
4373 def test_meth_class_get(self):
4374 # Testing __get__ method of METH_CLASS C methods...
4375 # Full coverage of descrobject.c::classmethod_get()
4376
4377 # Baseline
4378 arg = [1, 2, 3]
4379 res = {1: None, 2: None, 3: None}
4380 self.assertEqual(dict.fromkeys(arg), res)
4381 self.assertEqual({}.fromkeys(arg), res)
4382
4383 # Now get the descriptor
4384 descr = dict.__dict__["fromkeys"]
4385
4386 # More baseline using the descriptor directly
4387 self.assertEqual(descr.__get__(None, dict)(arg), res)
4388 self.assertEqual(descr.__get__({})(arg), res)
4389
4390 # Now check various error cases
4391 try:
4392 descr.__get__(None, None)
4393 except TypeError:
4394 pass
4395 else:
4396 self.fail("shouldn't have allowed descr.__get__(None, None)")
4397 try:
4398 descr.__get__(42)
4399 except TypeError:
4400 pass
4401 else:
4402 self.fail("shouldn't have allowed descr.__get__(42)")
4403 try:
4404 descr.__get__(None, 42)
4405 except TypeError:
4406 pass
4407 else:
4408 self.fail("shouldn't have allowed descr.__get__(None, 42)")
4409 try:
4410 descr.__get__(None, int)
4411 except TypeError:
4412 pass
4413 else:
4414 self.fail("shouldn't have allowed descr.__get__(None, int)")
4415
4416 def test_isinst_isclass(self):
4417 # Testing proxy isinstance() and isclass()...

Callers

nothing calls this directly

Calls 4

assertEqualMethod · 0.45
fromkeysMethod · 0.45
__get__Method · 0.45
failMethod · 0.45

Tested by

no test coverage detected