Skip to content

Commit 0a90dc8

Browse files
committed
fix: test with color
Signed-off-by: yihong0618 <[email protected]>
1 parent beed64f commit 0a90dc8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Lib/test/test_timeit.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,12 @@ def assert_exc_string(self, exc_string, expected_exc_name):
223223
exc_lines = exc_string.splitlines()
224224
self.assertGreater(len(exc_lines), 2)
225225
self.assertStartsWith(exc_lines[0], 'Traceback')
226-
self.assertStartsWith(exc_lines[-1], expected_exc_name)
226+
# Remove ANSI color codes from the last line before checking
227+
import re
228+
last_line = exc_lines[-1]
229+
# Remove ANSI escape sequences
230+
clean_last_line = re.sub(r'\x1b\[[0-9;]*m', '', last_line)
231+
self.assertStartsWith(clean_last_line, expected_exc_name)
227232

228233
def test_print_exc(self):
229234
s = io.StringIO()

0 commit comments

Comments
 (0)