File tree Expand file tree Collapse file tree 2 files changed +11
-25
lines changed
Expand file tree Collapse file tree 2 files changed +11
-25
lines changed Original file line number Diff line number Diff line change @@ -956,10 +956,12 @@ def _filterwarnings(filters, quiet=False):
956956 frame = sys ._getframe (2 )
957957 registry = frame .f_globals .get ('__warningregistry__' )
958958 if registry :
959- # Was: registry.clear()
960- # Py2-compatible:
961- for i in range (len (registry )):
962- registry .pop ()
959+ if utils .PY3 :
960+ registry .clear ()
961+ else :
962+ # Py2-compatible:
963+ for i in range (len (registry )):
964+ registry .pop ()
963965 with warnings .catch_warnings (record = True ) as w :
964966 # Set filter "always" to record all warnings. Because
965967 # test_warnings swap the module, we need to look up in
Original file line number Diff line number Diff line change 99import functools
1010from textwrap import dedent
1111
12- if not hasattr (unittest , 'skip' ):
13- import unittest2 as unittest
14-
1512from future .utils import bind_method , PY26 , PY3 , PY2
1613from future .moves .subprocess import check_output , STDOUT , CalledProcessError
1714
15+ if PY26 :
16+ import unittest2 as unittest
17+
1818
1919def reformat_code (code ):
2020 """
@@ -369,29 +369,13 @@ def expectedFailurePY3(func):
369369def expectedFailurePY26 (func ):
370370 if not PY26 :
371371 return func
372- @functools .wraps (func )
373- def wrapper (* args , ** kwargs ):
374- try :
375- func (* args , ** kwargs )
376- except Exception :
377- raise unittest .case ._ExpectedFailure (sys .exc_info ())
378- # The following contributes to a FAILURE on Py2.6 (with
379- # unittest2). Ignore it ...
380- # raise unittest.case._UnexpectedSuccess
381- return wrapper
372+ return unittest .expectedFailure (func )
382373
383374
384375def expectedFailurePY2 (func ):
385376 if not PY2 :
386377 return func
387- @functools .wraps (func )
388- def wrapper (* args , ** kwargs ):
389- try :
390- func (* args , ** kwargs )
391- except Exception :
392- raise unittest .case ._ExpectedFailure (sys .exc_info ())
393- raise unittest .case ._UnexpectedSuccess
394- return wrapper
378+ return unittest .expectedFailure (func )
395379
396380
397381# Renamed in Py3.3:
You can’t perform that action at this time.
0 commit comments