def test_decode_nibbles_odd_no_pad() -> 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'] = 'b'
    spec['2']['len_type'] = 2
    spec['2']['max_len'] = 8
    spec['2']['len_count'] = 'nibbles'
    data = b'02004000000000000000\x00\x03\x120'
    with pytest.raises(iso8583.DecodeError, match='Field data is 4 nibbles, expecting 3: field 2 pos 22'):
        iso8583.decode(data, spec=spec)
def test_decode_nibbles_odd_no_pad() -> 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'] = 'b'
    spec['2']['len_type'] = 2
    spec['2']['max_len'] = 8
    spec['2']['len_count'] = 'nibbles'
    data = b'02004000000000000000\x00\x03\x120'
    with pytest.raises(iso8583.DecodeError, match='Field data is 4 nibbles, expecting 3: field 2 pos 22'):
        iso8583.decode(data, spec=spec)