[tor-commits] [stem/master] Print full stacktrace when a test fails to import
atagar at torproject.org
atagar at torproject.org
Mon Feb 26 01:35:58 UTC 2018
commit b005d31362ddf6ba0d87d26482a596cf4a3dd475
Author: Damian Johnson <atagar at torproject.org>
Date: Sun Feb 25 16:16:16 2018 -0800
Print full stacktrace when a test fails to import
Our tests preemptively import test modules so asynchronous tasks can register
themselves. However, an import raises an exception then we only printed the
error message, not the stacktrace complicating troubleshooting.
---
test/task.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/test/task.py b/test/task.py
index 20841be5..b28833bd 100644
--- a/test/task.py
+++ b/test/task.py
@@ -26,6 +26,7 @@ import os
import re
import sys
import time
+import traceback
import stem
import stem.prereq
@@ -92,7 +93,10 @@ def _import_tests():
return
for module in (CONFIG['test.unit_tests'].splitlines() + CONFIG['test.integ_tests'].splitlines()):
- importlib.import_module(module.rsplit('.', 1)[0])
+ try:
+ importlib.import_module(module.rsplit('.', 1)[0])
+ except Exception as exc:
+ raise ImportError(traceback.format_exc())
def _check_for_unused_tests(paths):
More information about the tor-commits
mailing list