Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_cmd_line_script.py @ 77946:fcbd3bda7c0f 3.2
Fix issue # 15033 - Return the proper exitcode for failure when modules are invoked using -m switch. Patch contributed by Jeff Knupp
| author | Senthil Kumaran <senthil@uthcode.com> |
|---|---|
| date | Wed, 04 Jul 2012 19:28:16 -0700 |
| parents | 22f0044ea366 |
| children | 41658a4fb3cc 1186d68715cc |
line wrap: on
line diff
--- a/Lib/test/test_cmd_line_script.py Tue Jul 03 13:15:03 2012 +0200 +++ b/Lib/test/test_cmd_line_script.py Wed Jul 04 19:28:16 2012 -0700 @@ -279,6 +279,21 @@ 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_main(): support.run_unittest(CmdLineTest) support.reap_children()
