| 101 | |
| 102 | |
| 103 | def test_invalid_terms(temp_hdfstore): |
| 104 | df = DataFrame( |
| 105 | np.random.default_rng(2).standard_normal((10, 4)), |
| 106 | columns=Index(list("ABCD"), dtype=object), |
| 107 | index=date_range("2000-01-01", periods=10, freq="B", unit="ns"), |
| 108 | ) |
| 109 | df["string"] = "foo" |
| 110 | df.loc[df.index[0:4], "string"] = "bar" |
| 111 | |
| 112 | temp_hdfstore.put("df", df, format="table") |
| 113 | |
| 114 | # some invalid terms |
| 115 | msg = re.escape("__init__() missing 1 required positional argument: 'where'") |
| 116 | with pytest.raises(TypeError, match=msg): |
| 117 | Term() |
| 118 | |
| 119 | # more invalid |
| 120 | msg = re.escape( |
| 121 | "cannot process expression [df.index[3]], " |
| 122 | "[2000-01-06 00:00:00] is not a valid condition" |
| 123 | ) |
| 124 | with pytest.raises(ValueError, match=msg): |
| 125 | temp_hdfstore.select("df", "df.index[3]") |
| 126 | |
| 127 | msg = "invalid syntax" |
| 128 | with pytest.raises(SyntaxError, match=msg): |
| 129 | temp_hdfstore.select("df", "index>") |
| 130 | |
| 131 | |
| 132 | def test_invalid_terms_from_docs(temp_h5_path): |