Skip to content

Commit 74209d2

Browse files
authored
TST: Clean pg8000 test (#45164)
1 parent db54c28 commit 74209d2

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

.pre-commit-config.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,9 @@ repos:
175175
entry: python scripts/pandas_errors_documented.py
176176
language: python
177177
files: ^pandas/errors/__init__.py$
178+
- id: pg8000-not-installed-CI
179+
name: Check for pg8000 not installed on CI for test_pg8000_sqlalchemy_passthrough_error
180+
language: pygrep
181+
entry: 'pg8000'
182+
files: ^ci/deps
183+
types: [yaml]

pandas/tests/io/test_sql.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import numpy as np
3232
import pytest
3333

34+
import pandas.util._test_decorators as td
35+
3436
from pandas.core.dtypes.common import (
3537
is_datetime64_dtype,
3638
is_datetime64tz_dtype,
@@ -1423,16 +1425,10 @@ def test_database_uri_string(self, test_frame1):
14231425
tm.assert_frame_equal(test_frame1, test_frame3)
14241426
tm.assert_frame_equal(test_frame1, test_frame4)
14251427

1426-
# using driver that will not be installed on Travis to trigger error
1428+
@td.skip_if_installed("pg8000")
1429+
def test_pg8000_sqlalchemy_passthrough_error(self):
1430+
# using driver that will not be installed on CI to trigger error
14271431
# in sqlalchemy.create_engine -> test passing of this error to user
1428-
try:
1429-
# the rest of this test depends on pg8000's being absent
1430-
import pg8000 # noqa:F401
1431-
1432-
pytest.skip("pg8000 is installed")
1433-
except ImportError:
1434-
pass
1435-
14361432
db_uri = "postgresql+pg8000://user:pass@host/dbname"
14371433
with pytest.raises(ImportError, match="pg8000"):
14381434
sql.read_sql("select * from table", db_uri)

0 commit comments

Comments
 (0)