diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2010-12-30 23:47:02 +0000 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2011-01-05 17:35:42 +0000 |
commit | e01643fdc290a668e5a532da7f8eccd9bf0856ca (patch) | |
tree | 58feaed9aec5488fd4a79fba83fbd7a1e527a31c /tests | |
parent | 2730cf23367fb0d2198b402c2bf4cb98a82cef42 (diff) |
tests: improve assertion when forbidden events occur
This makes the backtraces prettier; it doesn't have any functional
effect.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/twisted/servicetest.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/twisted/servicetest.py b/tests/twisted/servicetest.py index 700c05ad..36ff6683 100644 --- a/tests/twisted/servicetest.py +++ b/tests/twisted/servicetest.py @@ -93,6 +93,14 @@ class EventPattern: class TimeoutError(Exception): pass +class ForbiddenEventOccurred(Exception): + def __init__(self, event): + Exception.__init__(self) + self.event = event + + def __str__(self): + return '\n' + '\n'.join(format_event(self.event)) + class BaseEventQueue: """Abstract event queue base class. @@ -155,10 +163,7 @@ class BaseEventQueue: def _check_forbidden(self, event): for e in self.forbidden_events: if e.match(event): - print "forbidden event occurred:" - for x in format_event(event): - print x - assert False + raise ForbiddenEventOccurred(event) def expect(self, type, **kw): pattern = EventPattern(type, **kw) |