Skip to content

Commit bcef60e

Browse files
Add test
1 parent 620c0ab commit bcef60e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pandas/tests/io/test_sql.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,25 @@ def test_multiindex_roundtrip(self):
857857
)
858858
tm.assert_frame_equal(df, result, check_index_type=True)
859859

860+
@pytest.mark.parametrize(
861+
"dtype, expected",
862+
[
863+
(None, [float, float]),
864+
(int, [int, int]),
865+
(float, [float, float]),
866+
({"SepalLength": int, "SepalWidth": float}, [int, float]),
867+
],
868+
)
869+
def test_dtype_argument(self, dtype, expected):
870+
# GH10285 Add dtype argument to read_sql_query
871+
result = sql.read_sql_query(
872+
"SELECT SepalLength, SepalWidth FROM iris", self.conn, dtype=dtype
873+
)
874+
assert result.dtypes.to_dict() == {
875+
"SepalLength": expected[0],
876+
"SepalWidth": expected[1],
877+
}
878+
860879
def test_integer_col_names(self):
861880
df = DataFrame([[1, 2], [3, 4]], columns=[0, 1])
862881
sql.to_sql(df, "test_frame_integer_col_names", self.conn, if_exists="replace")

0 commit comments

Comments
 (0)