bpo-42847: Normalise Lib/sqlite3/test/* file encodings (GH-24147)

Convert from ISO-8859-1 to UTF-8.
This commit is contained in:
Erlend Egeberg Aasland 2021-01-07 01:36:35 +01:00 committed by GitHub
parent 849e339a92
commit deab1e54ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 21 deletions

View file

@ -1,7 +1,6 @@
#-*- coding: iso-8859-1 -*-
# pysqlite2/test/dbapi.py: tests for DB-API compliance # pysqlite2/test/dbapi.py: tests for DB-API compliance
# #
# Copyright (C) 2004-2010 Gerhard Häring <gh@ghaering.de> # Copyright (C) 2004-2010 Gerhard Häring <gh@ghaering.de>
# #
# This file is part of pysqlite. # This file is part of pysqlite.
# #

View file

@ -1,7 +1,6 @@
#-*- coding: iso-8859-1 -*-
# pysqlite2/test/factory.py: tests for the various factories in pysqlite # pysqlite2/test/factory.py: tests for the various factories in pysqlite
# #
# Copyright (C) 2005-2007 Gerhard Häring <gh@ghaering.de> # Copyright (C) 2005-2007 Gerhard Häring <gh@ghaering.de>
# #
# This file is part of pysqlite. # This file is part of pysqlite.
# #
@ -235,20 +234,20 @@ class TextFactoryTests(unittest.TestCase):
self.con = sqlite.connect(":memory:") self.con = sqlite.connect(":memory:")
def test_unicode(self): def test_unicode(self):
austria = "Österreich" austria = "Österreich"
row = self.con.execute("select ?", (austria,)).fetchone() row = self.con.execute("select ?", (austria,)).fetchone()
self.assertEqual(type(row[0]), str, "type of row[0] must be unicode") self.assertEqual(type(row[0]), str, "type of row[0] must be unicode")
def test_string(self): def test_string(self):
self.con.text_factory = bytes self.con.text_factory = bytes
austria = "Österreich" austria = "Österreich"
row = self.con.execute("select ?", (austria,)).fetchone() row = self.con.execute("select ?", (austria,)).fetchone()
self.assertEqual(type(row[0]), bytes, "type of row[0] must be bytes") self.assertEqual(type(row[0]), bytes, "type of row[0] must be bytes")
self.assertEqual(row[0], austria.encode("utf-8"), "column must equal original data in UTF-8") self.assertEqual(row[0], austria.encode("utf-8"), "column must equal original data in UTF-8")
def test_custom(self): def test_custom(self):
self.con.text_factory = lambda x: str(x, "utf-8", "ignore") self.con.text_factory = lambda x: str(x, "utf-8", "ignore")
austria = "Österreich" austria = "Österreich"
row = self.con.execute("select ?", (austria,)).fetchone() row = self.con.execute("select ?", (austria,)).fetchone()
self.assertEqual(type(row[0]), str, "type of row[0] must be unicode") self.assertEqual(type(row[0]), str, "type of row[0] must be unicode")
self.assertTrue(row[0].endswith("reich"), "column must contain original data") self.assertTrue(row[0].endswith("reich"), "column must contain original data")
@ -258,7 +257,7 @@ class TextFactoryTests(unittest.TestCase):
with self.assertWarns(DeprecationWarning) as cm: with self.assertWarns(DeprecationWarning) as cm:
self.con.text_factory = sqlite.OptimizedUnicode self.con.text_factory = sqlite.OptimizedUnicode
self.assertIn("factory.py", cm.filename) self.assertIn("factory.py", cm.filename)
austria = "Österreich" austria = "Österreich"
germany = "Deutchland" germany = "Deutchland"
a_row = self.con.execute("select ?", (austria,)).fetchone() a_row = self.con.execute("select ?", (austria,)).fetchone()
d_row = self.con.execute("select ?", (germany,)).fetchone() d_row = self.con.execute("select ?", (germany,)).fetchone()

View file

@ -1,7 +1,6 @@
#-*- coding: iso-8859-1 -*-
# pysqlite2/test/hooks.py: tests for various SQLite-specific hooks # pysqlite2/test/hooks.py: tests for various SQLite-specific hooks
# #
# Copyright (C) 2006-2007 Gerhard Häring <gh@ghaering.de> # Copyright (C) 2006-2007 Gerhard Häring <gh@ghaering.de>
# #
# This file is part of pysqlite. # This file is part of pysqlite.
# #
@ -42,7 +41,7 @@ class CollationTests(unittest.TestCase):
def test_create_collation_not_ascii(self): def test_create_collation_not_ascii(self):
con = sqlite.connect(":memory:") con = sqlite.connect(":memory:")
with self.assertRaises(sqlite.ProgrammingError): with self.assertRaises(sqlite.ProgrammingError):
con.create_collation("collä", lambda x, y: (x > y) - (x < y)) con.create_collation("collä", lambda x, y: (x > y) - (x < y))
def test_create_collation_bad_upper(self): def test_create_collation_bad_upper(self):
class BadUpperStr(str): class BadUpperStr(str):

View file

@ -1,7 +1,6 @@
#-*- coding: iso-8859-1 -*-
# pysqlite2/test/regression.py: pysqlite regression tests # pysqlite2/test/regression.py: pysqlite regression tests
# #
# Copyright (C) 2006-2010 Gerhard Häring <gh@ghaering.de> # Copyright (C) 2006-2010 Gerhard Häring <gh@ghaering.de>
# #
# This file is part of pysqlite. # This file is part of pysqlite.
# #

View file

@ -1,7 +1,6 @@
#-*- coding: iso-8859-1 -*-
# pysqlite2/test/transactions.py: tests transactions # pysqlite2/test/transactions.py: tests transactions
# #
# Copyright (C) 2005-2007 Gerhard Häring <gh@ghaering.de> # Copyright (C) 2005-2007 Gerhard Häring <gh@ghaering.de>
# #
# This file is part of pysqlite. # This file is part of pysqlite.
# #

View file

@ -1,7 +1,6 @@
#-*- coding: iso-8859-1 -*-
# pysqlite2/test/types.py: tests for type conversion and detection # pysqlite2/test/types.py: tests for type conversion and detection
# #
# Copyright (C) 2005 Gerhard Häring <gh@ghaering.de> # Copyright (C) 2005 Gerhard Häring <gh@ghaering.de>
# #
# This file is part of pysqlite. # This file is part of pysqlite.
# #
@ -41,10 +40,10 @@ class SqliteTypeTests(unittest.TestCase):
self.con.close() self.con.close()
def test_string(self): def test_string(self):
self.cur.execute("insert into test(s) values (?)", ("Österreich",)) self.cur.execute("insert into test(s) values (?)", ("Österreich",))
self.cur.execute("select s from test") self.cur.execute("select s from test")
row = self.cur.fetchone() row = self.cur.fetchone()
self.assertEqual(row[0], "Österreich") self.assertEqual(row[0], "Österreich")
def test_small_int(self): def test_small_int(self):
self.cur.execute("insert into test(i) values (?)", (42,)) self.cur.execute("insert into test(i) values (?)", (42,))
@ -75,9 +74,9 @@ class SqliteTypeTests(unittest.TestCase):
self.assertEqual(row[0], sample) self.assertEqual(row[0], sample)
def test_unicode_execute(self): def test_unicode_execute(self):
self.cur.execute("select 'Österreich'") self.cur.execute("select 'Österreich'")
row = self.cur.fetchone() row = self.cur.fetchone()
self.assertEqual(row[0], "Österreich") self.assertEqual(row[0], "Österreich")
class DeclTypesTests(unittest.TestCase): class DeclTypesTests(unittest.TestCase):
class Foo: class Foo: