src.hamcrest.library.text.SubstringMatcher   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 4 2
A describe_to() 0 5 1
1
__author__ = "Jon Reid"
2
__copyright__ = "Copyright 2011 hamcrest.org"
3
__license__ = "BSD, see License.txt"
4
5
from hamcrest.core.base_matcher import BaseMatcher
6
7
import six
8
9
class SubstringMatcher(BaseMatcher):
10
11
    def __init__(self, substring):
12
        if not isinstance(substring, six.string_types):
13
            raise TypeError(self.__class__.__name__ + ' requires string')
14
        self.substring = substring
15
16
    def describe_to(self, description):
17
        description.append_text('a string ')                \
18
                   .append_text(self.relationship())        \
19
                   .append_text(' ')                        \
20
                   .append_description_of(self.substring)
21