diff options
author | Martin Panter <vadmium+py@gmail.com> | 2015-12-10 06:47:06 +0000 |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2015-12-10 06:47:06 +0000 |
commit | 7dda421bfff887da9a84e99c37ef1b0ef9f3cde9 (patch) | |
tree | e39c07f91360571424cb92263f3f34434c974ec4 /Lib/test/test_runpy.py | |
parent | a29eb08fb97fff461b62682da4ee9ac6ea8db5bf (diff) | |
download | cpython-git-7dda421bfff887da9a84e99c37ef1b0ef9f3cde9.tar.gz |
Issue #14285: Do not catch exceptions initializing any ancestor package
The previous fix only handled the case of the parent package of __main__
failing to initialize.
Also make the "Error while finding spec" formatting slightly more appealing,
and document and test that the module name must be absolute.
Diffstat (limited to 'Lib/test/test_runpy.py')
-rw-r--r-- | Lib/test/test_runpy.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py index 01f6abd8c5..87c83ecfae 100644 --- a/Lib/test/test_runpy.py +++ b/Lib/test/test_runpy.py @@ -197,8 +197,11 @@ class RunModuleTestCase(unittest.TestCase, CodeExecutionMixin): self.expect_import_error("sys.imp.eric") self.expect_import_error("os.path.half") self.expect_import_error("a.bee") + # Relative names not allowed self.expect_import_error(".howard") self.expect_import_error("..eaten") + self.expect_import_error(".test_runpy") + self.expect_import_error(".unittest") # Package without __main__.py self.expect_import_error("multiprocessing") @@ -460,6 +463,12 @@ from ..uncle.cousin import nephew self.assertNotIn("finding spec", format(err)) else: self.fail("Nothing raised; expected {}".format(name)) + try: + run_module(mod_name + ".submodule") + except exception as err: + self.assertNotIn("finding spec", format(err)) + else: + self.fail("Nothing raised; expected {}".format(name)) def test_run_package_in_namespace_package(self): for depth in range(1, 4): |