def test_view_failed_delitem(attr):
    adata = gen_adata((10, 10))
    view = adata[5:7, :][:, :5]
    adata_hash = joblib.hash(adata)
    view_hash = joblib.hash(view)

    with pytest.raises(KeyError):
        getattr(view, attr).__delitem__("not a key")

    assert view.is_view
    assert adata_hash == joblib.hash(adata)
    assert view_hash == joblib.hash(view)
def test_telemetry_imports_catboost(runner, live_mock_server, parse_ctx):
    with runner.isolated_filesystem():
        with mock.patch.dict("sys.modules", {"catboost": mock.Mock()}):
            import catboost

            run = wandb.init()
            run.finish()

            ctx_util = parse_ctx(live_mock_server.get_ctx())
            telemetry = ctx_util.telemetry

            # catboost in both init and finish modules
            assert telemetry and 7 in telemetry.get("1", [])
            assert telemetry and 7 in telemetry.get("2", [])