diff options
| author | Pablo Galindo <Pablogsal@gmail.com> | 2020-03-31 12:23:55 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-31 12:23:55 +0100 |
| commit | ef67512b40240f765026ad41d60b0c9a6dacd2b9 (patch) | |
| tree | 4cd0562ba5495f96213587b6bd2caeebd906b481 /Lib/test/test_cmd_line_script.py | |
| parent | c49016e67c3255b37599b354a8d7995d40663991 (diff) | |
| download | cpython-git-ef67512b40240f765026ad41d60b0c9a6dacd2b9.tar.gz | |
bpo-40108: Improve the error message in runpy when importing a module that includes the extension (GH-19239)
Diffstat (limited to 'Lib/test/test_cmd_line_script.py')
| -rw-r--r-- | Lib/test/test_cmd_line_script.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py index adfb8ce5ed..44a5487d75 100644 --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -499,6 +499,16 @@ class CmdLineTest(unittest.TestCase): self.assertNotIn(b'is a package', err) self.assertNotIn(b'Traceback', err) + def test_hint_when_triying_to_import_a_py_file(self): + with support.temp_dir() as script_dir, \ + support.change_cwd(path=script_dir): + # Create invalid *.pyc as empty file + with open('asyncio.py', 'wb'): + pass + err = self.check_dash_m_failure('asyncio.py') + self.assertIn(b"Try using 'asyncio' instead " + b"of 'asyncio.py' as the module name", err) + def test_dash_m_init_traceback(self): # These were wrapped in an ImportError and tracebacks were # suppressed; see Issue 14285 |
