From: Daniele Varrazzo Date: Tue, 29 Jun 2021 00:22:18 +0000 (+0100) Subject: Give a gc hit before running gc tests X-Git-Tag: 3.0.dev0~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e6e96855cfdcfb386dfbbc42b4fd52cafa642e11;p=thirdparty%2Fpsycopg.git Give a gc hit before running gc tests Sometimes these tests fail because there is garbage before. --- diff --git a/tests/test_copy.py b/tests/test_copy.py index b62097a72..dabb8aafb 100644 --- a/tests/test_copy.py +++ b/tests/test_copy.py @@ -537,6 +537,7 @@ def test_copy_to_leaks(dsn, faker, fmt, method, retries): elif method == "rows": list(copy.rows()) + gc_collect() for retry in retries: with retry: n = [] @@ -578,6 +579,7 @@ def test_copy_from_leaks(dsn, faker, fmt, retries): for got, want in zip(recs, faker.records): faker.assert_record(got, want) + gc_collect() for retry in retries: with retry: n = [] diff --git a/tests/test_copy_async.py b/tests/test_copy_async.py index c34286e78..e0f7ce9e1 100644 --- a/tests/test_copy_async.py +++ b/tests/test_copy_async.py @@ -515,6 +515,7 @@ async def test_copy_to_leaks(dsn, faker, fmt, method, retries): async for x in copy.rows(): pass + gc_collect() async for retry in retries: with retry: n = [] @@ -556,6 +557,7 @@ async def test_copy_from_leaks(dsn, faker, fmt, retries): for got, want in zip(recs, faker.records): faker.assert_record(got, want) + gc_collect() async for retry in retries: with retry: n = [] diff --git a/tests/test_cursor.py b/tests/test_cursor.py index 49e3f2313..e575867fd 100644 --- a/tests/test_cursor.py +++ b/tests/test_cursor.py @@ -550,6 +550,7 @@ def test_leak(dsn, faker, fmt, fmt_out, fetch, row_factory): row_factory = getattr(rows, row_factory) n = [] + gc_collect() for i in range(3): with psycopg.connect(dsn) as conn: with conn.cursor(binary=fmt_out, row_factory=row_factory) as cur: diff --git a/tests/test_cursor_async.py b/tests/test_cursor_async.py index 3a206861b..9d80b2698 100644 --- a/tests/test_cursor_async.py +++ b/tests/test_cursor_async.py @@ -464,6 +464,7 @@ async def test_leak(dsn, faker, fmt, fmt_out, fetch, row_factory): row_factory = getattr(rows, row_factory) n = [] + gc_collect() for i in range(3): async with await psycopg.AsyncConnection.connect(dsn) as conn: async with conn.cursor(