Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4)

Side by Side Diff: Lib/test/test_cgitb.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_cgi.py ('k') | Lib/test/test_cmd_line.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 from test.support import run_unittest
2 import unittest
3 import sys
4 import subprocess
5 import cgitb
6
7 class TestCgitb(unittest.TestCase):
8
9 def test_fonts(self):
10 text = "Hello Robbie!"
11 self.assertEqual(cgitb.small(text), "<small>{}</small>".format(text))
12 self.assertEqual(cgitb.strong(text), "<strong>{}</strong>".format(text))
13 self.assertEqual(cgitb.grey(text),
14 '<font color="#909090">{}</font>'.format(text))
15
16 def test_blanks(self):
17 self.assertEqual(cgitb.small(""), "")
18 self.assertEqual(cgitb.strong(""), "")
19 self.assertEqual(cgitb.grey(""), "")
20
21 def test_html(self):
22 try:
23 raise ValueError("Hello World")
24 except ValueError as err:
25 # If the html was templated we could do a bit more here.
26 # At least check that we get details on what we just raised.
27 html = cgitb.html(sys.exc_info())
28 self.assertIn("ValueError", html)
29 self.assertIn(str(err), html)
30
31 def test_text(self):
32 try:
33 raise ValueError("Hello World")
34 except ValueError as err:
35 text = cgitb.text(sys.exc_info())
36 self.assertIn("ValueError", text)
37 self.assertIn("Hello World", text)
38
39 def test_hook(self):
40 proc = subprocess.Popen([sys.executable, '-c',
41 ('import cgitb;'
42 'cgitb.enable();'
43 'raise ValueError("Hello World")')],
44 stdout=subprocess.PIPE)
45 out = proc.stdout.read().decode(sys.getfilesystemencoding())
46 self.addCleanup(proc.stdout.close)
47 self.assertIn("ValueError", out)
48 self.assertIn("Hello World", out)
49
50
51 def test_main():
52 run_unittest(TestCgitb)
53
54 if __name__ == "__main__":
55 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_cgi.py ('k') | Lib/test/test_cmd_line.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+