mirror of
https://github.com/python/cpython.git
synced 2025-10-26 11:14:33 +00:00
gh-71339: Use new assertion methods in test_sqlite3 (GH-128830)
This commit is contained in:
parent
ff3e145b27
commit
75bd42c737
3 changed files with 22 additions and 33 deletions
|
|
@ -59,45 +59,34 @@ def test_param_style(self):
|
|||
sqlite.paramstyle)
|
||||
|
||||
def test_warning(self):
|
||||
self.assertTrue(issubclass(sqlite.Warning, Exception),
|
||||
"Warning is not a subclass of Exception")
|
||||
self.assertIsSubclass(sqlite.Warning, Exception)
|
||||
|
||||
def test_error(self):
|
||||
self.assertTrue(issubclass(sqlite.Error, Exception),
|
||||
"Error is not a subclass of Exception")
|
||||
self.assertIsSubclass(sqlite.Error, Exception)
|
||||
|
||||
def test_interface_error(self):
|
||||
self.assertTrue(issubclass(sqlite.InterfaceError, sqlite.Error),
|
||||
"InterfaceError is not a subclass of Error")
|
||||
self.assertIsSubclass(sqlite.InterfaceError, sqlite.Error)
|
||||
|
||||
def test_database_error(self):
|
||||
self.assertTrue(issubclass(sqlite.DatabaseError, sqlite.Error),
|
||||
"DatabaseError is not a subclass of Error")
|
||||
self.assertIsSubclass(sqlite.DatabaseError, sqlite.Error)
|
||||
|
||||
def test_data_error(self):
|
||||
self.assertTrue(issubclass(sqlite.DataError, sqlite.DatabaseError),
|
||||
"DataError is not a subclass of DatabaseError")
|
||||
self.assertIsSubclass(sqlite.DataError, sqlite.DatabaseError)
|
||||
|
||||
def test_operational_error(self):
|
||||
self.assertTrue(issubclass(sqlite.OperationalError, sqlite.DatabaseError),
|
||||
"OperationalError is not a subclass of DatabaseError")
|
||||
self.assertIsSubclass(sqlite.OperationalError, sqlite.DatabaseError)
|
||||
|
||||
def test_integrity_error(self):
|
||||
self.assertTrue(issubclass(sqlite.IntegrityError, sqlite.DatabaseError),
|
||||
"IntegrityError is not a subclass of DatabaseError")
|
||||
self.assertIsSubclass(sqlite.IntegrityError, sqlite.DatabaseError)
|
||||
|
||||
def test_internal_error(self):
|
||||
self.assertTrue(issubclass(sqlite.InternalError, sqlite.DatabaseError),
|
||||
"InternalError is not a subclass of DatabaseError")
|
||||
self.assertIsSubclass(sqlite.InternalError, sqlite.DatabaseError)
|
||||
|
||||
def test_programming_error(self):
|
||||
self.assertTrue(issubclass(sqlite.ProgrammingError, sqlite.DatabaseError),
|
||||
"ProgrammingError is not a subclass of DatabaseError")
|
||||
self.assertIsSubclass(sqlite.ProgrammingError, sqlite.DatabaseError)
|
||||
|
||||
def test_not_supported_error(self):
|
||||
self.assertTrue(issubclass(sqlite.NotSupportedError,
|
||||
sqlite.DatabaseError),
|
||||
"NotSupportedError is not a subclass of DatabaseError")
|
||||
self.assertIsSubclass(sqlite.NotSupportedError, sqlite.DatabaseError)
|
||||
|
||||
def test_module_constants(self):
|
||||
consts = [
|
||||
|
|
@ -274,7 +263,7 @@ def test_module_constants(self):
|
|||
consts.append("SQLITE_IOERR_CORRUPTFS")
|
||||
for const in consts:
|
||||
with self.subTest(const=const):
|
||||
self.assertTrue(hasattr(sqlite, const))
|
||||
self.assertHasAttr(sqlite, const)
|
||||
|
||||
def test_error_code_on_exception(self):
|
||||
err_msg = "unable to open database file"
|
||||
|
|
@ -288,7 +277,7 @@ def test_error_code_on_exception(self):
|
|||
sqlite.connect(db)
|
||||
e = cm.exception
|
||||
self.assertEqual(e.sqlite_errorcode, err_code)
|
||||
self.assertTrue(e.sqlite_errorname.startswith("SQLITE_CANTOPEN"))
|
||||
self.assertStartsWith(e.sqlite_errorname, "SQLITE_CANTOPEN")
|
||||
|
||||
def test_extended_error_code_on_exception(self):
|
||||
with memory_database() as con:
|
||||
|
|
@ -425,7 +414,7 @@ def test_connection_exceptions(self):
|
|||
]
|
||||
for exc in exceptions:
|
||||
with self.subTest(exc=exc):
|
||||
self.assertTrue(hasattr(self.cx, exc))
|
||||
self.assertHasAttr(self.cx, exc)
|
||||
self.assertIs(getattr(sqlite, exc), getattr(self.cx, exc))
|
||||
|
||||
def test_interrupt_on_closed_db(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue