Skip to content

Commit

Permalink
autotest: add an epsilon kwarg for assert_parameter_values
Browse files Browse the repository at this point in the history
... and reimplement assert_parameter_vaue in terms of that function
  • Loading branch information
peterbarker committed Oct 20, 2023
1 parent 6835013 commit c65675a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions Tools/autotest/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3810,21 +3810,23 @@ def log_list(self):
self.progress("log list: %s" % str(ret))
return ret

def assert_parameter_values(self, parameters):
def assert_parameter_values(self, parameters, epsilon=None):
names = parameters.keys()
got = self.get_parameters(names)
for name in names:
if got[name] != parameters[name]:
equal = got[name] == parameters[name]
if epsilon is not None:
delta = abs(got[name] - parameters[name])
equal = delta <= epsilon
if not equal:
raise NotAchievedException("parameter %s want=%f got=%f" %
(name, parameters[name], got[name]))
self.progress("%s has expected value %f" % (name, got[name]))

def assert_parameter_value(self, parameter, required):
got = self.get_parameter(parameter)
if got != required:
raise NotAchievedException("%s has unexpected value; want=%f got=%f" %
(parameter, required, got))
self.progress("%s has value %f" % (parameter, required))
def assert_parameter_value(self, parameter, required, **kwargs):
self.assert_parameter_values({
parameter: required,
}, **kwargs)

def assert_reach_imu_temperature(self, target, timeout):
'''wait to reach a target temperature'''
Expand Down

0 comments on commit c65675a

Please sign in to comment.