diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7bc0e1ca62ff3..854b7b2e4fe63 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -175,3 +175,9 @@ repos: entry: python scripts/pandas_errors_documented.py language: python files: ^pandas/errors/__init__.py$ + - id: pg8000-not-installed-CI + name: Check for pg8000 not installed on CI for test_pg8000_sqlalchemy_passthrough_error + language: pygrep + entry: 'pg8000' + files: ^ci/deps + types: [yaml] diff --git a/pandas/tests/io/test_sql.py b/pandas/tests/io/test_sql.py index c1007a01a3829..7a94797543519 100644 --- a/pandas/tests/io/test_sql.py +++ b/pandas/tests/io/test_sql.py @@ -31,6 +31,8 @@ import numpy as np import pytest +import pandas.util._test_decorators as td + from pandas.core.dtypes.common import ( is_datetime64_dtype, is_datetime64tz_dtype, @@ -1423,16 +1425,10 @@ def test_database_uri_string(self, test_frame1): tm.assert_frame_equal(test_frame1, test_frame3) tm.assert_frame_equal(test_frame1, test_frame4) - # using driver that will not be installed on Travis to trigger error + @td.skip_if_installed("pg8000") + def test_pg8000_sqlalchemy_passthrough_error(self): + # using driver that will not be installed on CI to trigger error # in sqlalchemy.create_engine -> test passing of this error to user - try: - # the rest of this test depends on pg8000's being absent - import pg8000 # noqa:F401 - - pytest.skip("pg8000 is installed") - except ImportError: - pass - db_uri = "postgresql+pg8000://user:pass@host/dbname" with pytest.raises(ImportError, match="pg8000"): sql.read_sql("select * from table", db_uri)