bobber6467 / python-nose

Automatically exported from code.google.com/p/python-nose
0 stars 0 forks source link

ImportError masked by AttributeError #454

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
If a module has import error, the ImportError is masked by AttributeError.

There is a small change that can be done in util.py to trigger the ImportError

Instead of 

    log.debug("resolve: %s, %s, %s, %s", parts, name, obj, module)
    for part in parts:
        obj = getattr(obj, part)
    return obj

it can use:

    log.debug("resolve: %s, %s, %s, %s", parts, name, obj, module)
    for part in parts:
        try:
            obj = getattr(obj, part)
        except AttributeError:
            # Try to import the module so that we can see the import error.
            __import__(obj.__name__ + '.' + part)
    return obj

This should also help with issue #368

---- 
I can also submit a patch if required

Original issue reported on code.google.com by adiroi...@gmail.com on 9 Sep 2011 at 12:46