def test_define_holdout_set_str(monkeypatch): dummy_df = pd.DataFrame(dict(a=[0, 1], b=[2, 3])) # noinspection PyUnusedLocal def mock_pandas_read_csv(*args, **kwargs): return dummy_df monkeypatch.setattr(pd, "read_csv", mock_pandas_read_csv) assert define_holdout_set(pd.DataFrame(dict(a=[4], b=[5])), "foo", "x")[1].equals(dummy_df)
def test_define_holdout_set_value_error(holdout_set): with pytest.raises(ValueError, match="Mismatched columns.*"): define_holdout_set(pd.DataFrame(dict(a=[0, 1], b=[2, 3])), pd.DataFrame(holdout_set), "x")
def test_define_holdout_set_file_not_found_error(): with pytest.raises(FileNotFoundError): define_holdout_set(pd.DataFrame(), "foo", "target")
def test_define_holdout_set_type_error(holdout_set): with pytest.raises( TypeError, match="holdout_set must be None, DataFrame, callable, or str,.*"): define_holdout_set(pd.DataFrame(), holdout_set, "target")