1# Copyright (c) 2016 testtools developers. See LICENSE for details.
2
3__all__ = [
4    'Always',
5    'Never',
6    ]
7
8from ._impl import Mismatch
9
10
11class _Always:
12    """Always matches."""
13
14    def __str__(self):
15        return 'Always()'
16
17    def match(self, value):
18        return None
19
20
21def Always():
22    """Always match.
23
24    That is::
25
26        self.assertThat(x, Always())
27
28    Will always match and never fail, no matter what ``x`` is. Most useful when
29    passed to other higher-order matchers (e.g.
30    :py:class:`~testtools.matchers.MatchesListwise`).
31    """
32    return _Always()
33
34
35class _Never:
36    """Never matches."""
37
38    def __str__(self):
39        return 'Never()'
40
41    def match(self, value):
42        return Mismatch(
43            'Inevitable mismatch on {!r}'.format(value))
44
45
46def Never():
47    """Never match.
48
49    That is::
50
51        self.assertThat(x, Never())
52
53    Will never match and always fail, no matter what ``x`` is. Included for
54    completeness with :py:func:`.Always`, but if you find a use for this, let
55    us know!
56    """
57    return _Never()
58