diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-05-30 00:21:11 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-05-30 00:21:11 -0400 |
commit | 2c8689fd141c278a7bbc250087e553b76a515bc6 (patch) | |
tree | 2f6bf4c48b34b0d60f540cf9d79726da515fc0ac /lib/sqlalchemy/testing/assertsql.py | |
parent | 1bd578998b89a7e3c08e50d04f37daefbf307a58 (diff) | |
download | sqlalchemy-2c8689fd141c278a7bbc250087e553b76a515bc6.tar.gz |
- 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.
Diffstat (limited to 'lib/sqlalchemy/testing/assertsql.py')
-rw-r--r-- | lib/sqlalchemy/testing/assertsql.py | 21 |
1 files changed, 20 insertions, 1 deletions
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: |