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

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

Issue 23670: Modifications to support iOS as a development platform
Patch Set: Created 3 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_thread.py ('k') | Lib/test/test_unicodedata.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Test cases for traceback module""" 1 """Test cases for traceback module"""
2 2
3 from collections import namedtuple 3 from collections import namedtuple
4 from io import StringIO 4 from io import StringIO
5 import linecache 5 import linecache
6 import subprocess
6 import sys 7 import sys
7 import unittest 8 import unittest
8 import re 9 import re
9 from test import support 10 from test import support
10 from test.support import TESTFN, Error, captured_output, unlink, cpython_only 11 from test.support import TESTFN, Error, captured_output, unlink, cpython_only
11 from test.support.script_helper import assert_python_ok 12 from test.support.script_helper import assert_python_ok
12 import textwrap 13 import textwrap
13 14
14 import traceback 15 import traceback
15 16
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 if X.__module__ in ('__main__', 'builtins'): 104 if X.__module__ in ('__main__', 'builtins'):
104 str_name = X.__qualname__ 105 str_name = X.__qualname__
105 else: 106 else:
106 str_name = '.'.join([X.__module__, X.__qualname__]) 107 str_name = '.'.join([X.__module__, X.__qualname__])
107 self.assertEqual(err[0], "%s: %s\n" % (str_name, str_value)) 108 self.assertEqual(err[0], "%s: %s\n" % (str_name, str_value))
108 109
109 def test_without_exception(self): 110 def test_without_exception(self):
110 err = traceback.format_exception_only(None, None) 111 err = traceback.format_exception_only(None, None)
111 self.assertEqual(err, ['None\n']) 112 self.assertEqual(err, ['None\n'])
112 113
114 @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess .Popen()")
113 def test_encoded_file(self): 115 def test_encoded_file(self):
114 # Test that tracebacks are correctly printed for encoded source files: 116 # Test that tracebacks are correctly printed for encoded source files:
115 # - correct line number (Issue2384) 117 # - correct line number (Issue2384)
116 # - respect file encoding (Issue3975) 118 # - respect file encoding (Issue3975)
117 import tempfile, sys, subprocess, os 119 import tempfile, sys, os
118 120
119 # The spawned subprocess has its stdout redirected to a PIPE, and its 121 # The spawned subprocess has its stdout redirected to a PIPE, and its
120 # encoding may be different from the current interpreter, on Windows 122 # encoding may be different from the current interpreter, on Windows
121 # at least. 123 # at least.
122 process = subprocess.Popen([sys.executable, "-c", 124 process = subprocess.Popen([sys.executable, "-c",
123 "import sys; print(sys.stdout.encoding)"], 125 "import sys; print(sys.stdout.encoding)"],
124 stdout=subprocess.PIPE, 126 stdout=subprocess.PIPE,
125 stderr=subprocess.STDOUT) 127 stderr=subprocess.STDOUT)
126 stdout, stderr = process.communicate() 128 stdout, stderr = process.communicate()
127 output_encoding = str(stdout, 'ascii').splitlines()[0] 129 output_encoding = str(stdout, 'ascii').splitlines()[0]
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 if name.startswith('_') or name in blacklist: 914 if name.startswith('_') or name in blacklist:
913 continue 915 continue
914 module_object = getattr(traceback, name) 916 module_object = getattr(traceback, name)
915 if getattr(module_object, '__module__', None) == 'traceback': 917 if getattr(module_object, '__module__', None) == 'traceback':
916 expected.add(name) 918 expected.add(name)
917 self.assertCountEqual(traceback.__all__, expected) 919 self.assertCountEqual(traceback.__all__, expected)
918 920
919 921
920 if __name__ == "__main__": 922 if __name__ == "__main__":
921 unittest.main() 923 unittest.main()
OLDNEW
« no previous file with comments | « Lib/test/test_thread.py ('k') | Lib/test/test_unicodedata.py » ('j') | no next file with comments »

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