diff options
author | Aviv Palivoda <palaviv@gmail.com> | 2017-04-09 09:11:59 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2017-04-09 09:11:59 (GMT) |
commit | 0e6cb2ea624570ed08c354f1ed1f595dab4192d6 (patch) | |
tree | 736e7b8799d50375a64f1bfa21415703100688f2 /Lib/sqlite3 | |
parent | 2abfdf5a81383d3b1ed6b7321903a9a168c373c5 (diff) | |
download | cpython-0e6cb2ea624570ed08c354f1ed1f595dab4192d6.zip cpython-0e6cb2ea624570ed08c354f1ed1f595dab4192d6.tar.gz cpython-0e6cb2ea624570ed08c354f1ed1f595dab4192d6.tar.bz2 |
bpo-26187: Test that set_trace_callback() is not called multiple times (GH-461)
conn.set_trace_callback() shouldn't be called multiple times when the
schema is changing.
This has indirectly been fixed by using sqlite3_prepare_v2() in bpo-9303.
Diffstat (limited to 'Lib/sqlite3')
-rw-r--r-- | Lib/sqlite3/test/hooks.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/hooks.py b/Lib/sqlite3/test/hooks.py index f8ef4d8..801a30c 100644 --- a/Lib/sqlite3/test/hooks.py +++ b/Lib/sqlite3/test/hooks.py @@ -24,6 +24,8 @@ import unittest import sqlite3 as sqlite +from test.support import TESTFN, unlink + class CollationTests(unittest.TestCase): def CheckCreateCollationNotString(self): con = sqlite.connect(":memory:") @@ -248,6 +250,24 @@ class TraceCallbackTests(unittest.TestCase): "Unicode data %s garbled in trace callback: %s" % (ascii(unicode_value), ', '.join(map(ascii, traced_statements)))) + @unittest.skipIf(sqlite.sqlite_version_info < (3, 3, 9), "sqlite3_prepare_v2 is not available") + def CheckTraceCallbackContent(self): + # set_trace_callback() shouldn't produce duplicate content (bpo-26187) + traced_statements = [] + def trace(statement): + traced_statements.append(statement) + + queries = ["create table foo(x)", + "insert into foo(x) values(1)"] + self.addCleanup(unlink, TESTFN) + con1 = sqlite.connect(TESTFN, isolation_level=None) + con2 = sqlite.connect(TESTFN) + con1.set_trace_callback(trace) + cur = con1.cursor() + cur.execute(queries[0]) + con2.execute("create table bar(x)") + cur.execute(queries[1]) + self.assertEqual(traced_statements, queries) def suite(): |