Mercurial > cpython-lru_cache-weakref
diff Lib/sqlite3/test/dbapi.py @ 59374:ecca703bc0df 3.1
Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
| author | Gerhard Häring <gh@ghaering.de> |
|---|---|
| date | Fri, 05 Mar 2010 15:55:55 +0000 |
| parents | 680ad8eed33b |
| children | 2beb25369289 |
line wrap: on
line diff
--- a/Lib/sqlite3/test/dbapi.py Fri Mar 05 14:45:49 2010 +0000 +++ b/Lib/sqlite3/test/dbapi.py Fri Mar 05 15:55:55 2010 +0000 @@ -744,6 +744,73 @@ except: self.fail("Should have raised a ProgrammingError") + + def CheckClosedCreateFunction(self): + con = sqlite.connect(":memory:") + con.close() + def f(x): return 17 + try: + con.create_function("foo", 1, f) + self.fail("Should have raised a ProgrammingError") + except sqlite.ProgrammingError: + pass + except: + self.fail("Should have raised a ProgrammingError") + + def CheckClosedCreateAggregate(self): + con = sqlite.connect(":memory:") + con.close() + class Agg: + def __init__(self): + pass + def step(self, x): + pass + def finalize(self): + return 17 + try: + con.create_aggregate("foo", 1, Agg) + self.fail("Should have raised a ProgrammingError") + except sqlite.ProgrammingError: + pass + except: + self.fail("Should have raised a ProgrammingError") + + def CheckClosedSetAuthorizer(self): + con = sqlite.connect(":memory:") + con.close() + def authorizer(*args): + return sqlite.DENY + try: + con.set_authorizer(authorizer) + self.fail("Should have raised a ProgrammingError") + except sqlite.ProgrammingError: + pass + except: + self.fail("Should have raised a ProgrammingError") + + def CheckClosedSetProgressCallback(self): + con = sqlite.connect(":memory:") + con.close() + def progress(): pass + try: + con.set_progress_handler(progress, 100) + self.fail("Should have raised a ProgrammingError") + except sqlite.ProgrammingError: + pass + except: + self.fail("Should have raised a ProgrammingError") + + def CheckClosedCall(self): + con = sqlite.connect(":memory:") + con.close() + try: + con() + self.fail("Should have raised a ProgrammingError") + except sqlite.ProgrammingError: + pass + except: + self.fail("Should have raised a ProgrammingError") + def suite(): module_suite = unittest.makeSuite(ModuleTests, "Check") connection_suite = unittest.makeSuite(ConnectionTests, "Check")
