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

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

Issue 7652: Merge C version of decimal into py3k.
Patch Set: Created 7 years, 7 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/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 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 if fnmatch.fnmatchcase(name, match_tests): 1409 if fnmatch.fnmatchcase(name, match_tests):
1410 return True 1410 return True
1411 return False 1411 return False
1412 _filter_suite(suite, case_pred) 1412 _filter_suite(suite, case_pred)
1413 _run_suite(suite) 1413 _run_suite(suite)
1414 1414
1415 1415
1416 #======================================================================= 1416 #=======================================================================
1417 # doctest driver. 1417 # doctest driver.
1418 1418
1419 def run_doctest(module, verbosity=None): 1419 def run_doctest(module, verbosity=None, optionflags=0):
1420 """Run doctest on the given module. Return (#failures, #tests). 1420 """Run doctest on the given module. Return (#failures, #tests).
1421 1421
1422 If optional argument verbosity is not specified (or is None), pass 1422 If optional argument verbosity is not specified (or is None), pass
1423 support's belief about verbosity on to doctest. Else doctest's 1423 support's belief about verbosity on to doctest. Else doctest's
1424 usual behavior is used (it searches sys.argv for -v). 1424 usual behavior is used (it searches sys.argv for -v).
1425 """ 1425 """
1426 1426
1427 import doctest 1427 import doctest
1428 1428
1429 if verbosity is None: 1429 if verbosity is None:
1430 verbosity = verbose 1430 verbosity = verbose
1431 else: 1431 else:
1432 verbosity = None 1432 verbosity = None
1433 1433
1434 f, t = doctest.testmod(module, verbose=verbosity) 1434 f, t = doctest.testmod(module, verbose=verbosity, optionflags=optionflags)
1435 if f: 1435 if f:
1436 raise TestFailed("%d of %d doctests failed" % (f, t)) 1436 raise TestFailed("%d of %d doctests failed" % (f, t))
1437 if verbose: 1437 if verbose:
1438 print('doctest (%s) ... %d tests with zero failures' % 1438 print('doctest (%s) ... %d tests with zero failures' %
1439 (module.__name__, t)) 1439 (module.__name__, t))
1440 return f, t 1440 return f, t
1441 1441
1442 1442
1443 #======================================================================= 1443 #=======================================================================
1444 # Support for saving and restoring the imported modules. 1444 # Support for saving and restoring the imported modules.
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 def cleanup(): 1727 def cleanup():
1728 if attr_is_local: 1728 if attr_is_local:
1729 setattr(object_to_patch, attr_name, old_value) 1729 setattr(object_to_patch, attr_name, old_value)
1730 else: 1730 else:
1731 delattr(object_to_patch, attr_name) 1731 delattr(object_to_patch, attr_name)
1732 1732
1733 test_instance.addCleanup(cleanup) 1733 test_instance.addCleanup(cleanup)
1734 1734
1735 # actually override the attribute 1735 # actually override the attribute
1736 setattr(object_to_patch, attr_name, new_value) 1736 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+