16
16
import pytest
17
17
18
18
from dbutils .pooled_db import (
19
- InvalidConnection ,
19
+ InvalidConnectionError ,
20
20
NotSupportedError ,
21
21
PooledDB ,
22
22
SharedDBConnection ,
23
- TooManyConnections ,
23
+ TooManyConnectionsError ,
24
24
)
25
25
from dbutils .steady_db import SteadyDBConnection
26
26
@@ -207,7 +207,7 @@ def test_close_connection(dbapi, threadsafety): # noqa: F811
207
207
if shareable :
208
208
assert db ._shared_con is None
209
209
assert shared_con .shared == 0
210
- with pytest .raises (InvalidConnection ):
210
+ with pytest .raises (InvalidConnectionError ):
211
211
assert db ._usage
212
212
assert not hasattr (db_con , '_num_queries' )
213
213
assert len (pool ._idle_cache ) == 1
@@ -692,9 +692,9 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
692
692
assert len (pool ._idle_cache ) == 0
693
693
if shareable :
694
694
assert len (pool ._shared_cache ) == 0
695
- with pytest .raises (TooManyConnections ):
695
+ with pytest .raises (TooManyConnectionsError ):
696
696
pool .connection (False )
697
- with pytest .raises (TooManyConnections ):
697
+ with pytest .raises (TooManyConnectionsError ):
698
698
pool .connection ()
699
699
cache = []
700
700
assert pool ._connections == 0
@@ -712,13 +712,13 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
712
712
assert len (pool ._shared_cache ) == 2
713
713
else :
714
714
assert pool ._connections == 3
715
- with pytest .raises (TooManyConnections ):
715
+ with pytest .raises (TooManyConnectionsError ):
716
716
pool .connection (False )
717
717
if shareable :
718
718
cache .append (pool .connection (True ))
719
719
assert pool ._connections == 3
720
720
else :
721
- with pytest .raises (TooManyConnections ):
721
+ with pytest .raises (TooManyConnectionsError ):
722
722
pool .connection ()
723
723
del cache
724
724
assert pool ._connections == 0
@@ -732,9 +732,9 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
732
732
assert len (pool ._idle_cache ) == 0
733
733
if shareable :
734
734
assert len (pool ._shared_cache ) == 0
735
- with pytest .raises (TooManyConnections ):
735
+ with pytest .raises (TooManyConnectionsError ):
736
736
pool .connection (False )
737
- with pytest .raises (TooManyConnections ):
737
+ with pytest .raises (TooManyConnectionsError ):
738
738
pool .connection ()
739
739
assert db
740
740
del db
@@ -750,17 +750,17 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
750
750
assert len (pool ._shared_cache ) == 1
751
751
assert pool ._shared_cache [0 ].shared == 2
752
752
else :
753
- with pytest .raises (TooManyConnections ):
753
+ with pytest .raises (TooManyConnectionsError ):
754
754
pool .connection ()
755
- with pytest .raises (TooManyConnections ):
755
+ with pytest .raises (TooManyConnectionsError ):
756
756
pool .connection (False )
757
757
if shareable :
758
758
cache .append (pool .connection (True ))
759
759
assert pool ._connections == 1
760
760
assert len (pool ._shared_cache ) == 1
761
761
assert pool ._shared_cache [0 ].shared == 3
762
762
else :
763
- with pytest .raises (TooManyConnections ):
763
+ with pytest .raises (TooManyConnectionsError ):
764
764
pool .connection (True )
765
765
del cache
766
766
assert pool ._connections == 0
@@ -786,9 +786,9 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
786
786
assert len (pool ._idle_cache ) == 0
787
787
if shareable :
788
788
assert len (pool ._shared_cache ) == 0
789
- with pytest .raises (TooManyConnections ):
789
+ with pytest .raises (TooManyConnectionsError ):
790
790
pool .connection (False )
791
- with pytest .raises (TooManyConnections ):
791
+ with pytest .raises (TooManyConnectionsError ):
792
792
pool .connection ()
793
793
pool = PooledDB (dbapi , 4 , 3 , 2 , 1 , False )
794
794
assert pool ._maxconnections == 4
@@ -799,9 +799,9 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
799
799
cache .append (pool .connection (False ))
800
800
assert pool ._connections == 4
801
801
assert len (pool ._idle_cache ) == 0
802
- with pytest .raises (TooManyConnections ):
802
+ with pytest .raises (TooManyConnectionsError ):
803
803
pool .connection (False )
804
- with pytest .raises (TooManyConnections ):
804
+ with pytest .raises (TooManyConnectionsError ):
805
805
pool .connection ()
806
806
pool = PooledDB (dbapi , 1 , 2 , 3 , 4 , False )
807
807
assert pool ._maxconnections == 4
@@ -819,9 +819,9 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
819
819
assert pool ._connections == 4
820
820
else :
821
821
assert pool ._connections == 4
822
- with pytest .raises (TooManyConnections ):
822
+ with pytest .raises (TooManyConnectionsError ):
823
823
pool .connection ()
824
- with pytest .raises (TooManyConnections ):
824
+ with pytest .raises (TooManyConnectionsError ):
825
825
pool .connection (False )
826
826
pool = PooledDB (dbapi , 0 , 0 , 3 , 3 , False )
827
827
assert pool ._maxconnections == 3
@@ -830,9 +830,9 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
830
830
for _i in range (3 ):
831
831
cache .append (pool .connection (False ))
832
832
assert pool ._connections == 3
833
- with pytest .raises (TooManyConnections ):
833
+ with pytest .raises (TooManyConnectionsError ):
834
834
pool .connection (False )
835
- with pytest .raises (TooManyConnections ):
835
+ with pytest .raises (TooManyConnectionsError ):
836
836
pool .connection (True )
837
837
cache = []
838
838
assert pool ._connections == 0
@@ -844,9 +844,9 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
844
844
cache .append (pool .connection ())
845
845
assert pool ._connections == 3
846
846
else :
847
- with pytest .raises (TooManyConnections ):
847
+ with pytest .raises (TooManyConnectionsError ):
848
848
pool .connection ()
849
- with pytest .raises (TooManyConnections ):
849
+ with pytest .raises (TooManyConnectionsError ):
850
850
pool .connection (False )
851
851
pool = PooledDB (dbapi , 0 , 0 , 3 )
852
852
assert pool ._maxconnections == 0
@@ -1165,7 +1165,7 @@ def test_shared_in_transaction(dbapi): # noqa: F811
1165
1165
db = pool .connection ()
1166
1166
db .begin ()
1167
1167
pool .connection (False )
1168
- with pytest .raises (TooManyConnections ):
1168
+ with pytest .raises (TooManyConnectionsError ):
1169
1169
pool .connection ()
1170
1170
pool = PooledDB (dbapi , 0 , 2 , 2 )
1171
1171
db1 = pool .connection ()
@@ -1183,7 +1183,7 @@ def test_shared_in_transaction(dbapi): # noqa: F811
1183
1183
db .close ()
1184
1184
db2 .begin ()
1185
1185
pool .connection (False )
1186
- with pytest .raises (TooManyConnections ):
1186
+ with pytest .raises (TooManyConnectionsError ):
1187
1187
pool .connection ()
1188
1188
db1 .rollback ()
1189
1189
db = pool .connection ()
0 commit comments