Skip to content

Commit f42b9ac

Browse files
committed
Add test case
1 parent 20d0964 commit f42b9ac

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/io/test_sql.py

+14
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,20 @@ def test_con_string_import_error(self):
15271527
with pytest.raises(ImportError, match="SQLAlchemy"):
15281528
sql.read_sql("SELECT * FROM iris", conn)
15291529

1530+
@pytest.mark.skipif(SQLALCHEMY_INSTALLED, reason="SQLAlchemy is installed")
1531+
def test_con_unknown_dbapi2_class_does_not_error_without_sql_alchemy_installed(
1532+
self,
1533+
):
1534+
class MockSqliteConnection:
1535+
def __init__(self, *args, **kwargs):
1536+
self.conn = sqlite3.Connection(*args, **kwargs)
1537+
1538+
def __getattr__(self, name):
1539+
return getattr(self.conn, name)
1540+
1541+
conn = MockSqliteConnection(":memory:")
1542+
sql.read_sql("SELECT 1", conn)
1543+
15301544
def test_read_sql_delegate(self):
15311545
iris_frame1 = sql.read_sql_query("SELECT * FROM iris", self.conn)
15321546
iris_frame2 = sql.read_sql("SELECT * FROM iris", self.conn)

0 commit comments

Comments
 (0)