From d711695da6e54fb9351d0f989ea5cd6dd5d3e4c4 Mon Sep 17 00:00:00 2001 From: Jordan Adler Date: Mon, 8 Jul 2019 16:32:06 -0700 Subject: [PATCH] Remove flakiness in test_single_exception --- tests/test_future/test_utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_future/test_utils.py b/tests/test_future/test_utils.py index 488c0064..30eac7a6 100644 --- a/tests/test_future/test_utils.py +++ b/tests/test_future/test_utils.py @@ -4,7 +4,7 @@ """ from __future__ import absolute_import, unicode_literals, print_function -import sys, traceback +import re, sys, traceback from future.builtins import * from future.utils import (old_div, istext, isbytes, native, PY2, PY3, native_str, raise_, as_native_str, ensure_new_type, @@ -335,12 +335,14 @@ def test_single_exception_stacktrace(self): if PY2: expected += 'CustomException: ERROR\n' else: - expected += 'tests.test_future.test_utils.CustomException: ERROR\n' + expected += 'test_future.test_utils.CustomException: ERROR\n' try: raise CustomException('ERROR') except: - self.assertEqual(expected, traceback.format_exc()) + ret = re.sub(r'"[^"]*tests/test_future', '"/opt/python-future/tests/test_future', traceback.format_exc()) + ret = re.sub(r', line \d+,', ', line 328,', ret) + self.assertEqual(expected, ret) else: self.fail('No exception raised')