summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/assertsql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-11-11 14:57:08 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2019-11-11 14:57:08 -0500
commit3cf0a1642eafe53e3c3b40b06cf105a32676a27f (patch)
tree314230b1febe25874a92ae806e0d95913322375a /lib/sqlalchemy/testing/assertsql.py
parent5c7754d685df3715da76327c7401e99177611daf (diff)
downloadsqlalchemy-3cf0a1642eafe53e3c3b40b06cf105a32676a27f.tar.gz
Test fixture improvements
- ensure we escape out percent signs when a CompiledSQL or RegexSQL has percent signs in the SQL or in the parameter repr - to support combinations, print out complete test name in skip messages, py.test environment gives us a way to do this Change-Id: Ia9e62f7c1026c1465986144c5757e35fc164a2b8
Diffstat (limited to 'lib/sqlalchemy/testing/assertsql.py')
-rw-r--r--lib/sqlalchemy/testing/assertsql.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/sqlalchemy/testing/assertsql.py b/lib/sqlalchemy/testing/assertsql.py
index 6a654df1e..3a8f45918 100644
--- a/lib/sqlalchemy/testing/assertsql.py
+++ b/lib/sqlalchemy/testing/assertsql.py
@@ -182,10 +182,13 @@ class CompiledSQL(SQLMatchRule):
def _failure_message(self, expected_params):
return (
- "Testing for compiled statement %r partial params %r, "
+ "Testing for compiled statement %r partial params %s, "
"received %%(received_statement)r with params "
"%%(received_parameters)r"
- % (self.statement.replace("%", "%%"), expected_params)
+ % (
+ self.statement.replace("%", "%%"),
+ repr(expected_params).replace("%", "%%"),
+ )
)
@@ -199,9 +202,13 @@ class RegexSQL(CompiledSQL):
def _failure_message(self, expected_params):
return (
- "Testing for compiled statement ~%r partial params %r, "
+ "Testing for compiled statement ~%r partial params %s, "
"received %%(received_statement)r with params "
- "%%(received_parameters)r" % (self.orig_regex, expected_params)
+ "%%(received_parameters)r"
+ % (
+ self.orig_regex.replace("%", "%%"),
+ repr(expected_params).replace("%", "%%"),
+ )
)
def _compare_sql(self, execute_observed, received_statement):