From b3ccb75241566c1e1a814ae99a84637fd0ac2b44 Mon Sep 17 00:00:00 2001 From: Buck Golemon Date: Sat, 15 Nov 2014 14:01:06 -0800 Subject: add necessary tests, fix attrname, once it was shown to fail --HG-- branch : __main__-support --- coverage/control.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'coverage/control.py') diff --git a/coverage/control.py b/coverage/control.py index 6a136da4..e568f643 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) -- cgit v1.2.1