def test_valid_input(arg1, arg2, arg3): expected = bytearray([0xFF, 0xFF, 0x00, 0x22, 0x00, 0x06, (arg1 >> 8), (arg1 & 0xFF), arg2, (arg3 >> 8), (arg3 & 0xFF)]) expected.append((sum(expected[2:]) & 0xFF) ^ 0xFF) request = Sleep(arg1, arg2, arg3) assert request.tobytes() == expected
def test_example_input(): expected = bytearray([0xFF, 0xFF, 0x00, 0x22, 0x00, 0x06, 0x04, 0xD2, 0x38, 0x1E, 0xD2, 0xD9]) request = Sleep(1234, 56, 7890) assert request.tobytes() == expected
def test_input_below_range(arg1, arg2, arg3): request = Sleep(arg1, arg2, arg3) with pytest.raises(ValueError): request.tobytes()