# HG changeset patch # User Sylvain Thénault # Date 1301995083 -7200 # Node ID c6eb201d4410b7833c13199d70688a40821d80b1 # Parent b85396e65d8f675fcbc40c650e58b42dca4f186e [selectors] abstract ExpectedValueSelector now accept a set as single argument diff -r b85396e65d8f -r c6eb201d4410 selectors.py --- a/selectors.py Tue Apr 05 11:15:35 2011 +0200 +++ b/selectors.py Tue Apr 05 11:18:03 2011 +0200 @@ -387,7 +387,9 @@ class ExpectedValueSelector(Selector): """Take a list of expected values as initializer argument and store them - into the :attr:`expected` set attribute. + into the :attr:`expected` set attribute. You may also give a set as single + argument, which will be then be referenced as set of expected values, + allowing modification to the given set to be considered. You should implement the :meth:`_get_value(cls, req, **kwargs)` method which should return the value for the given context. The selector will then @@ -395,7 +397,10 @@ """ def __init__(self, *expected): assert expected, self - self.expected = frozenset(expected) + if len(expected) == 1 and isinstance(expected[0], set): + self.expected = expected[0] + else: + self.expected = frozenset(expected) def __str__(self): return '%s(%s)' % (self.__class__.__name__,