My favorites | Sign in
Project Home Downloads Wiki
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 145 attachment: pyodbc-paramleak-test.patch (964 bytes)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
diff --git a/tests/sqlservertests.py b/tests/sqlservertests.py
index f90f5a2..38774cc 100755
--- a/tests/sqlservertests.py
+++ b/tests/sqlservertests.py
@@ -27,6 +27,8 @@ is installed:

import sys, os, re
import unittest
+import weakref
+import gc
from decimal import Decimal
from datetime import datetime, date, time
from os.path import join, getsize, dirname, abspath
@@ -1238,6 +1240,17 @@ class SqlServerTestCase(unittest.TestCase):
current = m.group(1)
self.assert_(current in drivers)

+ def test_leak_params(self):
+ class WeakReferencableInt(int):
+ pass
+ mightleak = WeakReferencableInt(42)
+ mightleak_weakref = weakref.ref(mightleak)
+ self.cursor.execute("create table t1(n int)")
+ self.cursor.execute("insert into t1 (n) values (?)", (mightleak,))
+ del mightleak
+ gc.collect()
+ self.assert_(mightleak_weakref() is None)
+


def main():
Powered by Google Project Hosting