From: Daniele Varrazzo Date: Mon, 3 Jan 2022 15:59:29 +0000 (+0100) Subject: Use the present tense in PoolClosed error messages X-Git-Tag: pool-3.1~45^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bdacf064b01d1fce5d47e1c427f6fee3c4daa2af;p=thirdparty%2Fpsycopg.git Use the present tense in PoolClosed error messages Thank you John Aldis! https://twitter.com/johnaldis/status/1478016200634425348 --- diff --git a/psycopg_pool/psycopg_pool/base.py b/psycopg_pool/psycopg_pool/base.py index 4079caebc..380508b20 100644 --- a/psycopg_pool/psycopg_pool/base.py +++ b/psycopg_pool/psycopg_pool/base.py @@ -128,13 +128,9 @@ class BasePool(Generic[ConnectionType]): def _check_open_getconn(self) -> None: if self._closed: if self._opened: - raise PoolClosed( - f"the pool {self.name!r} has already been closed" - ) + raise PoolClosed(f"the pool {self.name!r} is already closed") else: - raise PoolClosed( - f"the pool {self.name!r} has not been opened yet" - ) + raise PoolClosed(f"the pool {self.name!r} is not open yet") def get_stats(self) -> Dict[str, int]: """ diff --git a/tests/pool/test_pool.py b/tests/pool/test_pool.py index 441e4764e..7f2355177 100644 --- a/tests/pool/test_pool.py +++ b/tests/pool/test_pool.py @@ -687,7 +687,7 @@ def test_closed_queue(dsn): def test_open_explicit(dsn): p = pool.ConnectionPool(dsn, open=False) assert p.closed - with pytest.raises(pool.PoolClosed, match="has not been opened yet"): + with pytest.raises(pool.PoolClosed, match="is not open yet"): p.getconn() with pytest.raises(pool.PoolClosed): @@ -705,7 +705,7 @@ def test_open_explicit(dsn): finally: p.close() - with pytest.raises(pool.PoolClosed, match="has already been closed"): + with pytest.raises(pool.PoolClosed, match="is already closed"): p.getconn() diff --git a/tests/pool/test_pool_async.py b/tests/pool/test_pool_async.py index 5a5162a8a..12a21bc69 100644 --- a/tests/pool/test_pool_async.py +++ b/tests/pool/test_pool_async.py @@ -679,7 +679,7 @@ async def test_open_explicit(dsn): with pytest.raises(pool.PoolClosed): await p.getconn() - with pytest.raises(pool.PoolClosed, match="has not been opened yet"): + with pytest.raises(pool.PoolClosed, match="is not open yet"): async with p.connection(): pass @@ -694,7 +694,7 @@ async def test_open_explicit(dsn): finally: await p.close() - with pytest.raises(pool.PoolClosed, match="has already been closed"): + with pytest.raises(pool.PoolClosed, match="is already closed"): await p.getconn()