Skip to content

TST: Clean pg8000 test #45164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,9 @@ repos:
entry: python scripts/pandas_errors_documented.py
language: python
files: ^pandas/errors/__init__.py$
- id: pg8000-not-installed-CI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to prevent someone adding pg8000 in the ci/deps in the future which would prevent this test from running.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i c ok sure

name: Check for pg8000 not installed on CI for test_pg8000_sqlalchemy_passthrough_error
language: pygrep
entry: 'pg8000'
files: ^ci/deps
types: [yaml]
14 changes: 5 additions & 9 deletions pandas/tests/io/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down