Skip to content

Commit dc9abea

Browse files
committed
Failing test for the ability to monkey-patch cursor.execute.
1 parent a370d45 commit dc9abea

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,17 @@ def test_we_close_the_cursor(self):
204204
, cursor.fetchall
205205
)
206206

207+
def test_monkey_patch_execute(self):
208+
expected = "SELECT 1"
209+
def execute(this, sql, params=[]):
210+
return sql
211+
from postgres.cursors import SimpleCursorBase
212+
SimpleCursorBase.execute = execute
213+
with self.db.get_cursor() as cursor:
214+
actual = cursor.execute(expected)
215+
del SimpleCursorBase.execute
216+
assert actual == expected
217+
207218

208219
# db.get_connection
209220
# =================

0 commit comments

Comments
 (0)