Code Duplication    Length = 24-26 lines in 2 locations

src/hamcrest/library/collection/issequence_containinginanyorder.py 1 location

@@ 48-73 (lines=26) @@
45
        return False
46
47
48
class IsSequenceContainingInAnyOrder(BaseMatcher):
49
50
    def __init__(self, matchers):
51
        self.matchers = matchers
52
53
    def matches(self, sequence, mismatch_description=None):
54
        try:
55
            sequence = list(sequence)
56
            matchsequence = MatchInAnyOrder(self.matchers, mismatch_description)
57
            for item in sequence:
58
                if not matchsequence.matches(item):
59
                    return False
60
            return matchsequence.isfinished(sequence)
61
        except TypeError:
62
            if mismatch_description:
63
                super(IsSequenceContainingInAnyOrder, self)             \
64
                    .describe_mismatch(sequence, mismatch_description)
65
            return False
66
67
    def describe_mismatch(self, item, mismatch_description):
68
        self.matches(item, mismatch_description)
69
70
    def describe_to(self, description):
71
        description.append_text('a sequence over ')             \
72
                   .append_list('[', ', ', ']', self.matchers)  \
73
                   .append_text(' in any order')
74
75
76
def contains_inanyorder(*items):

src/hamcrest/library/collection/issequence_containinginorder.py 1 location

@@ 46-69 (lines=24) @@
43
        return True
44
45
46
class IsSequenceContainingInOrder(BaseMatcher):
47
48
    def __init__(self, matchers):
49
        self.matchers = matchers
50
51
    def matches(self, sequence, mismatch_description=None):
52
        try:
53
            matchsequence = MatchingInOrder(self.matchers, mismatch_description)
54
            for item in sequence:
55
                if not matchsequence.matches(item):
56
                    return False
57
            return matchsequence.isfinished()
58
        except TypeError:
59
            if mismatch_description:
60
                super(IsSequenceContainingInOrder, self)                \
61
                    .describe_mismatch(sequence, mismatch_description)
62
            return False
63
64
    def describe_mismatch(self, item, mismatch_description):
65
        self.matches(item, mismatch_description)
66
67
    def describe_to(self, description):
68
        description.append_text('a sequence containing ')   \
69
                   .append_list('[', ', ', ']', self.matchers)
70
71
72
def contains(*items):