Skip to content

Commit bad6556

Browse files
committed
Coverage
1 parent 4e2ac8b commit bad6556

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

apsw/tests/__main__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,6 +3068,15 @@ def phcontinue():
30683068
self.db.execute("select 3").get
30693069
self.assertEqual(called, [False, True])
30703070

3071+
3072+
# bad id
3073+
class bad_eq:
3074+
def __eq__(self, other):
3075+
1 / 0
3076+
3077+
self.db.set_progress_handler(phabort, id=bad_eq())
3078+
self.assertRaises(ZeroDivisionError, self.db.set_progress_handler, phabort, id=3)
3079+
30713080
def testChanges(self):
30723081
"Verify reporting of changes"
30733082
c = self.db.cursor()
@@ -3375,6 +3384,13 @@ def hook(i):
33753384
self.assertRaises(apsw.ConstraintError, self.db.execute, "insert into foo values(99)")
33763385
self.assertEqual(seen, expected | {11})
33773386

3387+
# bad id
3388+
class bad_eq:
3389+
def __eq__(self, other):
3390+
1 / 0
3391+
3392+
self.assertRaises(ZeroDivisionError, self.db.set_commit_hook, ch, id=bad_eq())
3393+
33783394
def testRollbackHook(self):
33793395
"Verify rollback hooks"
33803396
c = self.db.cursor()
@@ -3454,6 +3470,14 @@ def hook3(x):
34543470

34553471
self.db.execute("begin ; insert into foo values(12); rollback")
34563472

3473+
# bad id
3474+
class bad_eq:
3475+
def __eq__(self, other):
3476+
1 / 0
3477+
3478+
self.db.set_rollback_hook(hook2, id=bad_eq())
3479+
self.assertRaises(ZeroDivisionError, self.db.set_rollback_hook, hook3, id=3)
3480+
34573481
def testUpdateHook(self):
34583482
"Verify update hooks"
34593483
c = self.db.cursor()
@@ -6424,9 +6448,13 @@ def hook(myid, update):
64246448
else:
64256449
raise Exception("unexpected")
64266450

6451+
self.db.preupdate_hook(lambda: 1/0)
6452+
64276453
for id in test_ids:
64286454
self.db.preupdate_hook(functools.partial(hook, id), id=id)
64296455

6456+
self.db.preupdate_hook(None)
6457+
64306458
gc.get_referents(self.db)
64316459

64326460
self.db.execute("create table foo(x,y,z)")

0 commit comments

Comments
 (0)