1616import pytest
1717
1818from dbutils .pooled_db import (
19- InvalidConnection ,
19+ InvalidConnectionError ,
2020 NotSupportedError ,
2121 PooledDB ,
2222 SharedDBConnection ,
23- TooManyConnections ,
23+ TooManyConnectionsError ,
2424)
2525from dbutils .steady_db import SteadyDBConnection
2626
@@ -207,7 +207,7 @@ def test_close_connection(dbapi, threadsafety): # noqa: F811
207207 if shareable :
208208 assert db ._shared_con is None
209209 assert shared_con .shared == 0
210- with pytest .raises (InvalidConnection ):
210+ with pytest .raises (InvalidConnectionError ):
211211 assert db ._usage
212212 assert not hasattr (db_con , '_num_queries' )
213213 assert len (pool ._idle_cache ) == 1
@@ -692,9 +692,9 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
692692 assert len (pool ._idle_cache ) == 0
693693 if shareable :
694694 assert len (pool ._shared_cache ) == 0
695- with pytest .raises (TooManyConnections ):
695+ with pytest .raises (TooManyConnectionsError ):
696696 pool .connection (False )
697- with pytest .raises (TooManyConnections ):
697+ with pytest .raises (TooManyConnectionsError ):
698698 pool .connection ()
699699 cache = []
700700 assert pool ._connections == 0
@@ -712,13 +712,13 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
712712 assert len (pool ._shared_cache ) == 2
713713 else :
714714 assert pool ._connections == 3
715- with pytest .raises (TooManyConnections ):
715+ with pytest .raises (TooManyConnectionsError ):
716716 pool .connection (False )
717717 if shareable :
718718 cache .append (pool .connection (True ))
719719 assert pool ._connections == 3
720720 else :
721- with pytest .raises (TooManyConnections ):
721+ with pytest .raises (TooManyConnectionsError ):
722722 pool .connection ()
723723 del cache
724724 assert pool ._connections == 0
@@ -732,9 +732,9 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
732732 assert len (pool ._idle_cache ) == 0
733733 if shareable :
734734 assert len (pool ._shared_cache ) == 0
735- with pytest .raises (TooManyConnections ):
735+ with pytest .raises (TooManyConnectionsError ):
736736 pool .connection (False )
737- with pytest .raises (TooManyConnections ):
737+ with pytest .raises (TooManyConnectionsError ):
738738 pool .connection ()
739739 assert db
740740 del db
@@ -750,17 +750,17 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
750750 assert len (pool ._shared_cache ) == 1
751751 assert pool ._shared_cache [0 ].shared == 2
752752 else :
753- with pytest .raises (TooManyConnections ):
753+ with pytest .raises (TooManyConnectionsError ):
754754 pool .connection ()
755- with pytest .raises (TooManyConnections ):
755+ with pytest .raises (TooManyConnectionsError ):
756756 pool .connection (False )
757757 if shareable :
758758 cache .append (pool .connection (True ))
759759 assert pool ._connections == 1
760760 assert len (pool ._shared_cache ) == 1
761761 assert pool ._shared_cache [0 ].shared == 3
762762 else :
763- with pytest .raises (TooManyConnections ):
763+ with pytest .raises (TooManyConnectionsError ):
764764 pool .connection (True )
765765 del cache
766766 assert pool ._connections == 0
@@ -786,9 +786,9 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
786786 assert len (pool ._idle_cache ) == 0
787787 if shareable :
788788 assert len (pool ._shared_cache ) == 0
789- with pytest .raises (TooManyConnections ):
789+ with pytest .raises (TooManyConnectionsError ):
790790 pool .connection (False )
791- with pytest .raises (TooManyConnections ):
791+ with pytest .raises (TooManyConnectionsError ):
792792 pool .connection ()
793793 pool = PooledDB (dbapi , 4 , 3 , 2 , 1 , False )
794794 assert pool ._maxconnections == 4
@@ -799,9 +799,9 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
799799 cache .append (pool .connection (False ))
800800 assert pool ._connections == 4
801801 assert len (pool ._idle_cache ) == 0
802- with pytest .raises (TooManyConnections ):
802+ with pytest .raises (TooManyConnectionsError ):
803803 pool .connection (False )
804- with pytest .raises (TooManyConnections ):
804+ with pytest .raises (TooManyConnectionsError ):
805805 pool .connection ()
806806 pool = PooledDB (dbapi , 1 , 2 , 3 , 4 , False )
807807 assert pool ._maxconnections == 4
@@ -819,9 +819,9 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
819819 assert pool ._connections == 4
820820 else :
821821 assert pool ._connections == 4
822- with pytest .raises (TooManyConnections ):
822+ with pytest .raises (TooManyConnectionsError ):
823823 pool .connection ()
824- with pytest .raises (TooManyConnections ):
824+ with pytest .raises (TooManyConnectionsError ):
825825 pool .connection (False )
826826 pool = PooledDB (dbapi , 0 , 0 , 3 , 3 , False )
827827 assert pool ._maxconnections == 3
@@ -830,9 +830,9 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
830830 for _i in range (3 ):
831831 cache .append (pool .connection (False ))
832832 assert pool ._connections == 3
833- with pytest .raises (TooManyConnections ):
833+ with pytest .raises (TooManyConnectionsError ):
834834 pool .connection (False )
835- with pytest .raises (TooManyConnections ):
835+ with pytest .raises (TooManyConnectionsError ):
836836 pool .connection (True )
837837 cache = []
838838 assert pool ._connections == 0
@@ -844,9 +844,9 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
844844 cache .append (pool .connection ())
845845 assert pool ._connections == 3
846846 else :
847- with pytest .raises (TooManyConnections ):
847+ with pytest .raises (TooManyConnectionsError ):
848848 pool .connection ()
849- with pytest .raises (TooManyConnections ):
849+ with pytest .raises (TooManyConnectionsError ):
850850 pool .connection (False )
851851 pool = PooledDB (dbapi , 0 , 0 , 3 )
852852 assert pool ._maxconnections == 0
@@ -1165,7 +1165,7 @@ def test_shared_in_transaction(dbapi): # noqa: F811
11651165 db = pool .connection ()
11661166 db .begin ()
11671167 pool .connection (False )
1168- with pytest .raises (TooManyConnections ):
1168+ with pytest .raises (TooManyConnectionsError ):
11691169 pool .connection ()
11701170 pool = PooledDB (dbapi , 0 , 2 , 2 )
11711171 db1 = pool .connection ()
@@ -1183,7 +1183,7 @@ def test_shared_in_transaction(dbapi): # noqa: F811
11831183 db .close ()
11841184 db2 .begin ()
11851185 pool .connection (False )
1186- with pytest .raises (TooManyConnections ):
1186+ with pytest .raises (TooManyConnectionsError ):
11871187 pool .connection ()
11881188 db1 .rollback ()
11891189 db = pool .connection ()
0 commit comments