2008-01-19 06:32:42 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
import psycopg2
|
|
|
|
import tests
|
|
|
|
|
|
|
|
|
|
|
|
class ConnectionTests(unittest.TestCase):
|
|
|
|
|
|
|
|
def connect(self):
|
2008-04-21 03:12:21 +04:00
|
|
|
return psycopg2.connect(tests.dsn)
|
2008-01-19 06:32:42 +03:00
|
|
|
|
|
|
|
def test_closed_attribute(self):
|
|
|
|
conn = self.connect()
|
|
|
|
self.assertEqual(conn.closed, False)
|
|
|
|
conn.close()
|
|
|
|
self.assertEqual(conn.closed, True)
|
|
|
|
|
|
|
|
def test_cursor_closed_attribute(self):
|
|
|
|
conn = self.connect()
|
|
|
|
curs = conn.cursor()
|
|
|
|
self.assertEqual(curs.closed, False)
|
|
|
|
curs.close()
|
|
|
|
self.assertEqual(curs.closed, True)
|
|
|
|
|
|
|
|
# Closing the connection closes the cursor:
|
|
|
|
curs = conn.cursor()
|
|
|
|
conn.close()
|
|
|
|
self.assertEqual(curs.closed, True)
|
|
|
|
|
|
|
|
|
|
|
|
def test_suite():
|
|
|
|
return unittest.TestLoader().loadTestsFromName(__name__)
|
|
|
|
|