def METHOD_NAME(context, ipam, prefixlen):
    ifname = context.new_ifname
    ipaddr = getattr(context, ipam)
    ipaddr_fail = getattr(context, ipam)
    (
        context.ndb.interfaces.create(ifname=ifname, kind='dummy', state='up')
        .add_ip(address=ipaddr, prefixlen=prefixlen)
        .commit()
    )
    assert interface_exists(context.netns, ifname=ifname)
    assert address_exists(context.netns, ifname=ifname, address=ipaddr)
    with pytest.raises(KeyError):
        (context.ndb.interfaces[ifname].del_ip(address=ipaddr_fail).commit())
    assert interface_exists(context.netns, ifname=ifname)
    assert address_exists(context.netns, ifname=ifname, address=ipaddr)