From: Daniele Varrazzo Date: Sun, 27 Mar 2022 18:52:57 +0000 (+0200) Subject: test: display the version of the server tests are run against X-Git-Tag: 3.1~157 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2460a5ef326c6662954e61eb5bb7d9aed73da7d2;p=thirdparty%2Fpsycopg.git test: display the version of the server tests are run against --- diff --git a/tests/fix_db.py b/tests/fix_db.py index 1702a4ad2..ab4a6dd3b 100644 --- a/tests/fix_db.py +++ b/tests/fix_db.py @@ -27,6 +27,22 @@ def pytest_addoption(parser): ) +def pytest_report_header(config): + dsn = config.getoption("--test-dsn") + if dsn is None: + return [] + + try: + with psycopg.connect(dsn, connect_timeout=10) as conn: + server_version = conn.execute("select version()").fetchall()[0][0] + except Exception as ex: + server_version = f"unknown ({ex})" + + return [ + f"Server version: {server_version}", + ] + + def pytest_configure(config): # register pg marker config.addinivalue_line(