psycopg2/tests/bug_gc.py
Daniele Varrazzo ade1b2cc7b Test suite converted into a proper package.
Dropped cyclic import from modules to tests: they were only working
because a second copy of the package was found in the project dir.
Use relative import so that 2to3 can do a good conversion.
2010-12-21 05:02:19 +00:00

28 lines
714 B
Python
Executable File

#!/usr/bin/env python
import psycopg2
import psycopg2.extensions
import time
import unittest
import gc
from testconfig import dsn
class StolenReferenceTestCase(unittest.TestCase):
def test_stolen_reference_bug(self):
def fish(val, cur):
gc.collect()
return 42
conn = psycopg2.connect(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()