safety tests: fix measurement test (#1679)

* Update common.py

* without abs and only negative values: this is not caught (since negative error < 1)

* ugly draft

* this catches it

* draft

* draft

* draft

* works now!

* no blurry tests

* ugh subaru is like this too

* okay some can scaling makes it slightly off (wheel speeds)

* uncommont

* clean up
This commit is contained in:
Shane Smiskol 2023-10-03 02:46:58 -07:00 committed by GitHub
parent 635db84095
commit 846c807797
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -640,8 +640,8 @@ class MeasurementSafetyTest(PandaSafetyTestBase):
self.assertTrue(self._rx(msg_func(val + i * 0.1)))
# assert close by one decimal place
self.assertLessEqual(abs(get_min_func() - val * factor), 1 * abs(factor))
self.assertLessEqual(abs(get_max_func() - (val + 0.5) * factor), 1 * abs(factor))
self.assertAlmostEqual(get_min_func() / factor, val, delta=0.1)
self.assertAlmostEqual(get_max_func() / factor - 0.5, val, delta=0.1)
# reset sample_t by reinitializing the safety mode
self._reset_safety_hooks()