Internal documentation for unit testing of MinimalModbus

test_minimalmodbus: Unittests for the minimalmodbus module.

For each function are these tests performed:

  • Known results
  • Invalid input value
  • Invalid input type

This unittest suite uses a mock/dummy serial port from the module dummy_serial, so it is possible to test the functionality using previously recorded communication data.

With dummy responses, it is also possible to simulate errors in the communication from the slave. A few different types of communication errors are tested, as seen in this table.

Simulated response error Tested using function Tested with function code
No response read_bit 2
Wrong CRC in response write_register 16
Wrong slave address in response write_register 16
Wrong function code in response write_register 16
Slave indicates an error write_register 16
Wrong byte count in response read_bit 2
Wrong register address in response write_register 16
Wrong number of registers in response write_bit 15
Wrong number of registers in response write_register 16
Wrong write data in response write_bit 5
Wrong write data in response write_register 6
test_minimalmodbus.VERBOSITY = 0

Verbosity level for the unit testing.

Use value 0 or 2. Note that it only has an effect for Python 2.7 and above.

test_minimalmodbus.SHOW_ERROR_MESSAGES_FOR_ASSERTRAISES = False

Set this to True for printing the error messages caught by assertRaises().

If set to True, any unintentional error messages raised during the processing of the command in assertRaises() are also caught (not counted). It will be printed in the short form, and will show no traceback. It can also be useful to set VERBOSITY = 2.

exception test_minimalmodbus._NonexistantError[source]
class test_minimalmodbus.ExtendedTestCase(methodName='runTest')[source]

Overriding the assertRaises() method to be able to print the error message.

Use test_minimalmodbus.SHOW_ERROR_MESSAGES_FOR_ASSERTRAISES = True in order to use this option. It can also be useful to set test_minimalmodbus.VERBOSITY = 2.

Based on https://stackoverflow.com/questions/8672754/ how-to-show-the-error-messages-caught-by-assertraises-in-unittest-in-python2-7

assertRaises(excClass: Union[Type[BaseException], Tuple[Type[BaseException], ...]], callableObj: Callable[[...], Any], *args, **kwargs) → None[source]

Prints the caught error message (if SHOW_ERROR_MESSAGES_FOR_ASSERTRAISES is True).

assertAlmostEqualRatio(first: float, second: float, epsilon: float = 1.000001) → None[source]

A function to compare floats, with ratio instead of “number_of_places”.

This is slightly different than the standard unittest.assertAlmostEqual()

Args:
  • first: Input argument for comparison
  • second: Input argument for comparison
  • epsilon: Largest allowed ratio of largest to smallest of the two input arguments
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCreatePayload(methodName='runTest')[source]
testKnownValues() → None[source]
testWrongValues() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestParsePayload(methodName='runTest')[source]
testKnownValues() → None[source]
testInvalidPayloads() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestEmbedPayload(methodName='runTest')[source]
known_values = [(2, 2, 'rtu', b'123', b'\x02\x02123X\xc2'), (1, 16, 'rtu', b'ABC', b'\x01\x10ABC<E'), (0, 5, 'rtu', b'hjl', b'\x00\x05hjl\x8b\x9d'), (1, 3, 'rtu', b'\x01\x02\x03', b'\x01\x03\x01\x02\x03\t%'), (1, 3, 'ascii', b'123', b':010331323366\r\n'), (4, 5, 'ascii', b'\x01\x02\x03', b':0405010203F1\r\n'), (2, 2, 'ascii', b'123', b':020231323366\r\n')]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestExtractPayload(methodName='runTest')[source]
known_values = [(2, 2, 'rtu', b'123', b'\x02\x02123X\xc2'), (1, 16, 'rtu', b'ABC', b'\x01\x10ABC<E'), (0, 5, 'rtu', b'hjl', b'\x00\x05hjl\x8b\x9d'), (1, 3, 'rtu', b'\x01\x02\x03', b'\x01\x03\x01\x02\x03\t%'), (1, 3, 'ascii', b'123', b':010331323366\r\n'), (4, 5, 'ascii', b'\x01\x02\x03', b':0405010203F1\r\n'), (2, 2, 'ascii', b'123', b':020231323366\r\n')]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestSanityEmbedExtractPayload(methodName='runTest')[source]
known_values = [(2, 2, 'rtu', b'123', b'\x02\x02123X\xc2'), (1, 16, 'rtu', b'ABC', b'\x01\x10ABC<E'), (0, 5, 'rtu', b'hjl', b'\x00\x05hjl\x8b\x9d'), (1, 3, 'rtu', b'\x01\x02\x03', b'\x01\x03\x01\x02\x03\t%'), (1, 3, 'ascii', b'123', b':010331323366\r\n'), (4, 5, 'ascii', b'\x01\x02\x03', b':0405010203F1\r\n'), (2, 2, 'ascii', b'123', b':020231323366\r\n')]
testKnownValues() → None[source]
testRange() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestPredictResponseSize(methodName='runTest')[source]
known_values = [('rtu', 1, b'\x00>\x00\x01', 6), ('rtu', 1, b'\x00>\x00\x07', 6), ('rtu', 1, b'\x00>\x00\x08', 6), ('rtu', 1, b'\x00>\x00\t', 7), ('rtu', 2, b'\x00>\x00\t', 7), ('rtu', 3, b'AB\x00\x07', 19), ('rtu', 4, b'AB\x00\x07', 19), ('rtu', 4, b'AB\x01\x07', 531), ('rtu', 5, b'\x00G\xff\x00', 8), ('rtu', 6, b'\x00G\xff\xff', 8), ('rtu', 16, b'\x00H\x00\x01\x01\x01', 8), ('ascii', 1, b'\x00>\x00\x01', 13), ('ascii', 1, b'\x00>\x00\x07', 13), ('ascii', 1, b'\x00>\x00\x08', 13), ('ascii', 1, b'\x00>\x00\t', 15), ('ascii', 3, b'AB\x00\x07', 39), ('ascii', 4, b'AB\x00\x07', 39), ('ascii', 4, b'AB\x01\x07', 1063), ('ascii', 5, b'\x00G\xff\x00', 17), ('ascii', 16, b'\x00H\x00\x01\x01\x01', 17)]
testKnownValues() → None[source]
testRecordedRtuMessages() → None[source]
testRecordedAsciiMessages() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCalculateMinimumSilentPeriod(methodName='runTest')[source]
known_values = [(2400, 0.016), (2400.0, 0.016), (4800, 0.008), (9600, 0.004), (19200, 0.002), (38400, 0.00175), (57600, 0.00175), (115200, 0.00175), (128000, 0.00175), (230400, 0.00175), (4000000, 0.00175)]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestNumToOneByte(methodName='runTest')[source]
known_values = [(0, b'\x00'), (7, b'\x07'), (255, b'\xff')]
testKnownValues() → None[source]
testKnownLoop() → None[source]
testWrongInput() → None[source]
testWrongType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestNumToTwoBytes(methodName='runTest')[source]
known_values = [(0.0, 0, False, False, b'\x00\x00'), (0, 0, False, False, b'\x00\x00'), (0, 0, True, False, b'\x00\x00'), (77.0, 1, False, False, b'\x03\x02'), (77.0, 1, True, False, b'\x02\x03'), (770, 0, False, False, b'\x03\x02'), (770, 0, True, False, b'\x02\x03'), (65535, 0, False, False, b'\xff\xff'), (65535, 0, True, False, b'\xff\xff'), (770, 0, False, True, b'\x03\x02'), (77.0, 1, False, True, b'\x03\x02'), (0.0, 0, False, True, b'\x00\x00'), (0.0, 3, False, True, b'\x00\x00'), (-1, 0, False, True, b'\xff\xff'), (-1, 1, False, True, b'\xff\xf6'), (-77, 0, False, True, b'\xff\xb3'), (-770, 0, False, True, b'\xfc\xfe'), (-77, 1, False, True, b'\xfc\xfe'), (-32768, 0, False, True, b'\x80\x00'), (32767, 0, False, True, b'\x7f\xff')]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestTwoBytesToNum(methodName='runTest')[source]
known_values = [(0.0, 0, False, False, b'\x00\x00'), (0, 0, False, False, b'\x00\x00'), (0, 0, True, False, b'\x00\x00'), (77.0, 1, False, False, b'\x03\x02'), (77.0, 1, True, False, b'\x02\x03'), (770, 0, False, False, b'\x03\x02'), (770, 0, True, False, b'\x02\x03'), (65535, 0, False, False, b'\xff\xff'), (65535, 0, True, False, b'\xff\xff'), (770, 0, False, True, b'\x03\x02'), (77.0, 1, False, True, b'\x03\x02'), (0.0, 0, False, True, b'\x00\x00'), (0.0, 3, False, True, b'\x00\x00'), (-1, 0, False, True, b'\xff\xff'), (-1, 1, False, True, b'\xff\xf6'), (-77, 0, False, True, b'\xff\xb3'), (-770, 0, False, True, b'\xfc\xfe'), (-77, 1, False, True, b'\xfc\xfe'), (-32768, 0, False, True, b'\x80\x00'), (32767, 0, False, True, b'\x7f\xff')]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestSanityTwoBytes(methodName='runTest')[source]
known_values = [(0.0, 0, False, False, b'\x00\x00'), (0, 0, False, False, b'\x00\x00'), (0, 0, True, False, b'\x00\x00'), (77.0, 1, False, False, b'\x03\x02'), (77.0, 1, True, False, b'\x02\x03'), (770, 0, False, False, b'\x03\x02'), (770, 0, True, False, b'\x02\x03'), (65535, 0, False, False, b'\xff\xff'), (65535, 0, True, False, b'\xff\xff'), (770, 0, False, True, b'\x03\x02'), (77.0, 1, False, True, b'\x03\x02'), (0.0, 0, False, True, b'\x00\x00'), (0.0, 3, False, True, b'\x00\x00'), (-1, 0, False, True, b'\xff\xff'), (-1, 1, False, True, b'\xff\xf6'), (-77, 0, False, True, b'\xff\xb3'), (-770, 0, False, True, b'\xfc\xfe'), (-77, 1, False, True, b'\xfc\xfe'), (-32768, 0, False, True, b'\x80\x00'), (32767, 0, False, True, b'\x7f\xff')]
testSanity() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestBytesToBits(methodName='runTest')[source]
known_values = [(b'\x00', 1, [0]), (b'\x01', 1, [1]), (b'\x02', 2, [0, 1]), (b'\x03', 2, [1, 1]), (b'\x04', 3, [0, 0, 1]), (b'\x08', 4, [0, 0, 0, 1]), (b'\x10', 5, [0, 0, 0, 0, 1]), (b' ', 6, [0, 0, 0, 0, 0, 1]), (b'@', 7, [0, 0, 0, 0, 0, 0, 1]), (b'\x80', 8, [0, 0, 0, 0, 0, 0, 0, 1]), (b'\x00\x01', 9, [0, 0, 0, 0, 0, 0, 0, 0, 1]), (b'\x00\x02', 10, [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), (b'\x00\x00\x01', 17, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), (b'\x00\x00\x02', 18, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), (b'\x00\x00\x02', 19, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]), (b'\x01', 1, [1]), (b'\x01', 2, [1, 0]), (b'\x01', 3, [1, 0, 0]), (b'\x01', 4, [1, 0, 0, 0]), (b'\x01', 5, [1, 0, 0, 0, 0]), (b'\x01', 6, [1, 0, 0, 0, 0, 0]), (b'\x01', 7, [1, 0, 0, 0, 0, 0, 0]), (b'\x01', 8, [1, 0, 0, 0, 0, 0, 0, 0]), (b'\x01\x00', 9, [1, 0, 0, 0, 0, 0, 0, 0, 0]), (b'\x01\x00', 10, [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (b'\x01\x00', 16, [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (b'\x01\x00\x00', 17, [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (b'\x01\x00\x00', 18, [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (b'\xcdk\x05', 19, [1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1]), (b'\xac\xdb5', 22, [0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1]), (b'\xcd\x01', 10, [1, 0, 1, 1, 0, 0, 1, 1, 1, 0])]
testKnownValues() → None[source]
testWrongValues() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestBitsToBytes(methodName='runTest')[source]
known_values = [(b'\x00', 1, [0]), (b'\x01', 1, [1]), (b'\x02', 2, [0, 1]), (b'\x03', 2, [1, 1]), (b'\x04', 3, [0, 0, 1]), (b'\x08', 4, [0, 0, 0, 1]), (b'\x10', 5, [0, 0, 0, 0, 1]), (b' ', 6, [0, 0, 0, 0, 0, 1]), (b'@', 7, [0, 0, 0, 0, 0, 0, 1]), (b'\x80', 8, [0, 0, 0, 0, 0, 0, 0, 1]), (b'\x00\x01', 9, [0, 0, 0, 0, 0, 0, 0, 0, 1]), (b'\x00\x02', 10, [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), (b'\x00\x00\x01', 17, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), (b'\x00\x00\x02', 18, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), (b'\x00\x00\x02', 19, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]), (b'\x01', 1, [1]), (b'\x01', 2, [1, 0]), (b'\x01', 3, [1, 0, 0]), (b'\x01', 4, [1, 0, 0, 0]), (b'\x01', 5, [1, 0, 0, 0, 0]), (b'\x01', 6, [1, 0, 0, 0, 0, 0]), (b'\x01', 7, [1, 0, 0, 0, 0, 0, 0]), (b'\x01', 8, [1, 0, 0, 0, 0, 0, 0, 0]), (b'\x01\x00', 9, [1, 0, 0, 0, 0, 0, 0, 0, 0]), (b'\x01\x00', 10, [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (b'\x01\x00', 16, [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (b'\x01\x00\x00', 17, [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (b'\x01\x00\x00', 18, [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), (b'\xcdk\x05', 19, [1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1]), (b'\xac\xdb5', 22, [0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1]), (b'\xcd\x01', 10, [1, 0, 1, 1, 0, 0, 1, 1, 1, 0])]
testKnownValues() → None[source]
testWrongValues() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestBitToBytes(methodName='runTest')[source]
known_values = [(0, b'\x00\x00'), (1, b'\xff\x00')]
testKnownValues() → None[source]
testWrongValue() → None[source]
testValueNotInteger() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCalculateNumberOfBytesForBits(methodName='runTest')[source]
known_values = [(0, 0), (1, 1), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1), (7, 1), (8, 1), (9, 2), (10, 2), (11, 2), (12, 2), (13, 2), (14, 2), (15, 2), (16, 2), (17, 3)]
testKnownValues() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestLongToBytes(methodName='runTest')[source]
known_values = [(0, 2, True, 0, b'\x00\x00\x00\x00'), (1, 2, False, 0, b'\x00\x00\x00\x01'), (1, 2, True, 0, b'\x00\x00\x00\x01'), (2, 2, False, 0, b'\x00\x00\x00\x02'), (2, 2, True, 0, b'\x00\x00\x00\x02'), (75000, 2, False, 0, b'\x00\x01$\xf8'), (75000, 2, True, 0, b'\x00\x01$\xf8'), (1000000, 2, False, 0, b'\x00\x0fB@'), (1000000, 2, True, 0, b'\x00\x0fB@'), (2147483647, 2, False, 0, b'\x7f\xff\xff\xff'), (2147483647, 2, True, 0, b'\x7f\xff\xff\xff'), (2147483648, 2, False, 0, b'\x80\x00\x00\x00'), (4294967295, 2, False, 0, b'\xff\xff\xff\xff'), (-1, 2, True, 0, b'\xff\xff\xff\xff'), (-2147483648, 2, True, 0, b'\x80\x00\x00\x00'), (-200000000, 2, True, 0, b'\xf4\x14>\x00'), (2923517522, 2, False, 0, b'\xaeAVR'), (-1371449774, 2, True, 0, b'\xaeAVR'), (2923517522, 2, False, 1, b'RVA\xae'), (2923517522, 2, False, 3, b'VR\xaeA'), (2923517522, 2, False, 2, b'A\xaeRV'), (0, 4, True, 0, b'\x00\x00\x00\x00\x00\x00\x00\x00'), (0, 4, False, 0, b'\x00\x00\x00\x00\x00\x00\x00\x00'), (1, 4, True, 0, b'\x00\x00\x00\x00\x00\x00\x00\x01'), (1, 4, False, 0, b'\x00\x00\x00\x00\x00\x00\x00\x01'), (-1, 4, True, 0, b'\xff\xff\xff\xff\xff\xff\xff\xff')]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestBytesToLong(methodName='runTest')[source]
known_values = [(0, 2, True, 0, b'\x00\x00\x00\x00'), (1, 2, False, 0, b'\x00\x00\x00\x01'), (1, 2, True, 0, b'\x00\x00\x00\x01'), (2, 2, False, 0, b'\x00\x00\x00\x02'), (2, 2, True, 0, b'\x00\x00\x00\x02'), (75000, 2, False, 0, b'\x00\x01$\xf8'), (75000, 2, True, 0, b'\x00\x01$\xf8'), (1000000, 2, False, 0, b'\x00\x0fB@'), (1000000, 2, True, 0, b'\x00\x0fB@'), (2147483647, 2, False, 0, b'\x7f\xff\xff\xff'), (2147483647, 2, True, 0, b'\x7f\xff\xff\xff'), (2147483648, 2, False, 0, b'\x80\x00\x00\x00'), (4294967295, 2, False, 0, b'\xff\xff\xff\xff'), (-1, 2, True, 0, b'\xff\xff\xff\xff'), (-2147483648, 2, True, 0, b'\x80\x00\x00\x00'), (-200000000, 2, True, 0, b'\xf4\x14>\x00'), (2923517522, 2, False, 0, b'\xaeAVR'), (-1371449774, 2, True, 0, b'\xaeAVR'), (2923517522, 2, False, 1, b'RVA\xae'), (2923517522, 2, False, 3, b'VR\xaeA'), (2923517522, 2, False, 2, b'A\xaeRV'), (0, 4, True, 0, b'\x00\x00\x00\x00\x00\x00\x00\x00'), (0, 4, False, 0, b'\x00\x00\x00\x00\x00\x00\x00\x00'), (1, 4, True, 0, b'\x00\x00\x00\x00\x00\x00\x00\x01'), (1, 4, False, 0, b'\x00\x00\x00\x00\x00\x00\x00\x01'), (-1, 4, True, 0, b'\xff\xff\xff\xff\xff\xff\xff\xff')]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestSanityLong(methodName='runTest')[source]
known_values = [(0, 2, True, 0, b'\x00\x00\x00\x00'), (1, 2, False, 0, b'\x00\x00\x00\x01'), (1, 2, True, 0, b'\x00\x00\x00\x01'), (2, 2, False, 0, b'\x00\x00\x00\x02'), (2, 2, True, 0, b'\x00\x00\x00\x02'), (75000, 2, False, 0, b'\x00\x01$\xf8'), (75000, 2, True, 0, b'\x00\x01$\xf8'), (1000000, 2, False, 0, b'\x00\x0fB@'), (1000000, 2, True, 0, b'\x00\x0fB@'), (2147483647, 2, False, 0, b'\x7f\xff\xff\xff'), (2147483647, 2, True, 0, b'\x7f\xff\xff\xff'), (2147483648, 2, False, 0, b'\x80\x00\x00\x00'), (4294967295, 2, False, 0, b'\xff\xff\xff\xff'), (-1, 2, True, 0, b'\xff\xff\xff\xff'), (-2147483648, 2, True, 0, b'\x80\x00\x00\x00'), (-200000000, 2, True, 0, b'\xf4\x14>\x00'), (2923517522, 2, False, 0, b'\xaeAVR'), (-1371449774, 2, True, 0, b'\xaeAVR'), (2923517522, 2, False, 1, b'RVA\xae'), (2923517522, 2, False, 3, b'VR\xaeA'), (2923517522, 2, False, 2, b'A\xaeRV'), (0, 4, True, 0, b'\x00\x00\x00\x00\x00\x00\x00\x00'), (0, 4, False, 0, b'\x00\x00\x00\x00\x00\x00\x00\x00'), (1, 4, True, 0, b'\x00\x00\x00\x00\x00\x00\x00\x01'), (1, 4, False, 0, b'\x00\x00\x00\x00\x00\x00\x00\x01'), (-1, 4, True, 0, b'\xff\xff\xff\xff\xff\xff\xff\xff')]
testSanity() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestFloatToBytes(methodName='runTest')[source]
known_values = [(1, 2, 0, b'?\x80\x00\x00'), (1.0, 2, 0, b'?\x80\x00\x00'), (1.0, 2, 0, b'?\x80\x00\x00'), (1.1, 2, 0, b'?\x8c\xcc\xcd'), (100, 2, 0, b'B\xc8\x00\x00'), (100.0, 2, 0, b'B\xc8\x00\x00'), (100000.0, 2, 0, b'G\xc3P\x00'), (1100000000.0, 2, 0, b'N\x83!V'), (1e+16, 2, 0, b'Z\x0e\x1b\xca'), (1.5e+16, 2, 0, b'ZU)\xaf'), (3.65e+30, 2, 0, b'r8G%'), (-1.1, 2, 0, b'\xbf\x8c\xcc\xcd'), (-2, 2, 0, b'\xc0\x00\x00\x00'), (-3.6e+30, 2, 0, b'\xf25\xc0\xe9'), (1.0, 4, 0, b'?\xf0\x00\x00\x00\x00\x00\x00'), (2, 4, 0, b'@\x00\x00\x00\x00\x00\x00\x00'), (1100000000.0, 4, 0, b'A\xd0d*\xc0\x00\x00\x00'), (3.65e+30, 4, 0, b'FG\x08\xe4\x9e/Mb'), (2.42e+300, 4, 0, b'~L\xe8\xa5g\x1fF\xa0'), (-1.1, 4, 0, b'\xbf\xf1\x99\x99\x99\x99\x99\x9a'), (-2, 4, 0, b'\xc0\x00\x00\x00\x00\x00\x00\x00'), (-3.6e+30, 4, 0, b'\xc6F\xb8\x1d\x1aC\xb2\x06'), (-3.6e+30, 4, 1, b'\x06\xb2C\x1a\x1d\xb8F\xc6'), (-3.6e+30, 4, 2, b'F\xc6\x1d\xb8C\x1a\x06\xb2'), (-3.6e+30, 4, 3, b'\xb2\x06\x1aC\xb8\x1d\xc6F'), (-4.3959787e-11, 2, 0, b'\xaeAVR'), (-4.3959787e-11, 2, 1, b'RVA\xae'), (-4.3959787e-11, 2, 2, b'A\xaeRV'), (-4.3959787e-11, 2, 3, b'VR\xaeA'), (123456.0, 2, 0, b'G\xf1 \x00'), (123456.0, 2, 1, b'\x00 \xf1G')]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestBytesToFloat(methodName='runTest')[source]
known_values = [(1, 2, 0, b'?\x80\x00\x00'), (1.0, 2, 0, b'?\x80\x00\x00'), (1.0, 2, 0, b'?\x80\x00\x00'), (1.1, 2, 0, b'?\x8c\xcc\xcd'), (100, 2, 0, b'B\xc8\x00\x00'), (100.0, 2, 0, b'B\xc8\x00\x00'), (100000.0, 2, 0, b'G\xc3P\x00'), (1100000000.0, 2, 0, b'N\x83!V'), (1e+16, 2, 0, b'Z\x0e\x1b\xca'), (1.5e+16, 2, 0, b'ZU)\xaf'), (3.65e+30, 2, 0, b'r8G%'), (-1.1, 2, 0, b'\xbf\x8c\xcc\xcd'), (-2, 2, 0, b'\xc0\x00\x00\x00'), (-3.6e+30, 2, 0, b'\xf25\xc0\xe9'), (1.0, 4, 0, b'?\xf0\x00\x00\x00\x00\x00\x00'), (2, 4, 0, b'@\x00\x00\x00\x00\x00\x00\x00'), (1100000000.0, 4, 0, b'A\xd0d*\xc0\x00\x00\x00'), (3.65e+30, 4, 0, b'FG\x08\xe4\x9e/Mb'), (2.42e+300, 4, 0, b'~L\xe8\xa5g\x1fF\xa0'), (-1.1, 4, 0, b'\xbf\xf1\x99\x99\x99\x99\x99\x9a'), (-2, 4, 0, b'\xc0\x00\x00\x00\x00\x00\x00\x00'), (-3.6e+30, 4, 0, b'\xc6F\xb8\x1d\x1aC\xb2\x06'), (-3.6e+30, 4, 1, b'\x06\xb2C\x1a\x1d\xb8F\xc6'), (-3.6e+30, 4, 2, b'F\xc6\x1d\xb8C\x1a\x06\xb2'), (-3.6e+30, 4, 3, b'\xb2\x06\x1aC\xb8\x1d\xc6F'), (-4.3959787e-11, 2, 0, b'\xaeAVR'), (-4.3959787e-11, 2, 1, b'RVA\xae'), (-4.3959787e-11, 2, 2, b'A\xaeRV'), (-4.3959787e-11, 2, 3, b'VR\xaeA'), (123456.0, 2, 0, b'G\xf1 \x00'), (123456.0, 2, 1, b'\x00 \xf1G')]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestSanityFloat(methodName='runTest')[source]
known_values = [(1, 2, 0, b'?\x80\x00\x00'), (1.0, 2, 0, b'?\x80\x00\x00'), (1.0, 2, 0, b'?\x80\x00\x00'), (1.1, 2, 0, b'?\x8c\xcc\xcd'), (100, 2, 0, b'B\xc8\x00\x00'), (100.0, 2, 0, b'B\xc8\x00\x00'), (100000.0, 2, 0, b'G\xc3P\x00'), (1100000000.0, 2, 0, b'N\x83!V'), (1e+16, 2, 0, b'Z\x0e\x1b\xca'), (1.5e+16, 2, 0, b'ZU)\xaf'), (3.65e+30, 2, 0, b'r8G%'), (-1.1, 2, 0, b'\xbf\x8c\xcc\xcd'), (-2, 2, 0, b'\xc0\x00\x00\x00'), (-3.6e+30, 2, 0, b'\xf25\xc0\xe9'), (1.0, 4, 0, b'?\xf0\x00\x00\x00\x00\x00\x00'), (2, 4, 0, b'@\x00\x00\x00\x00\x00\x00\x00'), (1100000000.0, 4, 0, b'A\xd0d*\xc0\x00\x00\x00'), (3.65e+30, 4, 0, b'FG\x08\xe4\x9e/Mb'), (2.42e+300, 4, 0, b'~L\xe8\xa5g\x1fF\xa0'), (-1.1, 4, 0, b'\xbf\xf1\x99\x99\x99\x99\x99\x9a'), (-2, 4, 0, b'\xc0\x00\x00\x00\x00\x00\x00\x00'), (-3.6e+30, 4, 0, b'\xc6F\xb8\x1d\x1aC\xb2\x06'), (-3.6e+30, 4, 1, b'\x06\xb2C\x1a\x1d\xb8F\xc6'), (-3.6e+30, 4, 2, b'F\xc6\x1d\xb8C\x1a\x06\xb2'), (-3.6e+30, 4, 3, b'\xb2\x06\x1aC\xb8\x1d\xc6F'), (-4.3959787e-11, 2, 0, b'\xaeAVR'), (-4.3959787e-11, 2, 1, b'RVA\xae'), (-4.3959787e-11, 2, 2, b'A\xaeRV'), (-4.3959787e-11, 2, 3, b'VR\xaeA'), (123456.0, 2, 0, b'G\xf1 \x00'), (123456.0, 2, 1, b'\x00 \xf1G')]
testSanity() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestValuelistToBytes(methodName='runTest')[source]
known_values = [([1], 1, b'\x00\x01'), ([0, 0], 2, b'\x00\x00\x00\x00'), ([1, 2], 2, b'\x00\x01\x00\x02'), ([1, 256], 2, b'\x00\x01\x01\x00'), ([1, 2, 3, 4], 4, b'\x00\x01\x00\x02\x00\x03\x00\x04'), ([1, 2, 3, 4, 5], 5, b'\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05')]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestBytesToValuelist(methodName='runTest')[source]
known_values = [([1], 1, b'\x00\x01'), ([0, 0], 2, b'\x00\x00\x00\x00'), ([1, 2], 2, b'\x00\x01\x00\x02'), ([1, 256], 2, b'\x00\x01\x01\x00'), ([1, 2, 3, 4], 4, b'\x00\x01\x00\x02\x00\x03\x00\x04'), ([1, 2, 3, 4, 5], 5, b'\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05')]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestSanityValuelist(methodName='runTest')[source]
known_values = [([1], 1, b'\x00\x01'), ([0, 0], 2, b'\x00\x00\x00\x00'), ([1, 2], 2, b'\x00\x01\x00\x02'), ([1, 256], 2, b'\x00\x01\x01\x00'), ([1, 2, 3, 4], 4, b'\x00\x01\x00\x02\x00\x03\x00\x04'), ([1, 2, 3, 4, 5], 5, b'\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05')]
testSanity() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestTextstringToBytes(methodName='runTest')[source]
known_values = [('A', 1, b'A '), ('AB', 1, b'AB'), ('ABC', 2, b'ABC '), ('ABCD', 2, b'ABCD'), ('A', 16, b'A '), ('A', 32, b'A '), ('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 123, b'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestBytesToTextstring(methodName='runTest')[source]
known_values = [('A', 1, b'A '), ('AB', 1, b'AB'), ('ABC', 2, b'ABC '), ('ABCD', 2, b'ABCD'), ('A', 16, b'A '), ('A', 32, b'A '), ('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 123, b'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestSanityTextstring(methodName='runTest')[source]
known_values = [('A', 1, b'A '), ('AB', 1, b'AB'), ('ABC', 2, b'ABC '), ('ABCD', 2, b'ABCD'), ('A', 16, b'A '), ('A', 32, b'A '), ('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 123, b'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')]
testSanity() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestPack(methodName='runTest')[source]
known_values = [(-77, '>h', b'\xff\xb3'), (-1, '>h', b'\xff\xff'), (-770, '>h', b'\xfc\xfe'), (-32768, '>h', b'\x80\x00'), (32767, '>h', b'\x7f\xff'), (770, '>H', b'\x03\x02'), (65535, '>H', b'\xff\xff'), (75000, '>l', b'\x00\x01$\xf8'), (-1, '>l', b'\xff\xff\xff\xff'), (-2147483648, '>l', b'\x80\x00\x00\x00'), (-200000000, '>l', b'\xf4\x14>\x00'), (1, '>L', b'\x00\x00\x00\x01'), (75000, '>L', b'\x00\x01$\xf8'), (2147483648, '>L', b'\x80\x00\x00\x00'), (2147483647, '>L', b'\x7f\xff\xff\xff'), (1.0, '>f', b'?\x80\x00\x00'), (100000.0, '>f', b'G\xc3P\x00'), (1e+16, '>f', b'Z\x0e\x1b\xca'), (3.65e+30, '>f', b'r8G%'), (-2, '>f', b'\xc0\x00\x00\x00'), (-3.6e+30, '>f', b'\xf25\xc0\xe9'), (1.0, '>d', b'?\xf0\x00\x00\x00\x00\x00\x00'), (2, '>d', b'@\x00\x00\x00\x00\x00\x00\x00'), (1100000000.0, '>d', b'A\xd0d*\xc0\x00\x00\x00'), (3.65e+30, '>d', b'FG\x08\xe4\x9e/Mb'), (2.42e+300, '>d', b'~L\xe8\xa5g\x1fF\xa0'), (-1.1, '>d', b'\xbf\xf1\x99\x99\x99\x99\x99\x9a'), (-2, '>d', b'\xc0\x00\x00\x00\x00\x00\x00\x00')]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestUnpack(methodName='runTest')[source]
known_values = [(-77, '>h', b'\xff\xb3'), (-1, '>h', b'\xff\xff'), (-770, '>h', b'\xfc\xfe'), (-32768, '>h', b'\x80\x00'), (32767, '>h', b'\x7f\xff'), (770, '>H', b'\x03\x02'), (65535, '>H', b'\xff\xff'), (75000, '>l', b'\x00\x01$\xf8'), (-1, '>l', b'\xff\xff\xff\xff'), (-2147483648, '>l', b'\x80\x00\x00\x00'), (-200000000, '>l', b'\xf4\x14>\x00'), (1, '>L', b'\x00\x00\x00\x01'), (75000, '>L', b'\x00\x01$\xf8'), (2147483648, '>L', b'\x80\x00\x00\x00'), (2147483647, '>L', b'\x7f\xff\xff\xff'), (1.0, '>f', b'?\x80\x00\x00'), (100000.0, '>f', b'G\xc3P\x00'), (1e+16, '>f', b'Z\x0e\x1b\xca'), (3.65e+30, '>f', b'r8G%'), (-2, '>f', b'\xc0\x00\x00\x00'), (-3.6e+30, '>f', b'\xf25\xc0\xe9'), (1.0, '>d', b'?\xf0\x00\x00\x00\x00\x00\x00'), (2, '>d', b'@\x00\x00\x00\x00\x00\x00\x00'), (1100000000.0, '>d', b'A\xd0d*\xc0\x00\x00\x00'), (3.65e+30, '>d', b'FG\x08\xe4\x9e/Mb'), (2.42e+300, '>d', b'~L\xe8\xa5g\x1fF\xa0'), (-1.1, '>d', b'\xbf\xf1\x99\x99\x99\x99\x99\x9a'), (-2, '>d', b'\xc0\x00\x00\x00\x00\x00\x00\x00')]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestSwap(methodName='runTest')[source]
known_values = [(b'', b''), (b'AB', b'BA'), (b'ABCD', b'BADC'), (b'ABCDEF', b'BADCFE'), (b'ABCDEFGH', b'BADCFEHG'), (b'ABCDEFGHIJ', b'BADCFEHGJI'), (b'ABCDEFGHIJKL', b'BADCFEHGJILK')]
wrongValues = [b'A', b'ABC', b'ABCDE', b'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA']
testKnownValues() → None[source]
testWrongValues() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestSanityPackUnpack(methodName='runTest')[source]
known_values = [(-77, '>h', b'\xff\xb3'), (-1, '>h', b'\xff\xff'), (-770, '>h', b'\xfc\xfe'), (-32768, '>h', b'\x80\x00'), (32767, '>h', b'\x7f\xff'), (770, '>H', b'\x03\x02'), (65535, '>H', b'\xff\xff'), (75000, '>l', b'\x00\x01$\xf8'), (-1, '>l', b'\xff\xff\xff\xff'), (-2147483648, '>l', b'\x80\x00\x00\x00'), (-200000000, '>l', b'\xf4\x14>\x00'), (1, '>L', b'\x00\x00\x00\x01'), (75000, '>L', b'\x00\x01$\xf8'), (2147483648, '>L', b'\x80\x00\x00\x00'), (2147483647, '>L', b'\x7f\xff\xff\xff'), (1.0, '>f', b'?\x80\x00\x00'), (100000.0, '>f', b'G\xc3P\x00'), (1e+16, '>f', b'Z\x0e\x1b\xca'), (3.65e+30, '>f', b'r8G%'), (-2, '>f', b'\xc0\x00\x00\x00'), (-3.6e+30, '>f', b'\xf25\xc0\xe9'), (1.0, '>d', b'?\xf0\x00\x00\x00\x00\x00\x00'), (2, '>d', b'@\x00\x00\x00\x00\x00\x00\x00'), (1100000000.0, '>d', b'A\xd0d*\xc0\x00\x00\x00'), (3.65e+30, '>d', b'FG\x08\xe4\x9e/Mb'), (2.42e+300, '>d', b'~L\xe8\xa5g\x1fF\xa0'), (-1.1, '>d', b'\xbf\xf1\x99\x99\x99\x99\x99\x9a'), (-2, '>d', b'\xc0\x00\x00\x00\x00\x00\x00\x00')]
testSanity() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestHexencode(methodName='runTest')[source]
known_values = [(b'', False, b''), (b'7', False, b'37'), (b'J', False, b'4A'), (b']', False, b'5D'), (b'\x04', False, b'04'), (b'\x04]', False, b'045D'), (b'mn', False, b'6D6E'), (b'Katt1', False, b'4B61747431'), (b'', True, b''), (b'7', True, b'37'), (b'J', True, b'4A'), (b']', True, b'5D'), (b'\x04', True, b'04'), (b'\x04]', True, b'04 5D'), (b'mn', True, b'6D 6E'), (b'Katt1', True, b'4B 61 74 74 31')]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestHexdecode(methodName='runTest')[source]
known_values = [(b'', False, b''), (b'7', False, b'37'), (b'J', False, b'4A'), (b']', False, b'5D'), (b'\x04', False, b'04'), (b'\x04]', False, b'045D'), (b'mn', False, b'6D6E'), (b'Katt1', False, b'4B61747431'), (b'', True, b''), (b'7', True, b'37'), (b'J', True, b'4A'), (b']', True, b'5D'), (b'\x04', True, b'04'), (b'\x04]', True, b'04 5D'), (b'mn', True, b'6D 6E'), (b'Katt1', True, b'4B 61 74 74 31')]
testKnownValues() → None[source]
testAllowLowercase() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestSanityHexencodeHexdecode(methodName='runTest')[source]
known_values = [(b'', False, b''), (b'7', False, b'37'), (b'J', False, b'4A'), (b']', False, b'5D'), (b'\x04', False, b'04'), (b'\x04]', False, b'045D'), (b'mn', False, b'6D6E'), (b'Katt1', False, b'4B61747431'), (b'', True, b''), (b'7', True, b'37'), (b'J', True, b'4A'), (b']', True, b'5D'), (b'\x04', True, b'04'), (b'\x04]', True, b'04 5D'), (b'mn', True, b'6D 6E'), (b'Katt1', True, b'4B 61 74 74 31')]
testKnownValues() → None[source]
testKnownValuesLoop() → None[source]

Loop through all bytes objects of length two.

_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestDescribeBytes(methodName='runTest')[source]
testKnownValues() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestTwosComplement(methodName='runTest')[source]
known_values = [(0, 8, 0), (1, 8, 1), (127, 8, 127), (-128, 8, 128), (-127, 8, 129), (-1, 8, 255), (0, 16, 0), (1, 16, 1), (32767, 16, 32767), (-32768, 16, 32768), (-32767, 16, 32769), (-1, 16, 65535)]
testKnownValues() → None[source]
testOutOfRange() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestFromTwosComplement(methodName='runTest')[source]
known_values = [(0, 8, 0), (1, 8, 1), (127, 8, 127), (-128, 8, 128), (-127, 8, 129), (-1, 8, 255), (0, 16, 0), (1, 16, 1), (32767, 16, 32767), (-32768, 16, 32768), (-32767, 16, 32769), (-1, 16, 65535)]
testKnownValues() → None[source]
testOutOfRange() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestSanityTwosComplement(methodName='runTest')[source]
known_values = [1, 2, 4, 8, 12, 16]
testSanity() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestSetBitOn(methodName='runTest')[source]
known_values = [(4, 0, 5), (4, 1, 6), (1, 1, 3)]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCheckBit(methodName='runTest')[source]
known_values = [(0, 0, False), (0, 1, False), (0, 2, False), (0, 3, False), (0, 4, False), (0, 5, False), (0, 6, False), (4, 0, False), (4, 1, False), (4, 2, True), (4, 3, False), (4, 4, False), (4, 5, False), (4, 5, False)]
testKnownValues() → None[source]
testWrongInputValue() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCalculateCrc(methodName='runTest')[source]
known_values = [(b'\x02\x07', b'A\x12'), (b'ABCDE', b'\x0fP')]
testKnownValues() → None[source]
testCalculationTime() → None[source]
testNotByteInput() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCalculateLrc(methodName='runTest')[source]
known_values = [(b'ABCDE', b'\xb1'), (b'\x02001#\x03', b'G')]
testKnownValues() → None[source]
testNotStringInput() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCheckFunctioncode(methodName='runTest')[source]
testCorrectFunctioncode() → None[source]
testCorrectFunctioncodeNoRange() → None[source]
testWrongFunctioncode() → None[source]
testWrongFunctioncodeNoRange() → None[source]
testWrongFunctioncodeType() → None[source]
testWrongFunctioncodeListValues() → None[source]
testWrongListType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCheckSlaveaddress(methodName='runTest')[source]
testKnownValues() → None[source]
testWrongValues() → None[source]
testNotIntegerInput() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCheckMode(methodName='runTest')[source]
testKnownValues() → None[source]
testWrongValues() → None[source]
testNotIntegerInput() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCheckRegisteraddress(methodName='runTest')[source]
testKnownValues() → None[source]
testWrongValues() → None[source]
testWrongType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCheckResponseSlaveErrorCode(methodName='runTest')[source]
testResponsesWithoutErrors() → None[source]
testResponsesWithErrors() → None[source]
testTooShortResponses() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCheckResponseNumberOfBytes(methodName='runTest')[source]
testCorrectNumberOfBytes() → None[source]
testWrongNumberOfBytes() → None[source]
testNotByteInput() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCheckResponseRegisterAddress(methodName='runTest')[source]
testCorrectResponseRegisterAddress() → None[source]
testTooShortString() → None[source]
testNotString() → None[source]
testWrongResponseRegisterAddress() → None[source]
testInvalidAddress() → None[source]
testAddressNotInteger() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCheckResponsenumber_of_registers(methodName='runTest')[source]
testCorrectResponsenumber_of_registers() → None[source]
testTooShortString() → None[source]
testNotString() → None[source]
testWrongResponsenumber_of_registers() → None[source]
testInvalidResponsenumber_of_registersRange() → None[source]
testnumber_of_registersNotInteger() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCheckResponseWriteData(methodName='runTest')[source]
testCorrectResponseWritedata() → None[source]
testWrongResponseWritedata() → None[source]
testNotString() → None[source]
testTooShortPayload() → None[source]
testInvalidReferenceData() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCheckString(methodName='runTest')[source]
testKnownValues() → None[source]
testTooShort() → None[source]
testTooLong() → None[source]
testNotAscii() → None[source]
testInconsistentLengthlimits() → None[source]
testInputNotString() → None[source]
testNotIntegerInput() → None[source]
testDescriptionNotString() → None[source]
testWrongCustomError() → None[source]
testCustomError() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCheckBytes(methodName='runTest')[source]
testKnownValues() → None[source]
testTooShort() → None[source]
testTooLong() → None[source]
testInconsistentLengthlimits() → None[source]
testInputNotBytes() → None[source]
testNotIntegerInput() → None[source]
testDescriptionNotString() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCheckInt(methodName='runTest')[source]
testKnownValues() → None[source]
testTooLargeValue() → None[source]
testTooSmallValue() → None[source]
testInconsistentLimits() → None[source]
testWrongInputType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCheckNumerical(methodName='runTest')[source]
testKnownValues() → None[source]
testTooLargeValue() → None[source]
testTooSmallValue() → None[source]
testInconsistentLimits() → None[source]
testNotNumericInput() → None[source]
testDescriptionNotString() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestCheckBool(methodName='runTest')[source]
testKnownValues() → None[source]
testWrongType() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestGetDiagnosticString(methodName='runTest')[source]
testReturnsString() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestDummyCommunication(methodName='runTest')[source]
setUp() → None[source]

Hook method for setting up the test fixture before exercising it.

testReadBit() → None[source]
testReadBitWrongValue() → None[source]
testReadBitWrongType() → None[source]
testReadBitWithWrongByteCountResponse() → None[source]
testReadBitWithNoResponse() → None[source]
testWriteBit() → None[source]
testWriteBitWrongValue() → None[source]
testWriteBitWrongType() → None[source]
testWriteBitWithWrongRegisternumbersResponse() → None[source]
testWriteBitWithWrongWritedataResponse() → None[source]
testReadBits() → None[source]
testReadBitsWrongValue() → None[source]
testWriteBits() → None[source]
testWriteBitsWrongValue() → None[source]
testReadRegister() → None[source]
testReadRegisterWrongValue() → None[source]
testReadRegisterWrongType() → None[source]
testWriteRegister() → None[source]
testWriteRegisterWithDecimals() → None[source]
testWriteRegisterWrongValue() → None[source]
testWriteRegisterWrongType() → None[source]
testWriteRegisterWithWrongCrcResponse() → None[source]
testWriteRegisterSuppressErrorMessageAtWrongCRC() → None[source]
testWriteRegisterWithWrongSlaveaddressResponse() → None[source]
testWriteRegisterWithWrongFunctioncodeResponse() → None[source]
testWriteRegisterWithWrongRegisteraddressResponse() → None[source]
testWriteRegisterWithWrongRegisternumbersResponse() → None[source]
testWriteRegisterWithWrongWritedataResponse() → None[source]
testReadLong() → None[source]
testReadLongWrongValue() → None[source]
testReadLongWrongType() → None[source]
testWriteLong() → None[source]
testWriteLongWrongValue() → None[source]
testWriteLongWrongType() → None[source]
testReadFloat() → None[source]
testReadFloatWrongValue() → None[source]
testReadFloatWrongType() → None[source]
testWriteFloat() → None[source]
testWriteFloatWrongValue() → None[source]
testWriteFloatWrongType() → None[source]
testReadString() → None[source]
testReadStringWrongValue() → None[source]
testReadStringWrongType() → None[source]
testWriteString() → None[source]
testWriteStringWrongValue() → None[source]
testWriteStringWrongType() → None[source]
testReadRegisters() → None[source]
testReadRegistersWrongValue() → None[source]
testReadRegistersWrongType() → None[source]
testWriteRegisters() → None[source]
testWriteRegistersWrongValue() → None[source]
testWriteRegistersWrongType() → None[source]
testGenericCommand() → None[source]
testGenericCommandWrongValue() → None[source]
testGenericCommandWrongType() → None[source]
testGenericCommandWrongValueCombinations() → None[source]
testPerformcommandKnownResponse() → None[source]
testPerformcommandWrongSlaveResponse() → None[source]
testPerformcommandWrongInputValue() → None[source]
testPerformcommandWrongInputType() → None[source]
testCommunicateKnownResponse() → None[source]
testCommunicateWrongType() → None[source]
testCommunicateNoMessage() → None[source]
testCommunicateNoSerialPort() → None[source]
testCommunicateNoResponse() → None[source]
testCommunicateLocalEcho() → None[source]
testCommunicateWrongLocalEcho() → None[source]
testPortWillBeOpened() → None[source]
testMeasureRoundtriptime() → None[source]
testRepresentation() → None[source]
testReadPortClosed() → None[source]
testPortAlreadyOpen() → None[source]
testPortAlreadyClosed() → None[source]
tearDown() → None[source]

Hook method for deconstructing the test fixture after testing it.

_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestDummyCommunicationOmegaSlave1(methodName='runTest')[source]
setUp() → None[source]

Hook method for setting up the test fixture before exercising it.

testReadBit() → None[source]
testWriteBit() → None[source]
testReadRegister() → None[source]
testWriteRegister() → None[source]
tearDown() → None[source]

Hook method for deconstructing the test fixture after testing it.

_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestDummyCommunicationOmegaSlave10(methodName='runTest')[source]
setUp() → None[source]

Hook method for setting up the test fixture before exercising it.

testReadBit() → None[source]
testWriteBit() → None[source]
testReadRegister() → None[source]
testWriteRegister() → None[source]
tearDown() → None[source]

Hook method for deconstructing the test fixture after testing it.

_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestDummyCommunicationDTB4824_RTU(methodName='runTest')[source]
setUp() → None[source]

Hook method for setting up the test fixture before exercising it.

testReadBit() → None[source]
testWriteBit() → None[source]
testReadBits() → None[source]
testReadRegister() → None[source]
testReadRegisters() → None[source]
testWriteRegister() → None[source]
tearDown() → None[source]

Hook method for deconstructing the test fixture after testing it.

_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestDummyCommunicationDTB4824_ASCII(methodName='runTest')[source]
setUp() → None[source]

Hook method for setting up the test fixture before exercising it.

testReadBit() → None[source]
testWriteBit() → None[source]
testReadBits() → None[source]
testReadRegister() → None[source]
testReadRegisters() → None[source]
testWriteRegister() → None[source]
tearDown() → None[source]

Hook method for deconstructing the test fixture after testing it.

_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestDummyCommunicationWithPortClosure(methodName='runTest')[source]
setUp() → None[source]

Hook method for setting up the test fixture before exercising it.

testReadRegisterSeveralTimes() → None[source]
testPortAlreadyClosed() → None[source]
tearDown() → None[source]

Hook method for deconstructing the test fixture after testing it.

_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestVerboseDummyCommunicationWithPortClosure(methodName='runTest')[source]
setUp() → None[source]

Hook method for setting up the test fixture before exercising it.

testReadRegister() → None[source]
tearDown() → None[source]

Hook method for deconstructing the test fixture after testing it.

_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestVerboseDummyCommunicationNoBufferClearing(methodName='runTest')[source]
setUp() → None[source]

Hook method for setting up the test fixture before exercising it.

testReadRegister() → None[source]
tearDown() → None[source]

Hook method for deconstructing the test fixture after testing it.

_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestVerboseDummyCommunicationNoCalculateReadSize(methodName='runTest')[source]
setUp() → None[source]

Hook method for setting up the test fixture before exercising it.

testReadRegister() → None[source]
tearDown() → None[source]

Hook method for deconstructing the test fixture after testing it.

_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestDummyCommunicationBroadcast(methodName='runTest')[source]
setUp() → None[source]

Hook method for setting up the test fixture before exercising it.

testWriteRegister() → None[source]
testReadingNotAllowed() → None[source]
tearDown() → None[source]

Hook method for deconstructing the test fixture after testing it.

_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestDummyCommunicationThreeInstrumentsPortClosure(methodName='runTest')[source]
setUp() → None[source]

Hook method for setting up the test fixture before exercising it.

testCommunication() → None[source]
tearDown() → None[source]

Hook method for deconstructing the test fixture after testing it.

_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestDummyCommunicationHandleLocalEcho(methodName='runTest')[source]
setUp() → None[source]

Hook method for setting up the test fixture before exercising it.

testReadRegister() → None[source]
testReadRegisterWrongEcho() → None[source]
tearDown() → None[source]

Hook method for deconstructing the test fixture after testing it.

_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestDummyCommunicationExternalSerialPort(methodName='runTest')[source]
setUp() → None[source]

Hook method for setting up the test fixture before exercising it.

testReadRegister() → None[source]
tearDown() → None[source]

Hook method for deconstructing the test fixture after testing it.

_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestDummyCommunicationExternalSerialPortFailsToOpen(methodName='runTest')[source]
testInitialise() → None[source]
_classSetupFailed = False
_class_cleanups = []
class test_minimalmodbus.TestDummyCommunicationExternalSerialPortWrongType(methodName='runTest')[source]
testInitialiseSerialPortInteger() → None[source]
testInitialiseSerialPortNone() → None[source]
_classSetupFailed = False
_class_cleanups = []
test_minimalmodbus.WRONG_ASCII_RESPONSES = {}

A dictionary of respones from a dummy instrument.

The key is the message (string) sent to the serial port, and the item is the response (string) from the dummy serial port.