From fce052b2af28001f4269c0790e0d1c4464813675 Mon Sep 17 00:00:00 2001
From: Mike Bayer <mike_mp@zzzcomputing.com>
Date: Wed, 11 Dec 2019 11:04:26 -0500
Subject: [PATCH] Use regex to compare SQL strings with IN

SQLAlchemy 1.4 will be changing the method by which it
renders an IN expression such that the bound parameters
are not fully rendered until the statement is executed,
rather than when the statement is compiled into its initial
string form [1].   Adjust tests which are asserting the presence
of IN expressions based on the compiled form to allow for an
arbitrary expression within the parenthesis.

[1] https://github.com/sqlalchemy/sqlalchemy/issues/4645

Change-Id: I8640ad0cbd96647ed74678631479190146bd908e
---
 oslo_db/tests/sqlalchemy/test_update_match.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/oslo_db/tests/sqlalchemy/test_update_match.py b/oslo_db/tests/sqlalchemy/test_update_match.py
index 36ebf739..15eeed43 100644
--- a/oslo_db/tests/sqlalchemy/test_update_match.py
+++ b/oslo_db/tests/sqlalchemy/test_update_match.py
@@ -60,19 +60,19 @@ class ManufactureCriteriaTest(oslo_test_base.BaseTestCase):
         specimen = MyModel(
             y='y1', z=('z1', 'z2'),
         )
-        self.assertEqual(
-            "my_table.y = :y_1 AND my_table.z IN (:z_1, :z_2)",
-            str(update_match.manufacture_entity_criteria(specimen).compile())
+        self.assertRegex(
+            str(update_match.manufacture_entity_criteria(specimen).compile()),
+            r"my_table.y = :y_1 AND my_table.z IN \(.+?\)",
         )
 
     def test_instance_criteria_tuples_wnone(self):
         specimen = MyModel(
             y='y1', z=('z1', 'z2', None),
         )
-        self.assertEqual(
-            "my_table.y = :y_1 AND (my_table.z IS NULL OR "
-            "my_table.z IN (:z_1, :z_2))",
-            str(update_match.manufacture_entity_criteria(specimen).compile())
+        self.assertRegex(
+            str(update_match.manufacture_entity_criteria(specimen).compile()),
+            r"my_table.y = :y_1 AND \(my_table.z IS NULL OR "
+            r"my_table.z IN \(.+?\)\)",
         )
 
     def test_instance_criteria_none_list(self):