2010-04-08 20:42:20 +04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import psycopg2
|
|
|
|
import psycopg2.extensions
|
|
|
|
import time
|
|
|
|
import unittest
|
|
|
|
import gc
|
|
|
|
|
2010-12-21 07:58:38 +03:00
|
|
|
from testconfig import dsn
|
2010-04-08 20:42:20 +04:00
|
|
|
|
|
|
|
class StolenReferenceTestCase(unittest.TestCase):
|
|
|
|
def test_stolen_reference_bug(self):
|
|
|
|
def fish(val, cur):
|
|
|
|
gc.collect()
|
|
|
|
return 42
|
2010-12-21 07:58:38 +03:00
|
|
|
conn = psycopg2.connect(dsn)
|
2010-04-08 20:42:20 +04:00
|
|
|
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()
|