From: R David Murray Date: Sat, 27 Oct 2012 18:55:25 +0000 (-0400) Subject: merge #12890: don't emit

tags in text mode when logdir specified. X-Git-Tag: v3.3.1rc1~737 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c4b8e05092b5aa018dd74f8563037b23d3c6756e;p=python merge #12890: don't emit

tags in text mode when logdir specified. Patch by Jeff McNeil. --- c4b8e05092b5aa018dd74f8563037b23d3c6756e diff --cc Lib/test/test_cgitb.py index 16a4b1a034,0000000000..4017772d03 mode 100644,000000..100644 --- a/Lib/test/test_cgitb.py +++ b/Lib/test/test_cgitb.py @@@ -1,55 -1,0 +1,72 @@@ +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): + + def test_fonts(self): + text = "Hello Robbie!" + self.assertEqual(cgitb.small(text), "{}".format(text)) + self.assertEqual(cgitb.strong(text), "{}".format(text)) + self.assertEqual(cgitb.grey(text), + '{}'.format(text)) + + def test_blanks(self): + self.assertEqual(cgitb.small(""), "") + self.assertEqual(cgitb.strong(""), "") + self.assertEqual(cgitb.grey(""), "") + + def test_html(self): + try: + raise ValueError("Hello World") + except ValueError as err: + # If the html was templated we could do a bit more here. + # At least check that we get details on what we just raised. + html = cgitb.html(sys.exc_info()) + self.assertIn("ValueError", html) + self.assertIn(str(err), html) + + def test_text(self): + try: + raise ValueError("Hello World") + except ValueError as err: + text = cgitb.text(sys.exc_info()) + 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('

', out) ++ self.assertIn('

', out) ++ ++ def test_syshook_no_logdir_text_format(self): ++ # Issue 12890: we were emitting the

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('

', out) ++ self.assertNotIn('

', out) + + +def test_main(): + run_unittest(TestCgitb) + +if __name__ == "__main__": + test_main() diff --cc Misc/ACKS index ac44ae8126,2b97f51a37..3966ba67cc --- a/Misc/ACKS +++ b/Misc/ACKS @@@ -767,8 -697,9 +767,9 @@@ Alan McIntyr Michael McLay Mark Mc Mahon Gordon McMillan -Caolan McNamara Andrew McNamara +Caolan McNamara + Jeff McNeil Craig McPheeters Lambert Meertens Bill van Melle diff --cc Misc/NEWS index 9766633f7c,5010f70bd5..ba555bb5ff --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -49,15 -132,13 +49,18 @@@ Core and Builtin Library ------- + - Issue #12890: cgitb no longer prints spurious

tags in text + mode when the logdir option is specified. + +- Issue #16307: Fix multiprocessing.Pool.map_async not calling its callbacks. + Patch by Janne Karila. + - Issue #16250: Fix URLError invocation with proper args. -- Issue #16305: Fix a segmentation fault occurring when interrupting - math.factorial. +- Issue #16116: Fix include and library paths to be correct when building C + extensions in venvs. + +- Issue #16245: Fix the value of a few entities in html.entities.html5. - Issue #14398: Fix size truncation and overflow bugs in the bz2 module.