mirror of
https://github.com/micropython/micropython.git
synced 2026-01-28 14:50:21 +01:00
tests/float/math_fun: Fix domain error tests with CPython 3.14.
This commit makes tests exercising certain math functions' limit work when using CPython 3.14 to validate the tests' output. CPython 3.14 introduced more descriptive messages when math domain error conditions are encountered rather than a single generic message. This breaks the tests in question as MicroPython uses a single error message when reporting these conditions (both to closely follow CPython and to save firmware space). The math domain tests now look for an error pattern that is compatible with both CPython 3.14 and previous versions, converting messages in the newer format into the previous one. This makes the tests' behaviour under MicroPython comparable with CPython for the foreseeable future. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit is contained in:
@@ -43,6 +43,9 @@ for function_name, function, test_vals in functions:
|
||||
ans = "{:.5g}".format(function(value))
|
||||
except ValueError as e:
|
||||
ans = str(e)
|
||||
if ans.startswith("expected a "):
|
||||
# CPython 3.14 changed messages to be more detailed; convert them back to simple ones
|
||||
ans = "math domain error"
|
||||
print("{}({:.5g}) = {}".format(function_name, value, ans))
|
||||
|
||||
tuple_functions = [
|
||||
|
||||
Reference in New Issue
Block a user