Skip to content

Commit 8931b5f

Browse files
committed
Add two tests for #17
1 parent edce194 commit 8931b5f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@ def test_TooMany_message_is_helpful_for_a_range(self):
109109
"Got 4 rows; expecting between 1 and 3 (inclusive)."
110110

111111

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+
112123
class TestOne(WithData):
113124

114125
def test_with_strict_True_one_raises_TooFew(self):
@@ -209,6 +220,16 @@ def test_one_or_zero_raises_TooFew(self):
209220
, "CREATE TABLE foux (baar text)"
210221
)
211222

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+
212233
def test_one_or_zero_returns_None(self):
213234
actual = self.db.one_or_zero("SELECT * FROM foo WHERE bar='blam'")
214235
assert actual is None

0 commit comments

Comments
 (0)