describe_to()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 5
rs 9.4285
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