diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-09-26 21:27:15 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-09-26 21:27:15 (GMT) |
commit | c8120092ddf9df6d9feb925876f8f807e36234a0 (patch) | |
tree | ccc3c491d8be83a919bdf7e1456e6b41ae041046 /Lib/sqlite3/test/hooks.py | |
parent | 2b91fadc7f631248d5801ddfb2713d434fc3ea8b (diff) | |
download | cpython-c8120092ddf9df6d9feb925876f8f807e36234a0.zip cpython-c8120092ddf9df6d9feb925876f8f807e36234a0.tar.gz cpython-c8120092ddf9df6d9feb925876f8f807e36234a0.tar.bz2 |
Issue #27897: Backported tests.
Diffstat (limited to 'Lib/sqlite3/test/hooks.py')
-rw-r--r-- | 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 index 16f217d..a5b1632 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 |