/usr/lib/python2.7/dist-packages/testtools/matchers/_const.py is in python-testtools 2.3.0-3ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | # Copyright (c) 2016 testtools developers. See LICENSE for details.
__all__ = [
'Always',
'Never',
]
from testtools.compat import _u
from ._impl import Mismatch
class _Always(object):
"""Always matches."""
def __str__(self):
return 'Always()'
def match(self, value):
return None
def Always():
"""Always match.
That is::
self.assertThat(x, Always())
Will always match and never fail, no matter what ``x`` is. Most useful when
passed to other higher-order matchers (e.g.
:py:class:`~testtools.matchers.MatchesListwise`).
"""
return _Always()
class _Never(object):
"""Never matches."""
def __str__(self):
return 'Never()'
def match(self, value):
return Mismatch(
_u('Inevitable mismatch on %r' % (value,)))
def Never():
"""Never match.
That is::
self.assertThat(x, Never())
Will never match and always fail, no matter what ``x`` is. Included for
completeness with :py:func:`.Always`, but if you find a use for this, let
us know!
"""
return _Never()
|