Skip to content

Commit 966b51c

Browse files
committed
Remove graalpytest caller frame from printed tracebacks
1 parent 3daab4e commit 966b51c

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

graalpython/com.oracle.graal.python.test/src/graalpytest.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,11 @@ def test_modules(self):
742742
def load_conftest(self, testfile):
743743
self.load_module(testfile)
744744

745+
def trim_traceback(self, tb):
746+
if tb and tb.tb_frame.f_code is TestCase.run_safely.__code__:
747+
return tb.tb_next
748+
return tb
749+
745750
def run(self):
746751
# eval session scope
747752
eval_scope("session")
@@ -783,14 +788,12 @@ def run(self):
783788
for e in self.exceptions:
784789
msg, exc = e
785790
print(msg)
786-
if verbose:
787-
try:
788-
import traceback
789-
traceback.print_exception(type(exc), exc, exc.__traceback__)
790-
except Exception:
791-
pass
792-
else:
793-
print(exc)
791+
try:
792+
import traceback
793+
traceback.print_exception(type(exc), exc, self.trim_traceback(exc.__traceback__))
794+
print()
795+
except Exception:
796+
pass
794797

795798
if self.exceptions or self.failed:
796799
_cleanup_tempdirs()

0 commit comments

Comments
 (0)