@pytest.mark.parametrize(['len_enc', 'len_type', 'max_len', 'len_count', 'pad', 'result', 'result_f2_len'], [('ascii', 2, 8, 'nibbles', '0', b'0200400000000000000003\x01#', b'03'), ('b', 2, 8, 'nibbles', '0', b'02004000000000000000\x00\x03\x01#', b'\x00\x03'), ('ascii', 0, 3, 'nibbles', '0', b'02004000000000000000\x01#', b''), ('ascii', 2, 8, 'nibbles', 'F', b'0200400000000000000003\xf1#', b'03'), ('b', 2, 8, 'nibbles', 'F', b'02004000000000000000\x00\x03\xf1#', b'\x00\x03'), ('ascii', 0, 3, 'nibbles', 'F', b'02004000000000000000\xf1#', b''), ('ascii', 2, 8, 'nibbles', '01', b'0200400000000000000003\x01#', b'03'), ('b', 2, 8, 'nibbles', '01', b'02004000000000000000\x00\x03\x01#', b'\x00\x03'), ('ascii', 0, 3, 'nibbles', '01', b'02004000000000000000\x01#', b''), ('ascii', 2, 8, 'nibbles', 'F1', b'0200400000000000000003\xf1#', b'03'), ('b', 2, 8, 'nibbles', 'F1', b'02004000000000000000\x00\x03\xf1#', b'\x00\x03'), ('ascii', 0, 3, 'nibbles', 'F1', b'02004000000000000000\xf1#', b'')])
def test_encode_nibbles_odd_left_pad(len_enc: str, len_type: int, max_len: int, len_count: str, pad: str, result: bytes, result_f2_len: bytes) -> None:
    spec = copy.deepcopy(iso8583.specs.default)
    spec['t']['data_enc'] = 'ascii'
    spec['p']['data_enc'] = 'ascii'
    spec['2']['data_enc'] = 'b'
    spec['2']['len_enc'] = len_enc
    spec['2']['len_type'] = len_type
    spec['2']['max_len'] = max_len
    spec['2']['len_count'] = len_count
    spec['2']['left_pad'] = pad
    decoded = {'t': '0200', '2': '123'}
    (s, encoded) = iso8583.encode(decoded, spec)
    assert (s == result)
    assert (encoded['2']['len'] == result_f2_len)
@pytest.mark.parametrize(['len_enc', 'len_type', 'max_len', 'len_count', 'pad', 'result', 'result_f2_len'], [('ascii', 2, 8, 'nibbles', '0', b'0200400000000000000003\x01#', b'03'), ('b', 2, 8, 'nibbles', '0', b'02004000000000000000\x00\x03\x01#', b'\x00\x03'), ('ascii', 0, 3, 'nibbles', '0', b'02004000000000000000\x01#', b), ('ascii', 2, 8, 'nibbles', 'F', b'0200400000000000000003\xf1#', b'03'), ('b', 2, 8, 'nibbles', 'F', b'02004000000000000000\x00\x03\xf1#', b'\x00\x03'), ('ascii', 0, 3, 'nibbles', 'F', b'02004000000000000000\xf1#', b), ('ascii', 2, 8, 'nibbles', '01', b'0200400000000000000003\x01#', b'03'), ('b', 2, 8, 'nibbles', '01', b'02004000000000000000\x00\x03\x01#', b'\x00\x03'), ('ascii', 0, 3, 'nibbles', '01', b'02004000000000000000\x01#', b), ('ascii', 2, 8, 'nibbles', 'F1', b'0200400000000000000003\xf1#', b'03'), ('b', 2, 8, 'nibbles', 'F1', b'02004000000000000000\x00\x03\xf1#', b'\x00\x03'), ('ascii', 0, 3, 'nibbles', 'F1', b'02004000000000000000\xf1#', b)])
def test_encode_nibbles_odd_left_pad(len_enc: str, len_type: int, max_len: int, len_count: str, pad: str, result: bytes, result_f2_len: bytes) -> None:
    spec = copy.deepcopy(iso8583.specs.default)
    spec['t']['data_enc'] = 'ascii'
    spec['p']['data_enc'] = 'ascii'
    spec['2']['data_enc'] = 'b'
    spec['2']['len_enc'] = len_enc
    spec['2']['len_type'] = len_type
    spec['2']['max_len'] = max_len
    spec['2']['len_count'] = len_count
    spec['2']['left_pad'] = pad
    decoded = {'t': '0200', '2': '123'}
    (s, encoded) = iso8583.encode(decoded, spec)
    assert (s == result)
    assert (encoded['2']['len'] == result_f2_len)