From 3cf0a1642eafe53e3c3b40b06cf105a32676a27f Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 11 Nov 2019 14:57:08 -0500 Subject: 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 --- lib/sqlalchemy/testing/assertsql.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'lib/sqlalchemy/testing/assertsql.py') 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): -- cgit v1.2.1