From: Serhiy Storchaka Date: Mon, 26 Sep 2016 21:27:15 +0000 (+0300) Subject: Issue #27897: Backported tests. X-Git-Tag: v2.7.13rc1~111 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c8120092ddf9df6d9feb925876f8f807e36234a0;p=python Issue #27897: Backported tests. --- diff --git a/Lib/sqlite3/test/hooks.py b/Lib/sqlite3/test/hooks.py index 16f217d8fc..a5b1632a18 100644 --- a/Lib/sqlite3/test/hooks.py +++ b/Lib/sqlite3/test/hooks.py @@ -31,6 +31,11 @@ class CollationTests(unittest.TestCase): 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 @@ class CollationTests(unittest.TestCase): 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