From 500fc32f33e08137206e66dd32ce5cb71e11ccf2 Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Mon, 30 Oct 2023 08:54:16 +0100 Subject: [PATCH] Add regression test for #390 --- .../regression/test_regression_bug390.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/integration/regression/test_regression_bug390.py diff --git a/test/integration/regression/test_regression_bug390.py b/test/integration/regression/test_regression_bug390.py new file mode 100644 index 00000000..e3013270 --- /dev/null +++ b/test/integration/regression/test_regression_bug390.py @@ -0,0 +1,37 @@ +from inspect import cleandoc + +pytest_plugins = "pytester" + + +def test_connection_with_block_cleans_up_properly(pytester, itde): + config = itde.db + # Because the error only occurs on process shutdown we need to run a test within a test + # (We require the result (stderr) of a terminated process triggering the failure. + pytester.makepyfile( + # fmt: off + cleandoc( + f""" + from sqlalchemy import create_engine + + def test(): + url = "exa+websocket://{{user}}:{{pw}}@{{host}}:{{port}}/{{schema}}?SSLCertificate=SSL_VERIFY_NONE" + url = url.format( + user="{config.username}", + pw="{config.password}", + host="{config.host}", + port={config.port}, + schema="{itde.itde.schemas[0]}", + ) + engine = create_engine(url) + query = "SELECT 42;" + with engine.connect() as con: + result = con.execute(query).fetchall() + """ + ), + # fmt: on + ) + r = pytester.runpytest_subprocess() + expected = "" + actual = f"{r.stderr}" + + assert actual == expected