Skip to content

Commit 7efd55d

Browse files
authored
Merge pull request #484 from jmadler/master
Remove flakiness in test_chained_exception
2 parents 6355c79 + 015e837 commit 7efd55d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tests/test_future/test_utils.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -349,15 +349,15 @@ def test_single_exception_stacktrace(self):
349349
if PY2:
350350
def test_chained_exceptions_stacktrace(self):
351351
expected = '''Traceback (most recent call last):
352-
File "/opt/python-future/tests/test_future/test_utils.py", line 354, in test_chained_exceptions_stacktrace
352+
File "/opt/python-future/tests/test_future/test_utils.py", line 1, in test_chained_exceptions_stacktrace
353353
raise_from(CustomException('ERROR'), val_err)
354-
File "/opt/python-future/src/future/utils/__init__.py", line 456, in raise_from
354+
File "/opt/python-future/src/future/utils/__init__.py", line 1, in raise_from
355355
raise e
356356
CustomException: ERROR
357357
358358
The above exception was the direct cause of the following exception:
359359
360-
File "/opt/python-future/tests/test_future/test_utils.py", line 352, in test_chained_exceptions_stacktrace
360+
File "/opt/python-future/tests/test_future/test_utils.py", line 1, in test_chained_exceptions_stacktrace
361361
raise ValueError('Wooops')
362362
ValueError: Wooops
363363
'''
@@ -368,7 +368,10 @@ def test_chained_exceptions_stacktrace(self):
368368
except ValueError as val_err:
369369
raise_from(CustomException('ERROR'), val_err)
370370
except Exception as err:
371-
self.assertEqual(expected.splitlines(), traceback.format_exc().splitlines())
371+
ret = re.sub(r'"[^"]*tests/test_future', '"/opt/python-future/tests/test_future', traceback.format_exc())
372+
ret = re.sub(r'"[^"]*future/utils/__init__.py', '"/opt/python-future/src/future/utils/__init__.py', ret)
373+
ret = re.sub(r', line \d+,', ', line 1,', ret)
374+
self.assertEqual(expected.splitlines(), ret.splitlines())
372375
else:
373376
self.fail('No exception raised')
374377

0 commit comments

Comments
 (0)