From 7fccd4a00e8f9b4b76e59df68f30fd2ac0315c0d Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 30 Oct 2011 22:31:27 -0400 Subject: Make execution with -m match Python more closely. --- coverage/execfile.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'coverage/execfile.py') diff --git a/coverage/execfile.py b/coverage/execfile.py index 71227b71..1c0048ff 100644 --- a/coverage/execfile.py +++ b/coverage/execfile.py @@ -65,6 +65,7 @@ def run_python_module(modulename, args): openfile.close() # Finally, hand the file off to run_python_file for execution. + args[0] = pathname run_python_file(pathname, args, package=packagename) @@ -89,7 +90,10 @@ def run_python_file(filename, args, package=None): old_argv = sys.argv old_path0 = sys.path[0] sys.argv = args - sys.path[0] = os.path.abspath(os.path.dirname(filename)) + if package: + sys.path[0] = '' + else: + sys.path[0] = os.path.abspath(os.path.dirname(filename)) try: # Open the source file. -- cgit v1.2.1