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

Method test_handle_repr

Lib/test/test_asyncio/test_events.py:2427–2472  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2425 wd['h'] = h # Would fail without __weakref__ slot.
2426
2427 def test_handle_repr(self):
2428 self.loop.get_debug.return_value = False
2429
2430 # simple function
2431 h = asyncio.Handle(noop, (1, 2), self.loop)
2432 filename, lineno = test_utils.get_function_source(noop)
2433 self.assertEqual(repr(h),
2434 '<Handle noop() at %s:%s>'
2435 % (filename, lineno))
2436
2437 # cancelled handle
2438 h.cancel()
2439 self.assertEqual(repr(h),
2440 '<Handle cancelled>')
2441
2442 # decorated function
2443 cb = types.coroutine(noop)
2444 h = asyncio.Handle(cb, (), self.loop)
2445 self.assertEqual(repr(h),
2446 '<Handle noop() at %s:%s>'
2447 % (filename, lineno))
2448
2449 # partial function
2450 cb = functools.partial(noop, 1, 2)
2451 h = asyncio.Handle(cb, (3,), self.loop)
2452 regex = (r'^<Handle noop\(\)\(\) at %s:%s>$'
2453 % (re.escape(filename), lineno))
2454 self.assertRegex(repr(h), regex)
2455
2456 # partial function with keyword args
2457 cb = functools.partial(noop, x=1)
2458 h = asyncio.Handle(cb, (2, 3), self.loop)
2459 regex = (r'^<Handle noop\(\)\(\) at %s:%s>$'
2460 % (re.escape(filename), lineno))
2461 self.assertRegex(repr(h), regex)
2462
2463 # partial method
2464 method = HandleTests.test_handle_repr
2465 cb = functools.partialmethod(method)
2466 filename, lineno = test_utils.get_function_source(method)
2467 h = asyncio.Handle(cb, (), self.loop)
2468
2469 cb_regex = r'<function HandleTests.test_handle_repr .*>'
2470 cb_regex = fr'functools.partialmethod\({cb_regex}\)\(\)'
2471 regex = fr'^<Handle {cb_regex} at {re.escape(filename)}:{lineno}>$'
2472 self.assertRegex(repr(h), regex)
2473
2474 def test_handle_repr_debug(self):
2475 self.loop.get_debug.return_value = True

Callers

nothing calls this directly

Calls 7

cancelMethod · 0.95
reprFunction · 0.85
partialMethod · 0.80
escapeMethod · 0.80
assertRegexMethod · 0.80
assertEqualMethod · 0.45
coroutineMethod · 0.45

Tested by

no test coverage detected