| Total Complexity | 6 |
| Total Lines | 20 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | from hamcrest.core.base_matcher import BaseMatcher |
||
| 8 | class IsEmpty(BaseMatcher): |
||
| 9 | |||
| 10 | def matches(self, item, mismatch_description=None): |
||
| 11 | try: |
||
| 12 | if len(item) == 0: |
||
| 13 | return True |
||
| 14 | |||
| 15 | if mismatch_description: |
||
| 16 | mismatch_description \ |
||
| 17 | .append_text('has %d item(s)' % len(item)) |
||
| 18 | |||
| 19 | except TypeError: |
||
| 20 | if mismatch_description: |
||
| 21 | mismatch_description \ |
||
| 22 | .append_text('does not support length') |
||
| 23 | |||
| 24 | return False |
||
| 25 | |||
| 26 | def describe_to(self, description): |
||
| 27 | description.append_text('an empty collection') |
||
| 28 | |||
| 36 |