summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_raise.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_raise.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_raise.py')
-rw-r--r--Lib/test/test_raise.py53
1 files changed, 1 insertions, 52 deletions
diff --git a/Lib/test/test_raise.py b/Lib/test/test_raise.py
index b169867..be5c1c6 100644
--- a/Lib/test/test_raise.py
+++ b/Lib/test/test_raise.py
@@ -3,27 +3,13 @@
"""Tests for the raise statement."""
-from test import support, script_helper
+from test import support
import re
import sys
import types
import unittest
-try:
- from resource import setrlimit, RLIMIT_CORE, error as resource_error
-except ImportError:
- prepare_subprocess = None
-else:
- def prepare_subprocess():
- # don't create core file
- try:
- setrlimit(RLIMIT_CORE, (0, 0))
- except (ValueError, resource_error):
- pass
-
-
-
def get_tb():
try:
raise OSError()
@@ -224,43 +210,6 @@ class TestCause(unittest.TestCase):
class TestTraceback(unittest.TestCase):
- def get_output(self, code, filename=None):
- """
- Run the specified code in Python (in a new child process) and read the
- output from the standard error or from a file (if filename is set).
- Return the output lines as a list.
- """
- options = {}
- if prepare_subprocess:
- options['preexec_fn'] = prepare_subprocess
- process = script_helper.spawn_python('-c', code, **options)
- stdout, stderr = process.communicate()
- exitcode = process.wait()
- output = support.strip_python_stderr(stdout)
- output = output.decode('ascii', 'backslashreplace')
- if filename:
- self.assertEqual(output, '')
- with open(filename, "rb") as fp:
- output = fp.read()
- output = output.decode('ascii', 'backslashreplace')
- output = re.sub('Current thread 0x[0-9a-f]+',
- 'Current thread XXX',
- output)
- return output.splitlines(), exitcode
-
- def test_traceback_verbiage(self):
- code = """
-try:
- raise ValueError
-except:
- raise NameError from None
-"""
- text, exitcode = self.get_output(code)
- self.assertEqual(len(text), 3)
- self.assertTrue(text[0].startswith('Traceback'))
- self.assertTrue(text[1].startswith(' File '))
- self.assertTrue(text[2].startswith('NameError'))
-
def test_sets_traceback(self):
try:
raise IndexError()