[issue7559] TestLoader.loadTestsFromName swallows import errors
Chris Jerdonek
report at bugs.python.org
Fri Apr 9 13:15:11 CEST 2010
Chris Jerdonek <chris.jerdonek at gmail.com> added the comment:
Thanks for your suggestions on the test code. I will do that.
It seems like the hard-coded approach would be more brittle. For example, if someone wants to replace __import__ with their own, e.g.
old__import__ = __builtins__.__import__
def __my_logging_import(*args, **kwargs):
print "Importing %s..." % args[0] # module name
return old__import__(*args, **kwargs)
__builtins__.__import__ = __my_logging_import
Then the stack traces would be different:
File "/Users/chris_g4/dev/Python/trunk/Lib/unittest/loader.py", line 92, in loadTestsFromName
module = __import__('.'.join(parts_copy))
File "unittests.py", line 8, in __my_logging_import
return old__import__(*args, **kwargs)
ImportError: No module named sdasfasfasdf
This causes the unit tests not to pass.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7559>
_______________________________________
More information about the Python-bugs-list
mailing list