summaryrefslogtreecommitdiff
path: root/tests/test_connection.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_connection.py')
-rwxr-xr-xtests/test_connection.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_connection.py b/tests/test_connection.py
index 340693e..fa78eb3 100755
--- a/tests/test_connection.py
+++ b/tests/test_connection.py
@@ -129,6 +129,42 @@ class ConnectionTests(ConnectingTestCase):
self.assertEqual(50, len(conn.notices))
self.assert_('table99' in conn.notices[-1], conn.notices[-1])
+ def test_notices_deque(self):
+ from collections import deque
+
+ conn = self.conn
+ self.conn.notices = deque()
+ cur = conn.cursor()
+ if self.conn.server_version >= 90300:
+ cur.execute("set client_min_messages=debug1")
+
+ cur.execute("create temp table table1 (id serial); create temp table table2 (id serial);")
+ cur.execute("create temp table table3 (id serial); create temp table table4 (id serial);")
+ self.assertEqual(len(conn.notices), 4)
+ self.assert_('table1' in conn.notices.popleft())
+ self.assert_('table2' in conn.notices.popleft())
+ self.assert_('table3' in conn.notices.popleft())
+ self.assert_('table4' in conn.notices.popleft())
+ self.assertEqual(len(conn.notices), 0)
+
+ # not limited, but no error
+ for i in range(0, 100, 10):
+ sql = " ".join(["create temp table table2_%d (id serial);" % j for j in range(i, i+10)])
+ cur.execute(sql)
+
+ self.assertEqual(100, len(conn.notices))
+
+ def test_notices_noappend(self):
+ conn = self.conn
+ self.conn.notices = None # will make an error swallowes ok
+ cur = conn.cursor()
+ if self.conn.server_version >= 90300:
+ cur.execute("set client_min_messages=debug1")
+
+ cur.execute("create temp table table1 (id serial);")
+
+ self.assertEqual(self.conn.notices, None)
+
def test_server_version(self):
self.assert_(self.conn.server_version)