Total Complexity | 4 |
Total Lines | 13 |
Duplicated Lines | 0 % |
1 | from hamcrest.core.base_matcher import BaseMatcher |
||
10 | class IsInstanceOf(BaseMatcher): |
||
11 | |||
12 | def __init__(self, expected_type): |
||
13 | if not is_matchable_type(expected_type): |
||
14 | raise TypeError('IsInstanceOf requires type') |
||
15 | self.expected_type = expected_type |
||
16 | |||
17 | def _matches(self, item): |
||
18 | return isinstance(item, self.expected_type) |
||
19 | |||
20 | def describe_to(self, description): |
||
21 | description.append_text('an instance of ') \ |
||
22 | .append_text(self.expected_type.__name__) |
||
23 | |||
39 |