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_when_verbose_and_retcode_is_nonzero_output_should_be_had():
    expected_stderr = "this is something fnord"
    with patch.dict(
        pdbedit.__salt__,
        {
            "cmd.run_all": MagicMock(
                return_value={"stdout": "", "stderr": expected_stderr, "retcode": 1}
            )
        },
    ), patch("salt.modules.pdbedit.log.error", autospec=True) as fake_error_log:
        pdbedit.list_users(verbose=True)
        actual_error = fake_error_log.mock_calls[0].args[0]
        assert actual_error == expected_stderr