Skip to content

Commit

Permalink
Merge pull request #484 from jmadler/master
Browse files Browse the repository at this point in the history
Remove flakiness in test_chained_exception
  • Loading branch information
jmadler authored Jul 9, 2019
2 parents 6355c79 + 015e837 commit 7efd55d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/test_future/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,15 @@ def test_single_exception_stacktrace(self):
if PY2:
def test_chained_exceptions_stacktrace(self):
expected = '''Traceback (most recent call last):
File "/opt/python-future/tests/test_future/test_utils.py", line 354, in test_chained_exceptions_stacktrace
File "/opt/python-future/tests/test_future/test_utils.py", line 1, in test_chained_exceptions_stacktrace
raise_from(CustomException('ERROR'), val_err)
File "/opt/python-future/src/future/utils/__init__.py", line 456, in raise_from
File "/opt/python-future/src/future/utils/__init__.py", line 1, in raise_from
raise e
CustomException: ERROR
The above exception was the direct cause of the following exception:
File "/opt/python-future/tests/test_future/test_utils.py", line 352, in test_chained_exceptions_stacktrace
File "/opt/python-future/tests/test_future/test_utils.py", line 1, in test_chained_exceptions_stacktrace
raise ValueError('Wooops')
ValueError: Wooops
'''
Expand All @@ -368,7 +368,10 @@ def test_chained_exceptions_stacktrace(self):
except ValueError as val_err:
raise_from(CustomException('ERROR'), val_err)
except Exception as err:
self.assertEqual(expected.splitlines(), traceback.format_exc().splitlines())
ret = re.sub(r'"[^"]*tests/test_future', '"/opt/python-future/tests/test_future', traceback.format_exc())
ret = re.sub(r'"[^"]*future/utils/__init__.py', '"/opt/python-future/src/future/utils/__init__.py', ret)
ret = re.sub(r', line \d+,', ', line 1,', ret)
self.assertEqual(expected.splitlines(), ret.splitlines())
else:
self.fail('No exception raised')

Expand Down

0 comments on commit 7efd55d

Please sign in to comment.