summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cmd_line_script.py
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2012-07-05 02:33:45 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2012-07-05 02:33:45 (GMT)
commitf28fbabc7fa7cf1c4880ce39b507f600def35439 (patch)
tree80fb013697540a163409e6c972f35a38d309aaa4 /Lib/test/test_cmd_line_script.py
parent53089c6e91f6152bc43776587e82a0bbeb574fe0 (diff)
parentf01a337950bdcd6905d12b2335ba4d8773f6b8e5 (diff)
downloadcpython-f28fbabc7fa7cf1c4880ce39b507f600def35439.zip
cpython-f28fbabc7fa7cf1c4880ce39b507f600def35439.tar.gz
cpython-f28fbabc7fa7cf1c4880ce39b507f600def35439.tar.bz2
Fix issue # 15033 - Return the proper exitcode for failure when modules are invoked using -m switch. Patch contributed by Jeff Knupp
Diffstat (limited to 'Lib/test/test_cmd_line_script.py')
-rw-r--r--Lib/test/test_cmd_line_script.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py
index 83aa163..d8bc263 100644
--- a/Lib/test/test_cmd_line_script.py
+++ b/Lib/test/test_cmd_line_script.py
@@ -287,6 +287,21 @@ class CmdLineTest(unittest.TestCase):
self._check_output(script_name, rc, out,
script_name, script_name, '', '')
+ def test_dash_m_error_code_is_one(self):
+ # If a module is invoked with the -m command line flag
+ # and results in an error that the return code to the
+ # shell is '1'
+ with temp_dir() as script_dir:
+ with support.temp_cwd(path=script_dir):
+ pkg_dir = os.path.join(script_dir, 'test_pkg')
+ make_pkg(pkg_dir)
+ script_name = _make_test_script(pkg_dir, 'other',
+ "if __name__ == '__main__': raise ValueError")
+ rc, out, err = assert_python_failure('-m', 'test_pkg.other', *example_args)
+ if verbose > 1:
+ print(out)
+ self.assertEqual(rc, 1)
+
def test_pep_409_verbiage(self):
# Make sure PEP 409 syntax properly suppresses
# the context of an exception