@@ -25,6 +25,19 @@ def test_connection_uri():
2525 assert connection_uri == expected_connection_uri
2626
2727
28+ def test_server_encoding (connection : psycopg .Connection ):
29+ """Test that PostgreSQL's encoding is 'UTF-8'."""
30+
31+ assert connection .execute ("SHOW SERVER_ENCODING" ).fetchone ()[0 ] == "UTF8"
32+
33+
34+ def test_locale (connection : psycopg .Connection ):
35+ """Test that PostgreSQL's locale is 'en_US.UTF-8'."""
36+
37+ assert connection .execute ("SHOW LC_COLLATE" ).fetchone ()[0 ] == "en_US.UTF-8"
38+ assert connection .execute ("SHOW LC_CTYPE" ).fetchone ()[0 ] == "en_US.UTF-8"
39+
40+
2841def test_user_permissions (connection : psycopg .Connection ):
2942 """Test that a user can create databases but is not a superuser."""
3043
@@ -53,6 +66,21 @@ def test_user_create_insert_select(connection: psycopg.Connection):
5366 assert records == [(1 , "42" )]
5467
5568
69+ def test_user_create_insert_non_ascii (connection : psycopg .Connection ):
70+ """Test that non-ASCII characters can be stored and fetched."""
71+
72+ table_name = "test_setup_postgres"
73+
74+ with connection , connection .transaction (force_rollback = True ):
75+ records = connection \
76+ .execute (f"CREATE TABLE { table_name } (eggs INTEGER, rice VARCHAR)" ) \
77+ .execute (f"INSERT INTO { table_name } (eggs, rice) VALUES (1, 'Україна')" ) \
78+ .execute (f"INSERT INTO { table_name } (eggs, rice) VALUES (2, 'ウクライナ')" ) \
79+ .execute (f"SELECT * FROM { table_name } " ) \
80+ .fetchall ()
81+ assert records == [(1 , "Україна" ), (2 , "ウクライナ" )]
82+
83+
5684def test_user_create_drop_database (connection : psycopg .Connection ):
5785 """Test that a user has no permissions to create databases."""
5886
0 commit comments