@@ -155,7 +155,13 @@ def test_sqrt_with_negative_causes_math_error(self):
155155 # Verify it causes the expected math error
156156 with self .assertRaises (ValueError ) as context :
157157 mathparse .parse ('sqrt -16' )
158- self .assertIn ("math domain error" , str (context .exception ).lower ())
158+ # Python 3.14+ uses more specific error messages
159+ error_msg = str (context .exception ).lower ()
160+ self .assertTrue (
161+ "math domain error" in error_msg or
162+ "expected a nonnegative input" in error_msg ,
163+ f"Unexpected error message: { error_msg } "
164+ )
159165
160166 def test_log_with_negative_causes_math_error (self ):
161167 """
@@ -168,7 +174,13 @@ def test_log_with_negative_causes_math_error(self):
168174 # Verify it causes the expected math error
169175 with self .assertRaises (ValueError ) as context :
170176 mathparse .parse ('log -10' )
171- self .assertIn ("math domain error" , str (context .exception ).lower ())
177+ # Python 3.14+ uses more specific error messages
178+ error_msg = str (context .exception ).lower ()
179+ self .assertTrue (
180+ "math domain error" in error_msg or
181+ "expected a positive input" in error_msg ,
182+ f"Unexpected error message: { error_msg } "
183+ )
172184
173185 def test_sqrt_with_positive_after_operator (self ):
174186 """
0 commit comments