Skip to content

Commit 7ee8efe

Browse files
committed
Attempt to fix sporadic travis-ci.org test failures (builds #429, #430)
1 parent 05a40ea commit 7ee8efe

File tree

2 files changed

+11
-25
lines changed

2 files changed

+11
-25
lines changed

src/future/backports/test/support.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff 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

src/future/tests/base.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
import functools
1010
from textwrap import dedent
1111

12-
if not hasattr(unittest, 'skip'):
13-
import unittest2 as unittest
14-
1512
from future.utils import bind_method, PY26, PY3, PY2
1613
from future.moves.subprocess import check_output, STDOUT, CalledProcessError
1714

15+
if PY26:
16+
import unittest2 as unittest
17+
1818

1919
def reformat_code(code):
2020
"""
@@ -369,29 +369,13 @@ def expectedFailurePY3(func):
369369
def 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

384375
def 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:

0 commit comments

Comments
 (0)