diff options
author | Guido van Rossum <guido@python.org> | 2007-11-06 21:34:58 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-11-06 21:34:58 (GMT) |
commit | 98297ee7815939b124156e438b22bd652d67b5db (patch) | |
tree | a9d239ebd87c73af2571ab48003984c4e18e27e5 /Lib/sqlite3/test | |
parent | a19f80c6df2df5e8a5d0cff37131097835ef971e (diff) | |
download | cpython-98297ee7815939b124156e438b22bd652d67b5db.zip cpython-98297ee7815939b124156e438b22bd652d67b5db.tar.gz cpython-98297ee7815939b124156e438b22bd652d67b5db.tar.bz2 |
Merging the py3k-pep3137 branch back into the py3k branch.
No detailed change log; just check out the change log for the py3k-pep3137
branch. The most obvious changes:
- str8 renamed to bytes (PyString at the C level);
- bytes renamed to buffer (PyBytes at the C level);
- PyString and PyUnicode are no longer compatible.
I.e. we now have an immutable bytes type and a mutable bytes type.
The behavior of PyString was modified quite a bit, to make it more
bytes-like. Some changes are still on the to-do list.
Diffstat (limited to 'Lib/sqlite3/test')
-rw-r--r-- | Lib/sqlite3/test/factory.py | 4 | ||||
-rw-r--r-- | Lib/sqlite3/test/types.py | 22 | ||||
-rw-r--r-- | Lib/sqlite3/test/userfunctions.py | 2 |
3 files changed, 14 insertions, 14 deletions
diff --git a/Lib/sqlite3/test/factory.py b/Lib/sqlite3/test/factory.py index f20848f..a9a828f 100644 --- a/Lib/sqlite3/test/factory.py +++ b/Lib/sqlite3/test/factory.py @@ -163,8 +163,8 @@ class TextFactoryTests(unittest.TestCase): germany = "Deutchland" a_row = self.con.execute("select ?", (austria,)).fetchone() d_row = self.con.execute("select ?", (germany,)).fetchone() - self.failUnless(type(a_row[0]) == str, "type of non-ASCII row must be unicode") - self.failUnless(type(d_row[0]) == str8, "type of ASCII-only row must be str8") + self.failUnless(type(a_row[0]) == str, "type of non-ASCII row must be str") + self.failUnless(type(d_row[0]) == str, "type of ASCII-only row must be str") def tearDown(self): self.con.close() diff --git a/Lib/sqlite3/test/types.py b/Lib/sqlite3/test/types.py index 4ff948d..8845e0c 100644 --- a/Lib/sqlite3/test/types.py +++ b/Lib/sqlite3/test/types.py @@ -62,11 +62,12 @@ class SqliteTypeTests(unittest.TestCase): self.failUnlessEqual(row[0], val) def CheckBlob(self): - val = memoryview(b"Guglhupf") + sample = b"Guglhupf" + val = memoryview(sample) self.cur.execute("insert into test(b) values (?)", (val,)) self.cur.execute("select b from test") row = self.cur.fetchone() - self.failUnlessEqual(row[0], val) + self.failUnlessEqual(row[0], sample) def CheckUnicodeExecute(self): self.cur.execute("select 'Österreich'") @@ -76,8 +77,8 @@ class SqliteTypeTests(unittest.TestCase): class DeclTypesTests(unittest.TestCase): class Foo: def __init__(self, _val): - if isinstance(_val, str8): - # sqlite3 always calls __init__ with a str8 created from a + if isinstance(_val, bytes): + # sqlite3 always calls __init__ with a bytes created from a # UTF-8 string when __conform__ was used to store the object. _val = _val.decode('utf8') self.val = _val @@ -207,11 +208,12 @@ class DeclTypesTests(unittest.TestCase): def CheckBlob(self): # default - val = memoryview(b"Guglhupf") + sample = b"Guglhupf" + val = memoryview(sample) self.cur.execute("insert into test(bin) values (?)", (val,)) self.cur.execute("select bin from test") row = self.cur.fetchone() - self.failUnlessEqual(row[0], val) + self.failUnlessEqual(row[0], sample) class ColNamesTests(unittest.TestCase): def setUp(self): @@ -219,13 +221,11 @@ class ColNamesTests(unittest.TestCase): self.cur = self.con.cursor() self.cur.execute("create table test(x foo)") - sqlite.converters["FOO"] = lambda x: "[%s]" % x - sqlite.converters["BAR"] = lambda x: "<%s>" % x + sqlite.converters["BAR"] = lambda x: b"<" + x + b">" sqlite.converters["EXC"] = lambda x: 5/0 sqlite.converters["B1B1"] = lambda x: "MARKER" def tearDown(self): - del sqlite.converters["FOO"] del sqlite.converters["BAR"] del sqlite.converters["EXC"] del sqlite.converters["B1B1"] @@ -252,14 +252,14 @@ class ColNamesTests(unittest.TestCase): self.cur.execute("insert into test(x) values (?)", ("xxx",)) self.cur.execute('select x as "x [bar]" from test') val = self.cur.fetchone()[0] - self.failUnlessEqual(val, "<xxx>") + self.failUnlessEqual(val, b"<xxx>") # Check if the stripping of colnames works. Everything after the first # whitespace should be stripped. self.failUnlessEqual(self.cur.description[0][0], "x") def CheckCaseInConverterName(self): - self.cur.execute("""select 'other' as "x [b1b1]\"""") + self.cur.execute("select 'other' as \"x [b1b1]\"") val = self.cur.fetchone()[0] self.failUnlessEqual(val, "MARKER") diff --git a/Lib/sqlite3/test/userfunctions.py b/Lib/sqlite3/test/userfunctions.py index 994057e..dc3a709 100644 --- a/Lib/sqlite3/test/userfunctions.py +++ b/Lib/sqlite3/test/userfunctions.py @@ -198,7 +198,7 @@ class FunctionTests(unittest.TestCase): cur.execute("select returnblob()") val = cur.fetchone()[0] self.failUnlessEqual(type(val), bytes) - self.failUnlessEqual(val, memoryview(b"blob")) + self.failUnlessEqual(val, b"blob") def CheckFuncException(self): cur = self.con.cursor() |