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

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

Issue 7652: Merge C version of decimal into py3k.
Patch Set: Created 8 years 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/decimal.py ('k') | Lib/test/test_decimal.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 """Supporting definitions for the Python regression tests.""" 1 """Supporting definitions for the Python regression tests."""
2 2
3 if __name__ != 'test.support': 3 if __name__ != 'test.support':
4 raise ImportError('support must be imported from the test package') 4 raise ImportError('support must be imported from the test package')
5 5
6 import contextlib 6 import contextlib
7 import errno 7 import errno
8 import functools 8 import functools
9 import gc 9 import gc
10 import socket 10 import socket
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 elif isinstance(cls, valid_types): 1276 elif isinstance(cls, valid_types):
1277 suite.addTest(cls) 1277 suite.addTest(cls)
1278 else: 1278 else:
1279 suite.addTest(unittest.makeSuite(cls)) 1279 suite.addTest(unittest.makeSuite(cls))
1280 _run_suite(suite) 1280 _run_suite(suite)
1281 1281
1282 1282
1283 #======================================================================= 1283 #=======================================================================
1284 # doctest driver. 1284 # doctest driver.
1285 1285
1286 def run_doctest(module, verbosity=None): 1286 def run_doctest(module, verbosity=None, optionflags=0):
1287 """Run doctest on the given module. Return (#failures, #tests). 1287 """Run doctest on the given module. Return (#failures, #tests).
1288 1288
1289 If optional argument verbosity is not specified (or is None), pass 1289 If optional argument verbosity is not specified (or is None), pass
1290 support's belief about verbosity on to doctest. Else doctest's 1290 support's belief about verbosity on to doctest. Else doctest's
1291 usual behavior is used (it searches sys.argv for -v). 1291 usual behavior is used (it searches sys.argv for -v).
1292 """ 1292 """
1293 1293
1294 import doctest 1294 import doctest
1295 1295
1296 if verbosity is None: 1296 if verbosity is None:
1297 verbosity = verbose 1297 verbosity = verbose
1298 else: 1298 else:
1299 verbosity = None 1299 verbosity = None
1300 1300
1301 # Direct doctest output (normally just errors) to real stdout; doctest 1301 # Direct doctest output (normally just errors) to real stdout; doctest
1302 # output shouldn't be compared by regrtest. 1302 # output shouldn't be compared by regrtest.
1303 save_stdout = sys.stdout 1303 save_stdout = sys.stdout
1304 sys.stdout = get_original_stdout() 1304 sys.stdout = get_original_stdout()
1305 try: 1305 try:
1306 f, t = doctest.testmod(module, verbose=verbosity) 1306 f, t = doctest.testmod(module, verbose=verbosity,
1307 optionflags=optionflags)
1307 if f: 1308 if f:
1308 raise TestFailed("%d of %d doctests failed" % (f, t)) 1309 raise TestFailed("%d of %d doctests failed" % (f, t))
1309 finally: 1310 finally:
1310 sys.stdout = save_stdout 1311 sys.stdout = save_stdout
1311 if verbose: 1312 if verbose:
1312 print('doctest (%s) ... %d tests with zero failures' % 1313 print('doctest (%s) ... %d tests with zero failures' %
1313 (module.__name__, t)) 1314 (module.__name__, t))
1314 return f, t 1315 return f, t
1315 1316
1316 1317
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 def cleanup(): 1600 def cleanup():
1600 if attr_is_local: 1601 if attr_is_local:
1601 setattr(object_to_patch, attr_name, old_value) 1602 setattr(object_to_patch, attr_name, old_value)
1602 else: 1603 else:
1603 delattr(object_to_patch, attr_name) 1604 delattr(object_to_patch, attr_name)
1604 1605
1605 test_instance.addCleanup(cleanup) 1606 test_instance.addCleanup(cleanup)
1606 1607
1607 # actually override the attribute 1608 # actually override the attribute
1608 setattr(object_to_patch, attr_name, new_value) 1609 setattr(object_to_patch, attr_name, new_value)
OLDNEW
« no previous file with comments | « Lib/decimal.py ('k') | Lib/test/test_decimal.py » ('j') | no next file with comments »

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