summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2018-02-26 08:43:58 -0500
committerNed Batchelder <ned@nedbatchelder.com>2018-02-26 08:43:58 -0500
commit74c04a7baac2b987c68ffb2923b287b55e154b5c (patch)
treecb77b23f23b441e1503771e5183f023a9c75e55e
parent3d8463e6a3e53fc2ad7e381f2f0f53d8bfeb7cd4 (diff)
downloadpython-coveragepy-74c04a7baac2b987c68ffb2923b287b55e154b5c.tar.gz
More uniformity
-rw-r--r--coverage/control.py3
-rw-r--r--coverage/inorout.py12
2 files changed, 7 insertions, 8 deletions
diff --git a/coverage/control.py b/coverage/control.py
index 01feef2..346ccf2 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -314,8 +314,7 @@ class Coverage(object):
Returns a boolean: True if the file should be traced, False if not.
"""
- module_globals = frame.f_globals if frame is not None else {}
- reason = self.inorout.check_include_omit_etc(filename, module_globals)
+ reason = self.inorout.check_include_omit_etc(filename, frame)
if self.debug.should('trace'):
if not reason:
msg = "Including %r" % (filename,)
diff --git a/coverage/inorout.py b/coverage/inorout.py
index 4fcec8e..7bb89f1 100644
--- a/coverage/inorout.py
+++ b/coverage/inorout.py
@@ -52,8 +52,8 @@ def canonical_path(morf, directory=False):
return morf_path
-def name_for_module(module_globals, filename):
- """Get the name of the module for a set of globals and file name.
+def name_for_module(filename, frame):
+ """Get the name of the module for a filename and frame.
For configurability's sake, we allow __main__ modules to be matched by
their importable name.
@@ -64,6 +64,7 @@ def name_for_module(module_globals, filename):
can't be determined, None is returned.
"""
+ module_globals = frame.f_globals if frame is not None else {}
if module_globals is None: # pragma: only ironpython
# IronPython doesn't provide globals: https://github.com/IronLanguages/main/issues/1296
module_globals = {}
@@ -273,21 +274,20 @@ class InOrOut(object):
"Plugin %r didn't set source_filename for %r" %
(plugin, disp.original_filename)
)
- module_globals = frame.f_globals if frame is not None else {}
- reason = self.check_include_omit_etc(disp.source_filename, module_globals)
+ reason = self.check_include_omit_etc(disp.source_filename, frame)
if reason:
nope(disp, reason)
return disp
- def check_include_omit_etc(self, filename, module_globals):
+ def check_include_omit_etc(self, filename, frame):
"""Check a file name against the include, omit, etc, rules.
Returns a string or None. String means, don't trace, and is the reason
why. None means no reason found to not trace.
"""
- modulename = name_for_module(module_globals, filename)
+ modulename = name_for_module(filename, frame)
# If the user specified source or include, then that's authoritative
# about the outer bound of what to measure and we don't have to apply