Deprecation warnings are ignored by default and easy to miss.
Close #737.
``psycopg_pool`` release notes
==============================
+Future releases
+---------------
+
+psycopg_pool 3.2.2 (unreleased)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+- Raise a `RuntimeWarning` instead of a `DeprecationWarning` if an async pool
+ is open in the constructor.
+
+
Current release
---------------
" is deprecated and will not be supported anymore in a future"
" release. Please use `await pool.open()`, or use the pool as context"
f" manager using: `async with {type(self).__name__}(...) as pool: `...",
- DeprecationWarning,
+ RuntimeWarning,
)
async def wait(self, timeout: float = 30.0) -> None:
def test_cant_create_open_outside_loop(dsn):
- with pytest.warns(DeprecationWarning):
+ with pytest.warns(RuntimeWarning):
with pytest.raises(RuntimeError):
pool.AsyncConnectionPool(dsn, open=True)
def test_create_warning(pool_cls, dsn):
+ warning_cls = DeprecationWarning
# No warning on explicit open for sync pool
p = pool_cls(dsn, open=True)
try:
pass
# Warning on open not specified
- with pytest.warns(DeprecationWarning):
+ with pytest.warns(warning_cls):
p = pool_cls(dsn)
try:
with p.connection():
p.close()
# Warning also if open is called explicitly on already implicitly open
- with pytest.warns(DeprecationWarning):
+ with pytest.warns(warning_cls):
p = pool_cls(dsn)
p.open()
try:
async def test_create_warning(pool_cls, dsn):
if True: # ASYNC
+ warning_cls = RuntimeWarning
# warning on explicit open too on async
- with pytest.warns(DeprecationWarning):
+ with pytest.warns(warning_cls):
p = pool_cls(dsn, open=True)
await p.close()
else:
+ warning_cls = DeprecationWarning
# No warning on explicit open for sync pool
p = pool_cls(dsn, open=True)
try:
pass
# Warning on open not specified
- with pytest.warns(DeprecationWarning):
+ with pytest.warns(warning_cls):
p = pool_cls(dsn)
try:
async with p.connection():
await p.close()
# Warning also if open is called explicitly on already implicitly open
- with pytest.warns(DeprecationWarning):
+ with pytest.warns(warning_cls):
p = pool_cls(dsn)
await p.open()
try: