summaryrefslogtreecommitdiff
path: root/tests/bug_gc.py
diff options
context:
space:
mode:
authorFederico Di Gregorio <fog@initd.org>2010-04-08 18:42:20 +0200
committerFederico Di Gregorio <fog@initd.org>2010-04-08 18:42:20 +0200
commit0a33ed01f556316e6480dba4d04198260568b4dd (patch)
treeff5e945c61e3974b90cc5bc16c296d81453f9dd7 /tests/bug_gc.py
parente8286084e9400ae634f06e9da34e4de474b51eb7 (diff)
downloadpsycopg2-0a33ed01f556316e6480dba4d04198260568b4dd.tar.gz
Added test for refcounting/gc bug reported by Michael Tharp
Diffstat (limited to 'tests/bug_gc.py')
-rwxr-xr-xtests/bug_gc.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/bug_gc.py b/tests/bug_gc.py
new file mode 100755
index 0000000..89d90d2
--- /dev/null
+++ b/tests/bug_gc.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+
+import psycopg2
+import psycopg2.extensions
+import time
+import unittest
+import gc
+
+import sys
+if sys.version_info < (3,):
+ import tests
+else:
+ import py3tests as tests
+
+class StolenReferenceTestCase(unittest.TestCase):
+ def test_stolen_reference_bug(self):
+ def fish(val, cur):
+ gc.collect()
+ return 42
+ conn = psycopg2.connect(tests.dsn)
+ UUID = psycopg2.extensions.new_type((2950,), "UUID", fish)
+ psycopg2.extensions.register_type(UUID, conn)
+ curs = conn.cursor()
+ curs.execute("select 'b5219e01-19ab-4994-b71e-149225dc51e4'::uuid")
+ curs.fetchone()
+
+def test_suite():
+ return unittest.TestLoader().loadTestsFromName(__name__)
+
+if __name__ == "__main__":
+ unittest.main()