summaryrefslogtreecommitdiff
path: root/Lib/asyncio/test_utils.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-06-12 18:39:26 +0200
committerVictor Stinner <victor.stinner@gmail.com>2014-06-12 18:39:26 +0200
commit307bccc6ff6670c58f4c20421a29071ff710e6a3 (patch)
treee165b2e33505bcece03948112ca230af5d2d2688 /Lib/asyncio/test_utils.py
parentf54432e2a16d445ed6fa142a9c5d8d23b11780b2 (diff)
downloadcpython-git-307bccc6ff6670c58f4c20421a29071ff710e6a3.tar.gz
asyncio: Tulip issue 173: Enhance repr(Handle) and repr(Task)
repr(Handle) is shorter for function: "foo" instead of "<function foo at 0x...>". It now also includes the source of the callback, filename and line number where it was defined, if available. repr(Task) now also includes the current position in the code, filename and line number, if available. If the coroutine (generator) is done, the line number is omitted and "done" is added.
Diffstat (limited to 'Lib/asyncio/test_utils.py')
-rw-r--r--Lib/asyncio/test_utils.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/asyncio/test_utils.py b/Lib/asyncio/test_utils.py
index 9c3656ac2b..1062bae132 100644
--- a/Lib/asyncio/test_utils.py
+++ b/Lib/asyncio/test_utils.py
@@ -372,3 +372,10 @@ class MockPattern(str):
"""
def __eq__(self, other):
return bool(re.search(str(self), other, re.S))
+
+
+def get_function_source(func):
+ source = events._get_function_source(func)
+ if source is None:
+ raise ValueError("unable to get the source of %r" % (func,))
+ return source