MCPcopy
hub / github.com/pandas-dev/pandas / test_invalid_terms

Function test_invalid_terms

pandas/tests/io/pytables/test_errors.py:103–129  ·  view source on GitHub ↗
(temp_hdfstore)

Source from the content-addressed store, hash-verified

101
102
103def 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
132def test_invalid_terms_from_docs(temp_h5_path):

Callers

nothing calls this directly

Calls 7

DataFrameClass · 0.90
IndexClass · 0.90
date_rangeFunction · 0.90
TermClass · 0.90
putMethod · 0.80
raisesMethod · 0.45
selectMethod · 0.45

Tested by

no test coverage detected