summaryrefslogtreecommitdiffstats
path: root/Lib/sqlite3/test
diff options
context:
space:
mode:
authorGerhard Häring <gh@ghaering.de>2008-02-29 22:22:09 (GMT)
committerGerhard Häring <gh@ghaering.de>2008-02-29 22:22:09 (GMT)
commit873d9ff84cf991a4a63d659479ab97724e44283d (patch)
treec809464127100eab12ba8223653c2ad06fed1fda /Lib/sqlite3/test
parent20c892db1012a84431c75d21565e4a6af538cfed (diff)
downloadcpython-873d9ff84cf991a4a63d659479ab97724e44283d.zip
cpython-873d9ff84cf991a4a63d659479ab97724e44283d.tar.gz
cpython-873d9ff84cf991a4a63d659479ab97724e44283d.tar.bz2
Make sure we get usable error messages when text could not be decoded when fetched from the database.
Diffstat (limited to 'Lib/sqlite3/test')
-rw-r--r--Lib/sqlite3/test/regression.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py
index df2a6fb..4a68d9d 100644
--- a/Lib/sqlite3/test/regression.py
+++ b/Lib/sqlite3/test/regression.py
@@ -79,6 +79,20 @@ class RegressionTests(unittest.TestCase):
cur.fetchone()
cur.fetchone()
+ def CheckErrorMsgDecodeError(self):
+ # When porting the module to Python 3.0, the error message about
+ # decoding errors disappeared. This verifies they're back again.
+ failure = None
+ try:
+ self.con.execute("select 'xxx' || ? || 'yyy' colname", (bytes(bytearray([250])),)).fetchone()
+ failure = "should have raised an OperationalError with detailed description"
+ except sqlite.OperationalError as e:
+ msg = e.args[0]
+ if not msg.startswith("Could not decode to UTF-8 column 'colname' with text 'xxx"):
+ failure = "OperationalError did not have expected description text"
+ if failure:
+ self.fail(failure)
+
def suite():
regression_suite = unittest.makeSuite(RegressionTests, "Check")
return unittest.TestSuite((regression_suite,))