From 6770b450b326e7fba49f25f7b19706ee7eff0cee Mon Sep 17 00:00:00 2001 From: Ivanq Date: Tue, 13 Oct 2020 19:50:08 +0300 Subject: [PATCH] Handle src/gevent/... paths --- src/Debug/Debug.py | 6 +++++- src/Test/TestDebug.py | 11 ++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Debug/Debug.py b/src/Debug/Debug.py index dec07919..e6cf28a9 100644 --- a/src/Debug/Debug.py +++ b/src/Debug/Debug.py @@ -47,7 +47,11 @@ def formatTraceback(items, limit=None, fold_builtin=True): is_last = i == len(items) path = path.replace("\\", "/") - if path in ("", ""): + if path.startswith("src/gevent/"): + file_title = "/" + path[len("src/gevent/"):] + is_builtin = True + is_skippable_builtin = False + elif path in ("", ""): file_title = "(importlib)" is_builtin = True is_skippable_builtin = True diff --git a/src/Test/TestDebug.py b/src/Test/TestDebug.py index 695a81a9..f65c13d9 100644 --- a/src/Test/TestDebug.py +++ b/src/Test/TestDebug.py @@ -19,11 +19,12 @@ class TestDebug: (["C:\\ZeroNet\\core\\src\\main.py:13"], ["?/src/main.py line 13"]), (["/root/main.py:17"], ["/root/main.py line 17"]), (["{gevent}:13"], ["/__init__.py line 13"]), # modules - (["{os}:13"], [" line 13"]), # python builtin modules, + (["{os}:13"], [" line 13"]), # python builtin modules + (["src/gevent/event.py:17"], ["/event.py line 17"]), # gevent-overriden __file__ (["@/src/Db/Db.py:17", "@/src/Db/DbQuery.py:1"], ["Db.py line 17", "DbQuery.py line 1"]), # mutliple args (["@/src/Db/Db.py:17", "@/src/Db/Db.py:1"], ["Db.py line 17", "1"]), # same file (["{os}:1", "@/src/Db/Db.py:17"], [" line 1", "Db.py line 17"]), # builtins - (["{gevent}:1"] + ["{os}:3"] * 4 + ["@/src/Db/Db.py:17"], ["/__init__.py line 1", "...", "Db.py line 17"]), + (["{gevent}:1"] + ["{os}:3"] * 4 + ["@/src/Db/Db.py:17"], ["/__init__.py line 1", "...", "Db.py line 17"]) ]) def testFormatTraceback(self, items, expected): q_items = [] @@ -41,12 +42,12 @@ class TestDebug: try: raise ValueError("Test exception") except: - assert Debug.formatException() == "ValueError: Test exception in TestDebug.py line 42" + assert Debug.formatException() == "ValueError: Test exception in TestDebug.py line 43" try: os.path.abspath(1) except: - assert Debug.formatException().startswith("TypeError: expected str, bytes or os.PathLike object, not int in TestDebug.py line 46 > line ") + assert Debug.formatException().startswith("TypeError: expected str, bytes or os.PathLike object, not int in TestDebug.py line 47 > line ") def testFormatStack(self): - assert Debug.formatStack().startswith("TestDebug.py line 52 > <_pytest>/python.py line ") \ No newline at end of file + assert Debug.formatStack().startswith("TestDebug.py line 53 > <_pytest>/python.py line ") \ No newline at end of file