Skip to content

Commit eb117e1

Browse files
committed
Update GoodTests runTests.py from 3.0.4 to 3.0.5 to fix issue in error path (missing dependency) on python2.
1 parent 590918b commit eb117e1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/runTests.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,15 @@ def main(thisDir=None, additionalArgs=[], MY_PACKAGE_MODULE=None, ALLOW_SITE_INS
364364
if baseName.endswith(('.py', '.pyc', '.pyo')):
365365
MY_PACKAGE_MODULE = baseName[ : baseName.rindex('.')]
366366

367-
if e.name != MY_PACKAGE_MODULE:
368-
sys.stderr.write('Error while importing %s: %s\n Likely this is another dependency that needs to be installed\nPerhaps run "pip install %s" or install the providing package.\n\n' %(e.name, str(e), e.name))
367+
try:
368+
eName = e.name
369+
except AttributeError as noNameE:
370+
# Some platforms python2 does not have this attribute
371+
# so pull it from the message
372+
eName = e.message.split()[-1]
373+
374+
if eName != MY_PACKAGE_MODULE:
375+
sys.stderr.write('Error while importing %s: %s\n Likely this is another dependency that needs to be installed\nPerhaps run "pip install %s" or install the providing package.\n\n' %(eName, str(e), eName))
369376
return 1
370377
sys.stderr.write('Could not import %s. Either install it or otherwise add to PYTHONPATH\n%s\n' %(MY_PACKAGE_MODULE, str(e)))
371378
return 1

0 commit comments

Comments
 (0)