Skip to content

Commit 52ad0eb

Browse files
committed
Fix missed tests and correct mistake in error message.
1 parent 16a274f commit 52ad0eb

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

pandas/io/pytables.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3528,8 +3528,8 @@ def validate(self, other) -> None:
35283528
if c == "values_axes" and sax.kind != oax.kind:
35293529
raise TypeError(
35303530
f"Cannot serialize the column [{oax.values[0]}] "
3531-
f"because its data contents are not [{oax.kind}] "
3532-
f"but [{sax.kind}] object dtype"
3531+
f"because its data contents are not [{sax.kind}] "
3532+
f"but [{oax.kind}] object dtype"
35333533
)
35343534
# Fallback if other source of difference
35353535
raise ValueError(

pandas/tests/io/pytables/test_append.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,11 @@ def test_append_raise(setup_path):
830830
df["foo"] = Timestamp("20130101")
831831
store.append("df", df)
832832
df["foo"] = "bar"
833-
msg = re.escape("Cannot serialize the column [foo] but [string] object dtype")
833+
msg = re.escape(
834+
"Cannot serialize the column [foo] "
835+
"because its data contents are not [string] "
836+
"but [datetime64[s]] object dtype"
837+
)
834838
with pytest.raises(TypeError, match=msg):
835839
store.append("df", df)
836840

pandas/tests/io/pytables/test_round_trip.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,11 @@ def test_table_values_dtypes_roundtrip(setup_path):
213213

214214
# incompatible dtype
215215
msg = re.escape(
216-
"invalid combination of [values_axes] on appending data "
217-
"[name->values_block_0,cname->values_block_0,"
218-
"dtype->float64,kind->float,shape->(1, 3)] vs "
219-
"current table [name->values_block_0,"
220-
"cname->values_block_0,dtype->int64,kind->integer,"
221-
"shape->None]"
216+
"Cannot serialize the column [a] "
217+
"because its data contents are not [float] "
218+
"but [integer] object dtype"
222219
)
223-
with pytest.raises(ValueError, match=msg):
220+
with pytest.raises(TypeError, match=msg):
224221
store.append("df_i8", df1)
225222

226223
# check creation/storage/retrieval of float32 (a bit hacky to

0 commit comments

Comments
 (0)