From 315640f6fd486f9785139afcbc1cad00cb8e4e3e Mon Sep 17 00:00:00 2001 From: Grollicus <cccvgitlab.db5c7b60@grollmann.eu> Date: Mon, 10 Apr 2023 20:58:00 +0200 Subject: [PATCH] made username lookup work with psycopg 3 --- src/core/tests/runner.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/tests/runner.py b/src/core/tests/runner.py index b9a10409f..c8588031d 100644 --- a/src/core/tests/runner.py +++ b/src/core/tests/runner.py @@ -2,11 +2,18 @@ from types import MethodType from django.test.runner import DiscoverRunner from django.db import connections + def prepare_database(self): self.connect() + + try: + username = self.connection.get_dsn_parameters()['user'] + except AttributeError: # psycopg has moved this method + username = self.connection.info.get_parameters()['user'] + self.connection.cursor().execute(f""" - CREATE SCHEMA rc3schema AUTHORIZATION {self.connection.get_dsn_parameters()["user"]}; - GRANT ALL ON SCHEMA rc3schema TO {self.connection.get_dsn_parameters()["user"]}; + CREATE SCHEMA rc3schema AUTHORIZATION {username}; + GRANT ALL ON SCHEMA rc3schema TO {username}; """) -- GitLab