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):
956
956
frame = sys ._getframe (2 )
957
957
registry = frame .f_globals .get ('__warningregistry__' )
958
958
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 ()
963
965
with warnings .catch_warnings (record = True ) as w :
964
966
# Set filter "always" to record all warnings. Because
965
967
# test_warnings swap the module, we need to look up in
Original file line number Diff line number Diff line change 9
9
import functools
10
10
from textwrap import dedent
11
11
12
- if not hasattr (unittest , 'skip' ):
13
- import unittest2 as unittest
14
-
15
12
from future .utils import bind_method , PY26 , PY3 , PY2
16
13
from future .moves .subprocess import check_output , STDOUT , CalledProcessError
17
14
15
+ if PY26 :
16
+ import unittest2 as unittest
17
+
18
18
19
19
def reformat_code (code ):
20
20
"""
@@ -369,29 +369,13 @@ def expectedFailurePY3(func):
369
369
def expectedFailurePY26 (func ):
370
370
if not PY26 :
371
371
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 )
382
373
383
374
384
375
def expectedFailurePY2 (func ):
385
376
if not PY2 :
386
377
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 )
395
379
396
380
397
381
# Renamed in Py3.3:
You can’t perform that action at this time.
0 commit comments