Close #14136 by cleaning up the PEP 409 command line test (patch by Ethan Furman)

This commit is contained in:
Nick Coghlan 2012-05-21 23:03:30 +10:00
parent 3267a30de1
commit 1d5ccdb24d
2 changed files with 20 additions and 52 deletions

View file

@ -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()