[Python-checkins] cpython (2.7): Issue #27897: Backported tests.

serhiy.storchaka python-checkins at python.org
Mon Sep 26 17:27:48 EDT 2016


https://hg.python.org/cpython/rev/1aae9b7ff321
changeset:   104090:1aae9b7ff321
branch:      2.7
parent:      104056:94a26aa1b1e0
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Tue Sep 27 00:27:15 2016 +0300
summary:
  Issue #27897: Backported tests.

files:
  Lib/sqlite3/test/hooks.py |  22 ++++++++++++++++++++++
  1 files changed, 22 insertions(+), 0 deletions(-)


diff --git a/Lib/sqlite3/test/hooks.py b/Lib/sqlite3/test/hooks.py
--- a/Lib/sqlite3/test/hooks.py
+++ b/Lib/sqlite3/test/hooks.py
@@ -31,6 +31,11 @@
     def tearDown(self):
         pass
 
+    def CheckCreateCollationNotString(self):
+        con = sqlite.connect(":memory:")
+        with self.assertRaises(TypeError):
+            con.create_collation(None, lambda x, y: (x > y) - (x < y))
+
     def CheckCreateCollationNotCallable(self):
         con = sqlite.connect(":memory:")
         try:
@@ -47,6 +52,23 @@
         except sqlite.ProgrammingError, e:
             pass
 
+    def CheckCreateCollationBadUpper(self):
+        class BadUpperStr(str):
+            def upper(self):
+                return None
+        con = sqlite.connect(":memory:")
+        mycoll = lambda x, y: -((x > y) - (x < y))
+        con.create_collation(BadUpperStr("mycoll"), mycoll)
+        result = con.execute("""
+            select x from (
+            select 'a' as x
+            union
+            select 'b' as x
+            ) order by x collate mycoll
+            """).fetchall()
+        self.assertEqual(result[0][0], 'b')
+        self.assertEqual(result[1][0], 'a')
+
     def CheckCollationIsUsed(self):
         if sqlite.version_info < (3, 2, 1):  # old SQLite versions crash on this test
             return

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list