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`.
This commit is contained in:
Erlend Egeberg Aasland 2021-06-23 14:56:40 +02:00 committed by GitHub
parent 489699ca05
commit a50e28377b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 66 additions and 48 deletions

View file

@ -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)"