1
"""Custom matchers used by the tests."""
3
from autopilot.matchers import Eventually as EventuallyMatcher
4
from testtools.matchers import Mismatch
7
def Eventually(matcher):
8
"""Wrapper around autopilot.matchers.Eventually.
10
The aim of the wrapper is just use a different timeout default
12
:param matcher: A testools-like matcher that tests the desired condition
14
:returns: A value depending on the matcher protocol
15
:rtype: None | a mismatch object with information about the mismatch
18
return EventuallyMatcher(matcher, timeout=40)
21
class DoesNotChange(object):
22
"""Match if two consecutive values are equal."""
28
return 'DoesNotChange()'
30
def match(self, value):
31
self.old_value = self.value
33
if self.value != self.old_value:
34
return Mismatch('Current value ({}) does not match old value ({})'
35
.format(self.value, self.old_value))