Kaydet (Commit) c8120092 authored tarafından Serhiy Storchaka's avatar Serhiy Storchaka

Issue #27897: Backported tests.

üst 2b91fadc
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment