mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-13 04:26:33 +03:00
ade1b2cc7b
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.
28 lines
714 B
Python
Executable File
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()
|