diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2021-06-23 12:56:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-23 12:56:40 (GMT) |
commit | a50e28377bcf37121b55c2de70d95a5386c478f8 (patch) | |
tree | 10bd9512e7501dc798630a89770254be220d0905 /Lib/sqlite3 | |
parent | 489699ca05bed5cfd10e847d8580840812b476cd (diff) | |
download | cpython-a50e28377bcf37121b55c2de70d95a5386c478f8.zip cpython-a50e28377bcf37121b55c2de70d95a5386c478f8.tar.gz cpython-a50e28377bcf37121b55c2de70d95a5386c478f8.tar.bz2 |
bpo-42064: Move `sqlite3` exceptions to global state, part 1 of 2 (GH-26745)
Also adds a test to verify the (borrowed) exceptions in `sqlite3.Connection`.
Diffstat (limited to 'Lib/sqlite3')
-rw-r--r-- | Lib/sqlite3/test/dbapi.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/dbapi.py b/Lib/sqlite3/test/dbapi.py index c9bcac9..7e44cac 100644 --- a/Lib/sqlite3/test/dbapi.py +++ b/Lib/sqlite3/test/dbapi.py @@ -208,6 +208,24 @@ class ConnectionTests(unittest.TestCase): with self.assertRaises(AttributeError): self.cx.in_transaction = True + def test_connection_exceptions(self): + exceptions = [ + "DataError", + "DatabaseError", + "Error", + "IntegrityError", + "InterfaceError", + "NotSupportedError", + "OperationalError", + "ProgrammingError", + "Warning", + ] + for exc in exceptions: + with self.subTest(exc=exc): + self.assertTrue(hasattr(self.cx, exc)) + self.assertIs(getattr(sqlite, exc), getattr(self.cx, exc)) + + class OpenTests(unittest.TestCase): _sql = "create table test(id integer)" |