avoid f-strings in SQL creation in tests

This commit is contained in:
Sarah Hoffmann
2026-02-09 21:25:01 +01:00
parent 73590baf15
commit d10d70944d
2 changed files with 9 additions and 5 deletions

View File

@@ -60,7 +60,7 @@ def temp_db(monkeypatch):
with psycopg.connect(dbname='postgres', autocommit=True) as conn:
with conn.cursor() as cur:
cur.execute('DROP DATABASE IF EXISTS {}'.format(name))
cur.execute(pysql.SQL('DROP DATABASE IF EXISTS') + pysql.Identifier(name))
@pytest.fixture
@@ -104,7 +104,9 @@ def table_factory(temp_db_conn):
"""
def mk_table(name, definition='id INT', content=None):
with psycopg.ClientCursor(temp_db_conn) as cur:
cur.execute('CREATE TABLE {} ({})'.format(name, definition))
cur.execute(pysql.SQL("CREATE TABLE {} ({})")
.format(pysql.Identifier(name),
pysql.SQL(definition)))
if content:
sql = pysql.SQL("INSERT INTO {} VALUES ({})")\
.format(pysql.Identifier(name),