summaryrefslogtreecommitdiff
path: root/Lib/test/test_cmd_line_script.py
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2020-03-31 12:23:55 +0100
committerGitHub <noreply@github.com>2020-03-31 12:23:55 +0100
commitef67512b40240f765026ad41d60b0c9a6dacd2b9 (patch)
tree4cd0562ba5495f96213587b6bd2caeebd906b481 /Lib/test/test_cmd_line_script.py
parentc49016e67c3255b37599b354a8d7995d40663991 (diff)
downloadcpython-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.py10
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