Skip to content

Remove flakiness in test_chained_exception #484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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