summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cmd_line_script.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2012-05-21 13:03:30 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2012-05-21 13:03:30 (GMT)
commit1d5ccdb24db4581a677e1db84b8a0f356094740f (patch)
tree36bebc6f1d5a3ec7cdf5b8b9b87a8bc0563ac52e /Lib/test/test_cmd_line_script.py
parent3267a30de12724971bd7e7b9262e19c1d9b2becd (diff)
downloadcpython-1d5ccdb24db4581a677e1db84b8a0f356094740f.zip
cpython-1d5ccdb24db4581a677e1db84b8a0f356094740f.tar.gz
cpython-1d5ccdb24db4581a677e1db84b8a0f356094740f.tar.bz2
Close #14136 by cleaning up the PEP 409 command line test (patch by Ethan Furman)
Diffstat (limited to 'Lib/test/test_cmd_line_script.py')
-rw-r--r--Lib/test/test_cmd_line_script.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py
index 155aafc..83aa163 100644
--- a/Lib/test/test_cmd_line_script.py
+++ b/Lib/test/test_cmd_line_script.py
@@ -7,6 +7,7 @@ import os
import os.path
import py_compile
+import textwrap
from test import support
from test.script_helper import (
make_pkg, make_script, make_zip_pkg, make_zip_script,
@@ -286,6 +287,24 @@ class CmdLineTest(unittest.TestCase):
self._check_output(script_name, rc, out,
script_name, script_name, '', '')
+ def test_pep_409_verbiage(self):
+ # Make sure PEP 409 syntax properly suppresses
+ # the context of an exception
+ script = textwrap.dedent("""\
+ try:
+ raise ValueError
+ except:
+ raise NameError from None
+ """)
+ with temp_dir() as script_dir:
+ script_name = _make_test_script(script_dir, 'script', script)
+ exitcode, stdout, stderr = assert_python_failure(script_name)
+ text = stderr.decode('ascii').split('\n')
+ self.assertEqual(len(text), 4)
+ self.assertTrue(text[0].startswith('Traceback'))
+ self.assertTrue(text[1].startswith(' File '))
+ self.assertTrue(text[3].startswith('NameError'))
+
def test_main():
support.run_unittest(CmdLineTest)
support.reap_children()