From fd438d9dd9ad13b464f5ce16dda7a23eb6c37262 Mon Sep 17 00:00:00 2001 From: Jongwook Choi Date: Thu, 31 Oct 2024 09:54:07 -0400 Subject: [PATCH] fix(tests): failing tests on python3.13 about stacktrace messages Fixes #571. Problem: The `test_python3_ex_eval` test fails on python3.13 because the format of stacktrace message has changed. Solution: Check for important lines only. --- test/test_vim.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/test/test_vim.py b/test/test_vim.py index 3e140d68..81997c27 100644 --- a/test/test_vim.py +++ b/test/test_vim.py @@ -3,7 +3,6 @@ import os import sys import tempfile -import textwrap from pathlib import Path import pytest @@ -232,21 +231,18 @@ def test_python3_ex_eval(vim: Nvim) -> None: # because the Ex command :python will throw (wrapped with provider#python3#Call) with pytest.raises(NvimError) as excinfo: vim.command('py3= 1/0') - assert textwrap.dedent('''\ - Traceback (most recent call last): - File "", line 1, in - ZeroDivisionError: division by zero - ''').strip() in excinfo.value.args[0] + stacktrace = excinfo.value.args[0] + assert 'Traceback (most recent call last):' in stacktrace + assert 'File "", line 1, in ' in stacktrace + assert 'ZeroDivisionError: division by zero' in stacktrace vim.command('python3 def raise_error(): raise RuntimeError("oops")') with pytest.raises(NvimError) as excinfo: vim.command_output('python3 =print("nooo", raise_error())') - assert textwrap.dedent('''\ - Traceback (most recent call last): - File "", line 1, in - File "", line 1, in raise_error - RuntimeError: oops - ''').strip() in excinfo.value.args[0] + stacktrace = excinfo.value.args[0] + assert 'Traceback (most recent call last):' in stacktrace + assert 'File "", line 1, in raise_error' in stacktrace + assert 'RuntimeError: oops' in stacktrace assert 'nooo' not in vim.command_output(':messages')