From: Daniele Varrazzo Date: Tue, 22 Jun 2021 10:54:02 +0000 (+0100) Subject: Mark timing based test flaky X-Git-Tag: 3.0.dev0~22 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bc9f4a9a1d1b0ae636be81762ec4d5849ec583c5;p=thirdparty%2Fpsycopg.git Mark timing based test flaky --- diff --git a/tests/pool/test_pool.py b/tests/pool/test_pool.py index 6f42b7f0a..235b0af5c 100644 --- a/tests/pool/test_pool.py +++ b/tests/pool/test_pool.py @@ -760,16 +760,18 @@ def test_reconnect_failure(proxy): @pytest.mark.slow -def test_uniform_use(dsn): - with pool.ConnectionPool(dsn, min_size=4) as p: - counts = Counter() - for i in range(8): - with p.connection() as conn: - sleep(0.1) - counts[id(conn)] += 1 - - assert len(counts) == 4 - assert set(counts.values()) == set([2]) +def test_uniform_use(dsn, retries): + for retry in retries: + with retry: + with pool.ConnectionPool(dsn, min_size=4) as p: + counts = Counter() + for i in range(8): + with p.connection() as conn: + sleep(0.1) + counts[id(conn)] += 1 + + assert len(counts) == 4 + assert set(counts.values()) == set([2]) @pytest.mark.slow diff --git a/tests/pool/test_pool_async.py b/tests/pool/test_pool_async.py index 23894a3c3..e1c146c35 100644 --- a/tests/pool/test_pool_async.py +++ b/tests/pool/test_pool_async.py @@ -773,16 +773,18 @@ async def test_reconnect_failure(proxy): @pytest.mark.slow -async def test_uniform_use(dsn): - async with pool.AsyncConnectionPool(dsn, min_size=4) as p: - counts = Counter() - for i in range(8): - async with p.connection() as conn: - await asyncio.sleep(0.1) - counts[id(conn)] += 1 - - assert len(counts) == 4 - assert set(counts.values()) == set([2]) +async def test_uniform_use(dsn, retries): + async for retry in retries: + with retry: + async with pool.AsyncConnectionPool(dsn, min_size=4) as p: + counts = Counter() + for i in range(8): + async with p.connection() as conn: + await asyncio.sleep(0.1) + counts[id(conn)] += 1 + + assert len(counts) == 4 + assert set(counts.values()) == set([2]) @pytest.mark.slow