Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autotest: add an epsilon kwarg for assert_parameter_values #25317

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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