File tree 2 files changed +18
-5
lines changed
2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -507,7 +507,10 @@ def tearDown(self):
507
507
self .client .execute (self .TEARDOWN_METHOD ))
508
508
finally :
509
509
try :
510
- if self .client .connection .is_in_transaction ():
510
+ if (
511
+ self .client .connection
512
+ and self .client .connection .is_in_transaction ()
513
+ ):
511
514
raise AssertionError (
512
515
'test connection is still in transaction '
513
516
'*after* the test' )
Original file line number Diff line number Diff line change @@ -52,9 +52,19 @@ class RetryCondition:
52
52
53
53
class IsolationLevel :
54
54
"""Isolation level for transaction"""
55
- Serializable = "SERIALIZABLE"
56
- RepeatableRead = "REPEATABLE READ"
57
-
55
+ Serializable = "Serializable"
56
+ RepeatableRead = "RepeatableRead"
57
+
58
+ @staticmethod
59
+ def _to_start_tx_str (v ):
60
+ if v == IsolationLevel .Serializable :
61
+ return 'SERIALIZABLE'
62
+ elif v == IsolationLevel .RepeatableRead :
63
+ return 'REPEATABLE READ'
64
+ else :
65
+ raise ValueError (
66
+ f"Invalid isolation_level value for transaction(): { self } "
67
+ )
58
68
59
69
class RetryOptions :
60
70
"""An immutable class that contains rules for `transaction()`"""
@@ -118,7 +128,7 @@ def defaults(cls):
118
128
return cls ()
119
129
120
130
def start_transaction_query (self ):
121
- isolation = str (self ._isolation )
131
+ isolation = IsolationLevel . _to_start_tx_str (self ._isolation )
122
132
if self ._readonly :
123
133
mode = 'READ ONLY'
124
134
else :
You can’t perform that action at this time.
0 commit comments