Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def testWrongInputType(self):
for value in _NOT_NUMERICALS:
self.assertRaises(TypeError, minimalmodbus._floatToBytestring, value, 2)
for value in _NOT_INTERGERS:
self.assertRaises(TypeError, minimalmodbus._floatToBytestring, 1.1, value)
def testSanity(self):
for value, numberOfRegisters, knownstring in self.knownValues:
resultvalue = minimalmodbus._bytestringToFloat( \
minimalmodbus._floatToBytestring(value, numberOfRegisters), numberOfRegisters)
self.assertAlmostEqualRatio(resultvalue, value)
def testKnownValues(self):
for value, numberOfRegisters, knownstring in self.knownValues:
resultstring = minimalmodbus._floatToBytestring(value, numberOfRegisters)
self.assertEqual(resultstring, knownstring)
self.assertEqual(minimalmodbus._floatToBytestring(1.5e999, 2), '\x7f\x80\x00\x00') # +inf
def testKnownValues(self):
for value, numberOfRegisters, knownstring in self.knownValues:
resultstring = minimalmodbus._floatToBytestring(value, numberOfRegisters)
self.assertEqual(resultstring, knownstring)
self.assertEqual(minimalmodbus._floatToBytestring(1.5e999, 2), '\x7f\x80\x00\x00') # +inf