diff options
author | R David Murray <rdmurray@bitdance.com> | 2012-10-27 18:55:25 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2012-10-27 18:55:25 (GMT) |
commit | c4b8e05092b5aa018dd74f8563037b23d3c6756e (patch) | |
tree | ebfe4f6eeaa503b4a2c6783daa7f15ed762c7bd1 /Lib/test/test_cgitb.py | |
parent | 0b3014dda01b6ed3fc805cbfce37a9dc6f0d0fa1 (diff) | |
parent | 252cd0e4e0b11c7d13e24146617ad48e80feca43 (diff) | |
download | cpython-c4b8e05092b5aa018dd74f8563037b23d3c6756e.zip cpython-c4b8e05092b5aa018dd74f8563037b23d3c6756e.tar.gz cpython-c4b8e05092b5aa018dd74f8563037b23d3c6756e.tar.bz2 |
merge #12890: don't emit <p> tags in text mode when logdir specified.
Patch by Jeff McNeil.
Diffstat (limited to 'Lib/test/test_cgitb.py')
-rw-r--r-- | Lib/test/test_cgitb.py | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/Lib/test/test_cgitb.py b/Lib/test/test_cgitb.py index 16a4b1a..4017772 100644 --- a/Lib/test/test_cgitb.py +++ b/Lib/test/test_cgitb.py @@ -1,7 +1,9 @@ from test.support import run_unittest +from test.script_helper import assert_python_failure, temp_dir import unittest import sys import subprocess +import tempfile import cgitb class TestCgitb(unittest.TestCase): @@ -36,16 +38,31 @@ class TestCgitb(unittest.TestCase): self.assertIn("ValueError", text) self.assertIn("Hello World", text) - def test_hook(self): - proc = subprocess.Popen([sys.executable, '-c', - ('import cgitb;' - 'cgitb.enable();' - 'raise ValueError("Hello World")')], - stdout=subprocess.PIPE) - out = proc.stdout.read().decode(sys.getfilesystemencoding()) - self.addCleanup(proc.stdout.close) + def test_syshook_no_logdir_default_format(self): + with temp_dir() as tracedir: + rc, out, err = assert_python_failure( + '-c', + ('import cgitb; cgitb.enable(logdir="%s"); ' + 'raise ValueError("Hello World")') % tracedir) + out = out.decode(sys.getfilesystemencoding()) self.assertIn("ValueError", out) self.assertIn("Hello World", out) + # By default we emit HTML markup. + self.assertIn('<p>', out) + self.assertIn('</p>', out) + + def test_syshook_no_logdir_text_format(self): + # Issue 12890: we were emitting the <p> tag in text mode. + with temp_dir() as tracedir: + rc, out, err = assert_python_failure( + '-c', + ('import cgitb; cgitb.enable(format="text", logdir="%s"); ' + 'raise ValueError("Hello World")') % tracedir) + out = out.decode(sys.getfilesystemencoding()) + self.assertIn("ValueError", out) + self.assertIn("Hello World", out) + self.assertNotIn('<p>', out) + self.assertNotIn('</p>', out) def test_main(): |