def METHOD_NAME(group, groups, subgroup, root_user, users):
    group.members.create(
        {"user_id": users[0].id, "access_level": AccessLevel.OWNER.value}
    )
    group.members.delete(root_user.id)
    yield group
    # we are running tests with root's token, so every group is created
    # with a single user - root as owner. we restore the group to
    # this state here.
    group.members.create(
        {"user_id": root_user.id, "access_level": AccessLevel.OWNER.value}
    )
    # we try to remove all users, not just those added above,
    # on purpose, as more may have been added in the tests
    for user in users:
        with allowed_codes(404):
            group.members.delete(user.id)
    with allowed_codes(404):
        group.unshare(subgroup.id)
    for share_with in groups:
        with allowed_codes(404):
            group.unshare(share_with.id)