Visitar URL original
bpo-26187: Tests sqlite3 trace callback no duplicate on shcema changing by palaviv · Pull Request #461 · python/cpython · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
CR fixes
  • Loading branch information
palaviv committed Mar 12, 2017
commit 94dd92de9479480f900a4db92764f2b419651a71
17 changes: 8 additions & 9 deletions Lib/sqlite3/test/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import unittest
import sqlite3 as sqlite
from tempfile import NamedTemporaryFile
import tempfile

class CollationTests(unittest.TestCase):
def CheckCreateCollationNotString(self):
Expand Down Expand Up @@ -252,15 +252,15 @@ def trace(statement):
@unittest.skipIf(sqlite.sqlite_version_info < (3, 3, 9), "sqlite3_prepare_v2 is not available")
def CheckTraceCallbackContent(self):
"""
Test that the statement are correct. Fix for bpo-26187
bpo-26187

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer a plain Python comment instead of a docstring:

# set_trace_callback() shouldn't produce duplicate content (bpo-26187)

"""
with NamedTemporaryFile(suffix='.sqlite') as db_path:
traced_statements = []
def trace(statement):
traced_statements.append(statement)
traced_statements = []
def trace(statement):
traced_statements.append(statement)

queries = ["create table foo(x)",
"insert into foo(x) values(1)"]
queries = ["create table foo(x)",
"insert into foo(x) values(1)"]
with tempfile.NamedTemporaryFile(suffix='.sqlite') as db_path:
con1 = sqlite.connect(db_path.name, isolation_level=None)
con2 = sqlite.connect(db_path.name)
con1.set_trace_callback(trace)
Expand All @@ -271,7 +271,6 @@ def trace(statement):
self.assertEqual(traced_statements, queries)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Please delete the extra new line.



def suite():
collation_suite = unittest.makeSuite(CollationTests, "Check")
progress_suite = unittest.makeSuite(ProgressTests, "Check")
Expand Down