def METHOD_NAME(domain_name, allow_domain_requests=False):
    domain = Domain(name=domain_name, is_active=True)
    if allow_domain_requests:
        domain.allow_domain_requests = True
    domain.save()
    try:
        yield
    finally:
        domain.delete()