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

Method test_handle_repr_debug

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

Source from the content-addressed store, hash-verified

2469 self.assertRegex(repr(h), regex)
2470
2471 def test_handle_repr_debug(self):
2472 self.loop.get_debug.return_value = True
2473
2474 # simple function
2475 create_filename = __file__
2476 create_lineno = sys._getframe().f_lineno + 1
2477 h = asyncio.Handle(noop, (1, 2), self.loop)
2478 filename, lineno = test_utils.get_function_source(noop)
2479 self.assertEqual(repr(h),
2480 '<Handle noop(1, 2) at %s:%s created at %s:%s>'
2481 % (filename, lineno, create_filename, create_lineno))
2482
2483 # cancelled handle
2484 h.cancel()
2485 self.assertEqual(
2486 repr(h),
2487 '<Handle cancelled noop(1, 2) at %s:%s created at %s:%s>'
2488 % (filename, lineno, create_filename, create_lineno))
2489
2490 # double cancellation won't overwrite _repr
2491 h.cancel()
2492 self.assertEqual(
2493 repr(h),
2494 '<Handle cancelled noop(1, 2) at %s:%s created at %s:%s>'
2495 % (filename, lineno, create_filename, create_lineno))
2496
2497 # partial function
2498 cb = functools.partial(noop, 1, 2)
2499 create_lineno = sys._getframe().f_lineno + 1
2500 h = asyncio.Handle(cb, (3,), self.loop)
2501 regex = (r'^<Handle noop\(1, 2\)\(3\) at %s:%s created at %s:%s>$'
2502 % (re.escape(filename), lineno,
2503 re.escape(create_filename), create_lineno))
2504 self.assertRegex(repr(h), regex)
2505
2506 # partial function with keyword args
2507 cb = functools.partial(noop, x=1)
2508 create_lineno = sys._getframe().f_lineno + 1
2509 h = asyncio.Handle(cb, (2, 3), self.loop)
2510 regex = (r'^<Handle noop\(x=1\)\(2, 3\) at %s:%s created at %s:%s>$'
2511 % (re.escape(filename), lineno,
2512 re.escape(create_filename), create_lineno))
2513 self.assertRegex(repr(h), regex)
2514
2515 def test_handle_source_traceback(self):
2516 loop = asyncio.new_event_loop()

Callers

nothing calls this directly

Calls 5

cancelMethod · 0.95
partialMethod · 0.80
escapeMethod · 0.80
assertRegexMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected