From 14313ee41e96a5480834ce651ecb3f4b31a4db88 Mon Sep 17 00:00:00 2001 From: joncrall Date: Sun, 2 Jun 2024 15:19:53 -0400 Subject: [PATCH] Better error message --- src/xdoctest/utils/util_import.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/xdoctest/utils/util_import.py b/src/xdoctest/utils/util_import.py index 10c99a5..43a44c8 100644 --- a/src/xdoctest/utils/util_import.py +++ b/src/xdoctest/utils/util_import.py @@ -180,9 +180,10 @@ def _custom_import_modpath(modpath, index=-1): with PythonPathContext(dpath, index=index): module = import_module_from_name(modname) except Exception as ex: # nocover - msg_parts = [ - 'ERROR: Failed to import modname={} with modpath={}'.format( - modname, modpath) + msg_parts = [( + 'ERROR: Failed to import modname={} with modpath={} and ' + 'sys.path modified with {} at index={}').format( + modname, modpath, repr(dpath), index) ] msg_parts.append('Caused by: {}'.format(repr(ex))) raise RuntimeError('\n'.join(msg_parts))