o (]^qã@sšddlmZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z dZd Zd ZGd d „d eeƒZd eee efde efdd„ZdS)é)ÚSized)ÚUnion)Ú BaseMatcher)Ú Description)Ú hasmethod)Ú wrap_matcher)ÚMatcherzJon ReidzCopyright 2011 hamcrest.orgzBSD, see License.txtcsdeZdZdeeddfdd„Zdedefdd„Zded e ddf‡fd d „ Z d e ddfd d„Z ‡Z S)Ú HasLengthÚ len_matcherÚreturnNcCs ||_dS)N)r )Úselfr ©r úC/usr/lib/python3/dist-packages/hamcrest/library/object/haslength.pyÚ__init__s zHasLength.__init__ÚitemcCst|dƒsdS|j t|ƒ¡S)NÚ__len__F)rr ÚmatchesÚlen)r rr r rÚ_matchess zHasLength._matchesÚmismatch_descriptioncs8tt|ƒ ||¡t|dƒr| d¡ t|ƒ¡dSdS)Nrz with length of )Úsuperr Údescribe_mismatchrÚ append_textÚappend_description_ofr)r rr©Ú __class__r rrs ÿzHasLength.describe_mismatchÚ descriptioncCs| d¡ |j¡dS)Nzan object with length of )rrr )r rr r rÚ describe_toszHasLength.describe_to) Ú__name__Ú __module__Ú __qualname__rÚintrrÚboolrrrrÚ __classcell__r r rrr s r Úmatchr cCs tt|ƒƒS)aMMatches if ``len(item)`` satisfies a given matcher. :param match: The matcher to satisfy, or an expected value for :py:func:`~hamcrest.core.core.isequal.equal_to` matching. This matcher invokes the :py:func:`len` function on the evaluated object to get its length, passing the result to a given matcher for evaluation. If the ``match`` argument is not a matcher, it is implicitly wrapped in an :py:func:`~hamcrest.core.core.isequal.equal_to` matcher to check for :equality. Examples:: has_length(greater_than(6)) has_length(5) )r r)r$r r rÚ has_length!s r%N)Úcollections.abcrÚtypingrÚhamcrest.core.base_matcherrÚhamcrest.core.descriptionrÚhamcrest.core.helpers.hasmethodrÚ"hamcrest.core.helpers.wrap_matcherrÚhamcrest.core.matcherrÚ __author__Ú __copyright__Ú __license__r r!r%r r r rÚs      &