From 2c8689fd141c278a7bbc250087e553b76a515bc6 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 30 May 2014 00:21:11 -0400 Subject: - add a new assertsql construct "Or", so that we can test for a UOW flush that might take one of multiple directions; apply this to test_delete_unloaded_m2o which is now illustrating multiple paths due to #3060/#3061, though still doing the right thing. --- lib/sqlalchemy/testing/assertsql.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/testing/assertsql.py b/lib/sqlalchemy/testing/assertsql.py index 3e0d4c9d3..d77fc18a2 100644 --- a/lib/sqlalchemy/testing/assertsql.py +++ b/lib/sqlalchemy/testing/assertsql.py @@ -256,11 +256,30 @@ class AllOf(AssertRule): if rule.rule_passed(): # a rule passed, move on self.rules.remove(rule) return len(self.rules) == 0 - assert False, 'No assertion rules were satisfied for statement' + return False + + def rule_passed(self): + return self.is_consumed() def consume_final(self): return len(self.rules) == 0 +class Or(AllOf): + def __init__(self, *rules): + self.rules = set(rules) + self._consume_final = False + + def is_consumed(self): + if not self.rules: + return True + for rule in list(self.rules): + if rule.rule_passed(): # a rule passed + self._consume_final = True + return True + return False + + def consume_final(self): + assert self._consume_final, "Unsatisified rules remain" def _process_engine_statement(query, context): if util.jython: -- cgit v1.2.1