Skip to content

Commit

Permalink
Add a test to illustrate client encoding issues
Browse files Browse the repository at this point in the history
See #348
  • Loading branch information
dlax committed Mar 9, 2023
1 parent 77a3bbf commit ce1c684
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,22 @@ def test_postgres_and_python_encoding(pyenc: str, pgenc: str, data, postgresql)
assert running.encoding == pgenc


@pytest.mark.parametrize(
"encoding", ["utf-8", "latin1", pytest.param("sql_ascii", marks=pytest.mark.xfail)]
)
def test_client_encoding(postgresql, encoding: str) -> None:
data = Data.pg_connect(
host=postgresql.info.host,
port=postgresql.info.port,
database=postgresql.info.dbname,
user=postgresql.info.user,
dsn=f"client_encoding={encoding}",
)
assert data.pg_version.startswith(
f"PostgreSQL {str(postgresql.info.server_version)[:2]}"
)


def test_filters_dbname(data, execute):
data_filtered = attr.evolve(data, filters=types.Filters(dbname="temp"))
execute("SELECT pg_sleep(2)", dbname="template1", autocommit=True)
Expand Down

0 comments on commit ce1c684

Please sign in to comment.