def test_view_delattr(attr, subset_func):
    base = gen_adata((10, 10))
    orig_hash = joblib.hash(base)
    subset = base[subset_func(base.obs_names), subset_func(base.var_names)]
    empty = ad.AnnData(obs=subset.obs[[]], var=subset.var[[]])

    delattr(subset, attr)

    assert not subset.is_view
    # Should now have same value as default
    assert_equal(getattr(subset, attr), getattr(empty, attr))
    assert orig_hash == joblib.hash(base)  # Original should not be modified
def test_validate_question_suggestion_count_fails_for_negative_count(self):
        community_contribution_stats = (
            suggestion_services.get_community_contribution_stats()
        )
        community_contribution_stats.question_suggestion_count = (
            self.negative_count
        )

        with self.assertRaisesRegex(
            utils.ValidationError,
            'Expected the question suggestion count to be non-negative, '
            'received: %s.' % (
                community_contribution_stats.question_suggestion_count)
        ):
            community_contribution_stats.validate()