def test_decode_nibbles_variable_missing() -> None:
    'Variable field is missing'
    spec = copy.deepcopy(iso8583.specs.default)
    spec['t']['data_enc'] = 'ascii'
    spec['p']['data_enc'] = 'ascii'
    spec['2']['data_enc'] = 'ascii'
    spec['2']['len_enc'] = 'ascii'
    spec['2']['len_type'] = 2
    spec['2']['max_len'] = 4
    spec['2']['len_count'] = 'nibbles'
    s = b'0200400000000000000004'
    with pytest.raises(iso8583.DecodeError, match='Field data is 0 nibbles, expecting 4: field 2 pos 22'):
        iso8583.decode(s, spec=spec)
Variable field is missing
def test_decode_nibbles_variable_missing() -> None:
    
    spec = copy.deepcopy(iso8583.specs.default)
    spec['t']['data_enc'] = 'ascii'
    spec['p']['data_enc'] = 'ascii'
    spec['2']['data_enc'] = 'ascii'
    spec['2']['len_enc'] = 'ascii'
    spec['2']['len_type'] = 2
    spec['2']['max_len'] = 4
    spec['2']['len_count'] = 'nibbles'
    s = b'0200400000000000000004'
    with pytest.raises(iso8583.DecodeError, match='Field data is 0 nibbles, expecting 4: field 2 pos 22'):
        iso8583.decode(s, spec=spec)