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.
This commit is contained in:
committed by
Chris Hennes
parent
ec132dc2e4
commit
18371c0d3c
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user