diff options
author | Buck Golemon <buck@yelp.com> | 2014-11-15 14:01:06 -0800 |
---|---|---|
committer | Buck Golemon <buck@yelp.com> | 2014-11-15 14:01:06 -0800 |
commit | 84505f77650e7c62ba47da5c2b93d291885e7a9b (patch) | |
tree | c94534255f2337a3713ce6d657ebe38ff4d6d30e /coverage/control.py | |
parent | f549b24f56fdf2549c3d94635a3783055862e491 (diff) | |
download | python-coveragepy-84505f77650e7c62ba47da5c2b93d291885e7a9b.tar.gz |
add necessary tests, fix attrname, once it was shown to fail
Diffstat (limited to 'coverage/control.py')
-rw-r--r-- | coverage/control.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/coverage/control.py b/coverage/control.py index 6a136da..e568f64 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -322,13 +322,17 @@ class Coverage(object): loader = module_namespace.get('__loader__', None) for attrname in ('fullname', 'name'): # attribute renamed in py3.2 + if hasattr(loader, attrname): + fullname = getattr(loader, attrname) + else: + continue + if ( - hasattr(loader, 'fullname') and - isinstance(loader.fullname, str) and - loader.fullname != '__main__' + isinstance(fullname, str) and + fullname != '__main__' ): # module loaded via runpy -m - return loader.fullname + return fullname # script as first argument to python cli inspectedname = inspect.getmodulename(filename) |