Skip to content

Commit 762903c

Browse files
committed
Add test case
1 parent 20d0964 commit 762903c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pandas/tests/io/test_sql.py

+13
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,19 @@ 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(self):
1532+
1533+
class MockSqliteConnection():
1534+
def __init__(self, *args, **kwargs):
1535+
self.conn = sqlite3.Connection(*args, **kwargs)
1536+
1537+
def __getattr__(self, name):
1538+
return getattr(self.conn, name)
1539+
1540+
conn = MockSqliteConnection(":memory:")
1541+
sql.read_sql("SELECT 1", conn)
1542+
15301543
def test_read_sql_delegate(self):
15311544
iris_frame1 = sql.read_sql_query("SELECT * FROM iris", self.conn)
15321545
iris_frame2 = sql.read_sql("SELECT * FROM iris", self.conn)

0 commit comments

Comments
 (0)