]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Use the present tense in PoolClosed error messages 196/head
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 3 Jan 2022 15:59:29 +0000 (16:59 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 3 Jan 2022 16:06:24 +0000 (17:06 +0100)
Thank you John Aldis! https://twitter.com/johnaldis/status/1478016200634425348

psycopg_pool/psycopg_pool/base.py
tests/pool/test_pool.py
tests/pool/test_pool_async.py

index 4079caebc23463163fd271d97c564c0be89deff5..380508b20fb0f7615c11256e13b4c2cfa84e5cea 100644 (file)
@@ -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]:
         """
index 441e4764e5b14f5f2d1b3eefa7b3110d6d4c4277..7f23551770a95297b7bfe1712e430e1e4cc87776 100644 (file)
@@ -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()
 
 
index 5a5162a8afe6e830b0452cca4413c5c070bfd51e..12a21bc69333c5997d6b97c48ecd4b81070b9f03 100644 (file)
@@ -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()