def test_open_and_close(self):
# ProfileConfig.open() returns a context manager that closes the
# database on exit.
config_file = os.path.join(self.make_dir(), "config")
config = api.ProfileConfig.open(config_file)
self.assertIsInstance(config, contextlib._GeneratorContextManager)
with config as config:
self.assertIsInstance(config, api.ProfileConfig)
with config.cursor() as cursor:
self.assertEqual(
(1,), cursor.execute("SELECT 1").fetchone())
self.assertRaises(sqlite3.ProgrammingError, config.cursor)
评论列表
文章目录