Skip to content

Commit f8ae285

Browse files
fix test
1 parent 602194a commit f8ae285

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

pandas/tests/io/test_sql.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4360,22 +4360,33 @@ def test_xsqlite_if_exists(sqlite_buildin):
43604360
drop_table(table_name, sqlite_buildin)
43614361

43624362

4363-
@pytest.mark.parametrize("conn", all_connectable)
4364-
def test_bytes_column(conn, request):
4363+
@pytest.mark.parametrize("con", all_connectable)
4364+
def test_bytes_column(con, request):
43654365
# GitHub Issue #59242
4366-
conn = request.getfixturevalue(conn)
4366+
conn = request.getfixturevalue(con)
43674367
pa = pytest.importorskip("pyarrow")
43684368
for dtype_backend in ["pyarrow", "numpy_nullable", lib.no_default]:
43694369
query = """
43704370
select x'0123456789abcdef0123456789abcdef' a
43714371
"""
43724372
df = pd.read_sql(query, conn, dtype_backend=dtype_backend)
4373+
4374+
dtype = "O"
4375+
if dtype_backend == "pyarrow":
4376+
# sqlite3 + mysql both return a binary type
4377+
# for the binary literal
4378+
dtype = pd.ArrowDtype(pa.binary())
4379+
elif dtype_backend == "pyarrow" and "postgres" in con:
4380+
# postgres column is a bit type
4381+
# but converts to a string when returned
4382+
dtype = pd.ArrowDtype(pa.string())
4383+
43734384
expected = DataFrame(
43744385
[
43754386
{
43764387
"a": b"\x01#Eg\x89\xab\xcd\xef\x01#Eg\x89\xab\xcd\xef",
43774388
}
43784389
],
4379-
dtype=(pd.ArrowDtype(pa.binary()) if dtype_backend == "pyarrow" else "O"),
4390+
dtype=dtype,
43804391
)
43814392
tm.assert_frame_equal(df, expected)

0 commit comments

Comments
 (0)