Completed
Pull Request — master (#81)
by
unknown
01:06
created

src.hamcrest.library.collection.IsIn   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 11
Duplicated Lines 0 %
Metric Value
dl 0
loc 11
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A IsIn._matches() 0 2 1
A IsIn.__init__() 0 2 1
A IsIn.describe_to() 0 3 1
1
from hamcrest.core.base_matcher import BaseMatcher
2
3
__author__ = "Jon Reid"
4
__copyright__ = "Copyright 2011 hamcrest.org"
5
__license__ = "BSD, see License.txt"
6
7
8
class IsIn(BaseMatcher):
9
10
    def __init__(self, sequence):
11
        self.sequence = sequence
12
13
    def _matches(self, item):
14
        return item in self.sequence
15
16
    def describe_to(self, description):
17
        description.append_text('one of ')      \
18
                   .append_list('(', ', ', ')', self.sequence)
19
20
21
def is_in(sequence):
22
    """Matches if evaluated object is present in a given sequence.
23
24
    :param sequence: The sequence to search.
25
26
    This matcher invokes the ``in`` membership operator to determine if the
27
    evaluated object is a member of the sequence.
28
29
    """
30
    return IsIn(sequence)
31