File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,17 @@ def test_TooMany_message_is_helpful_for_a_range(self):
109
109
"Got 4 rows; expecting between 1 and 3 (inclusive)."
110
110
111
111
112
+ class TestOneRollsBack (WithData ):
113
+
114
+ def test_one_rollsback_on_error (self ):
115
+ try :
116
+ self .db .one ("UPDATE foo SET bar='bum' RETURNING *" , strict = True )
117
+ except TooMany :
118
+ pass
119
+ actual = self .db .all ("SELECT * FROM foo WHERE bar='bum'" )
120
+ assert actual == []
121
+
122
+
112
123
class TestOne (WithData ):
113
124
114
125
def test_with_strict_True_one_raises_TooFew (self ):
@@ -209,6 +220,16 @@ def test_one_or_zero_raises_TooFew(self):
209
220
, "CREATE TABLE foux (baar text)"
210
221
)
211
222
223
+ def test_one_or_zero_rollsback_on_error (self ):
224
+ try :
225
+ self .db .one_or_zero ("CREATE TABLE foux (baar text)" )
226
+ except TooFew :
227
+ pass
228
+ self .assertRaises ( ProgrammingError
229
+ , self .db .all
230
+ , "SELECT * FROM foux"
231
+ )
232
+
212
233
def test_one_or_zero_returns_None (self ):
213
234
actual = self .db .one_or_zero ("SELECT * FROM foo WHERE bar='blam'" )
214
235
assert actual is None
You can’t perform that action at this time.
0 commit comments