From 18371c0d3c99a18607f418762608becfc37824d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Fri, 4 Mar 2022 19:14:15 +0100 Subject: [PATCH] Test: Provide more useful information when unit translation fails Add the input quantity and the target scheme to the exception output. Also make the output formatting more canonical and remove the unused "s" temporary. --- src/Mod/Test/UnitTests.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Mod/Test/UnitTests.py b/src/Mod/Test/UnitTests.py index a77239977f..4726e46037 100644 --- a/src/Mod/Test/UnitTests.py +++ b/src/Mod/Test/UnitTests.py @@ -121,14 +121,13 @@ class UnitBasicCases(unittest.TestCase): q1 = FreeCAD.Units.Quantity(q1) q1.Format = {'Precision': 16} for idx, val in enumerate(schemes): - t = FreeCAD.Units.schemaTranslate(q1, idx) + [t, amountPerUnit, unit] = FreeCAD.Units.schemaTranslate(q1, idx) try: - q2 = FreeCAD.Units.Quantity(t[0]) + q2 = FreeCAD.Units.Quantity(t) if math.fabs(q1.Value - q2.Value) > 0.01: print (" {} : {} : {} : {} : {}".format(q1, q2, t, i, val).encode("utf-8").strip()) except Exception as e: - s = "{}: {}".format(e, t[0]) - print (" ".join(str(e)).encode("utf-8").strip()) + print ("{} : {} : {} : {}".format(q1, i, val, e).encode("utf-8").strip()) def testVoltage(self): q1 = FreeCAD.Units.Quantity("1e20 V")