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

Side by Side Diff: Lib/test/test_zipimport_support.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_zipimport.py ('k') | Lib/test/threaded_import_hangers.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 # This test module covers support in various parts of the standard library 1 # This test module covers support in various parts of the standard library
2 # for working with modules located inside zipfiles 2 # for working with modules located inside zipfiles
3 # The tests are centralised in this fashion to make it easy to drop them 3 # The tests are centralised in this fashion to make it easy to drop them
4 # if a platform doesn't support zipimport 4 # if a platform doesn't support zipimport
5 import test.support 5 import test.support
6 import os 6 import os
7 import os.path 7 import os.path
8 import sys 8 import sys
9 import textwrap 9 import textwrap
10 import zipfile 10 import zipfile
(...skipping 15 matching lines...) Expand all
26 26
27 # Other test modules with zipimport related tests 27 # Other test modules with zipimport related tests
28 # test_zipimport (of course!) 28 # test_zipimport (of course!)
29 # test_cmd_line_script (covers the zipimport support in runpy) 29 # test_cmd_line_script (covers the zipimport support in runpy)
30 30
31 # Retrieve some helpers from other test cases 31 # Retrieve some helpers from other test cases
32 from test import test_doctest, sample_doctest 32 from test import test_doctest, sample_doctest
33 33
34 34
35 def _run_object_doctest(obj, module): 35 def _run_object_doctest(obj, module):
36 finder = doctest.DocTestFinder(verbose=verbose, recurse=False) 36 # Direct doctest output (normally just errors) to real stdout; doctest
37 runner = doctest.DocTestRunner(verbose=verbose) 37 # output shouldn't be compared by regrtest.
38 # Use the object's fully qualified name if it has one 38 save_stdout = sys.stdout
39 # Otherwise, use the module's name 39 sys.stdout = test.support.get_original_stdout()
40 try: 40 try:
41 name = "%s.%s" % (obj.__module__, obj.__name__) 41 finder = doctest.DocTestFinder(verbose=verbose, recurse=False)
42 except AttributeError: 42 runner = doctest.DocTestRunner(verbose=verbose)
43 name = module.__name__ 43 # Use the object's fully qualified name if it has one
44 for example in finder.find(obj, name, module): 44 # Otherwise, use the module's name
45 runner.run(example) 45 try:
46 f, t = runner.failures, runner.tries 46 name = "%s.%s" % (obj.__module__, obj.__name__)
47 if f: 47 except AttributeError:
48 raise test.support.TestFailed("%d of %d doctests failed" % (f, t)) 48 name = module.__name__
49 for example in finder.find(obj, name, module):
50 runner.run(example)
51 f, t = runner.failures, runner.tries
52 if f:
53 raise test.support.TestFailed("%d of %d doctests failed" % (f, t))
54 finally:
55 sys.stdout = save_stdout
49 if verbose: 56 if verbose:
50 print ('doctest (%s) ... %d tests with zero failures' % (module.__name__ , t)) 57 print ('doctest (%s) ... %d tests with zero failures' % (module.__name__ , t))
51 return f, t 58 return f, t
52 59
53 60
54 61
55 class ZipSupportTests(unittest.TestCase): 62 class ZipSupportTests(unittest.TestCase):
56 # This used to use the ImportHooksBaseTestCase to restore 63 # This used to use the ImportHooksBaseTestCase to restore
57 # the state of the import related information 64 # the state of the import related information
58 # in the sys module after each test. However, that restores 65 # in the sys module after each test. However, that restores
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 data = kill_python(p) 231 data = kill_python(p)
225 self.assertIn(run_name.encode('utf-8'), data) 232 self.assertIn(run_name.encode('utf-8'), data)
226 233
227 234
228 def test_main(): 235 def test_main():
229 test.support.run_unittest(ZipSupportTests) 236 test.support.run_unittest(ZipSupportTests)
230 test.support.reap_children() 237 test.support.reap_children()
231 238
232 if __name__ == '__main__': 239 if __name__ == '__main__':
233 test_main() 240 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_zipimport.py ('k') | Lib/test/threaded_import_hangers.py » ('j') | no next file with comments »

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