bg vUddlmZddlmZddlmZddlmZddl m Z m Z ddl mZddlmZddlmZmZmZmZmZmZmZmZmZmZmZmZdd lmZdd lZdd l m!Z!m"Z"dd l#m$Z$dd l%m&Z&ddl'm(Z(m)Z)ddl*m+Z,e-e.e/e0e1e2d fZ3dcde-de-de-de-fdZ4dddZ5dedee-deee-effdZ6dddee-dee-fdZ7 dfdddee-dee-fdZ8de9de9dddee-fd Z:ddde-fd!Z; dgdededdd#ede1de1dddee-fd&Z?de@de@dddee-fd'ZAed(ZBd)eeBdeeBfd*ZC dhdededdd,ed#e-d-e-d.ee)jUeOe,jUeOeVe:e ePiZWeSeJd;<dZXd?ZYe-e.e@fZZGd@dAZ[GdBde\Z]dCZ^e"dDZ_e_e_e_e_d d d d d"d"dEdEd dF dededGedHed#e-dIe-de-de-dJe,s Avvaa V  Awwd1gg%%(Aw777$Q''G$Q''GEOw('7A)6??   &3&&(>3(>(> }}S&))F2W]]35O5OOO#vr,ignorereturnc t|}t|tr |j|d<n#t $rd}YnwxYwt |dttu}|rxt}t|j D]&}| t |dd'|r|i}|D]&}t ||t}|tur|||<'|dS||D]}| |d|S)Nargs __slots__) varscopy isinstance BaseExceptionrB TypeErrorgetattrrsetr4__mro__updatepop) objr?attrs has_slotsslotsclsnvalueattrs r*r6r6DsE%S    c= ) ) %HE&M  [)44IEI !99$ 8 8C LLk266 7 7 7 7  U]E ! !ACI..EI%% a }t  " "D IIdD ! ! ! ! Ls!A AAignore_attributesc|dd}t|tr#|t |d}t |}|||S)NrWrD) get_optionrGdictgetr4rKrM)r-rWrOr?s r*_attrs_to_ignorer\bsh   3R 8 8F&$+DIIr** [[F MM#$$$ Mr,rDc~t|t|ust|trt|||St|t |||}t|t |||}|||r|st|||S|js||krt ||||ddSdS)a Compare the two supplied objects based on their type and attributes. :param ignore_attributes: Either a sequence of strings containing attribute names to be ignored when comparing or a mapping of type to sequence of strings containing attribute names to be ignored when comparing that type. This may be specified as either a parameter to this function or in the ``context``. If specified in both, they will both apply with precedence given to whatever is specified is specified as a parameter. If specified as a parameter to this function, it may only be a list of strings. Nr0r1)r4rGr>r6r\ ignore_eqr7)rr r-rWr;r<s r*compare_objectr_ms$ Awwd1ggAt!4!4aG,,,Q 0:KQ O OPPGQ 0:KQ O OPPG'/'/g/aG,,,6Gw..'1 -u66 6/.r,cf|j|jkrt|||St|||S)z^ Compare the two supplied exceptions based on their message, type and attributes. )rBr>r_rr r-s r*compare_exceptionrbs7 vaG,,, !Q ( ((r,c pt|tur0t|jt|ur |j|krdSt}i}dD]Q}||}||dt |t|||<Rdjdi|S)zy Return a textual description of the difference between two objects including information about their types. r)rr z {0} ({1!r})z {x} != {y}rD)r4 AlreadySeenrOlocalsr8format _short_repr)rr r-source to_rendernamerOs r*r5r5s  Aww+$qu++a"8"8QUaZZr XXFI  Tl!--   S!1!1499 = =  $ <  + + + ++r,Tprefixc t|}t|}d}||kr>||kr8|||||d|zrn|dz }||kr||k8||kr||krdS|rdnddzt|d||jpdt||d|jpd t||dfzS) zb Returns a textual description of the differences between the two supplied sequences. rz[%i]Nzsequence not as expected: rzsame: %s %s: %s %s: %sr%r&)len differentr r!r")rr r-rkl_xl_yis r*compare_sequencerss a&&C a&&C A c''a#gg   QqT1Q4! 4 4   Q c''a#gg  czza3hh06 > , ,B  "!BQB%..!/4Wgaenn!/5Xwqu~~ r,c~t|}t|}|js||krdSt|||S)z Returns a textual description of the differences between the two supplied generators. This is done by first unwinding each of the generators supplied into tuples and then passing those tuples to :func:`compare_sequence`. N)tupler^rsras r*compare_generatorrvsD aA aA  a Aq' * **r,c .t|dd}t|dd}|ra|r_||krHttt||tt||||St |||St |||S)z Returns a textual difference between two tuples or :func:`collections.namedtuple` instances. The presence of a ``_fields`` attribute on a tuple is used to decide whether or not it is a :func:`~collections.namedtuple`. _fieldsN)rJr7rZzipr5rs)rr r-x_fieldsy_fieldss r* compare_tupler|sq)T**Hq)T**H4H4 x  #DXq)9)9$:$:$(Xq)9)9$:$:$+$%'' ' %Q733 3 Aq' * **r,c&t||||S)ze Returns a textual description of the differences between the two supplied dictionaries. )r7ras r* compare_dictr~s Aq'1 - --r,Itemsequencec&t|dS)Nc t|SN)r3)os r*z sorted_by_repr..s $q''r,)key)sorted)rs r*sorted_by_reprrs ( 1 1 2 2 22r,[%r] obj_for_class breadcrumb check_y_not_xcVt|}t|}||z } ||z } g} g} t||D]} ||| || || fzrl| | d|dt|| d|dt|| | | | s|r| s| sdS|turg}nd|j j zg}| rI t| } n#t$rYnwxYw| dd|zt| f|jpd}|jpd }| r_| d|d |d |d ft| D]/} || dt|| 0| r_| d|d |d |d ft| D]/} || dt|| 0| r1| dd |pdzf| | d|S)N: rr2r %s not as expected:rz%ssame:r%r&in but not :z %sdiffer:zvalues r$)rKkeysr intersectionroappendr8r r __class____name__rrIextendr3r!r"r()rr r-rrkrrx_keysy_keysx_not_yy_not_xsamediffsrlinesr!r"s r*r7r7s ]]F ]]FvoGvoG D Ef11&99::   QsVQsVZ3'-A B B  LL c71S6??3333 c71S6??333     KK      'e !!&)@)IIJ ; $<??? U 99U  sE E$#E$c||z }||z }|s|sdSd|jjzdg}|jpd}|jpd}|r9|d|d|dt t |df|r9|d|d|dt t |dfd |d zS) z] Returns a textual description of the differences between the two supplied sets. Nrrr%r&rrrr$)rrr!r"rr rr()rr r-rrrr!r"s r* compare_setr5s !eG!eG w "Q[%9 92 >Eo(Go)G #*77GGG 4 N7++ , ,      #*77GGG 4 N7++ , ,     99U  D  r,z\s+$trailing_whitespace_retextcg}|dD]-}|r)|s||.d|S)Nr$)r)isspacerr()rresultlines r*strip_blank_linesrSs^ F 4        MM$    99V  r,c|d}t|ddD]\}}t|dz||<t|d|d<d|S)Nr$)r) enumerater3r()rpartsrrparts r* split_reprr[sr JJt  EU3B3Z((%%4t $$aU2YE"I 99U  r,c|dd}|dd}|dd}|s6td|}td|}|st|}t|}||krdS|dt |}|d t |}t |d kst |d krQd |vsd |vr@|rt|}t|}d t|||j |j z}nd |d |}n|d z|z}|S)a Returns an informative string describing the differences between the two supplied strings. The way in which this comparison is performed can be controlled using the following parameters: :param blanklines: If `False`, then when comparing multi-line strings, any blank lines in either argument will be ignored. :param trailing_whitespace: If `False`, then when comparing multi-line strings, trailing whilespace on lines will be ignored. :param show_whitespace: If `True`, then whitespace characters in multi-line strings will be replaced with their representations. blanklinesTtrailing_whitespaceshow_whitespaceFrNrr r$ != r2) rYrsubrr8r3rnrr+r!r") rr r-rrr labelled_x labelled_ymessages r* compare_textrcsq$##L$77J!,,-BDII(():EBBO . " & &r1 - - " & &r1 - - ! a  a AvvsDGG,,JsDGG,,J 1vv{{c!ffrkk 199  "qMMqMMT!QIIIGG " )3 JJ?GGV#J. Nr,c||krdS|dt|}|dt|}d|d|S)Nrr r$r)r8r3)rr r-rrs r* compare_bytesrsUAvvsDGG,,JsDGG,,JJ'ZZ 44r,c||krdSd}||\}}}||\}}} ||krC||kr=|| kr7tt|tt|t|St|t|kr+t t|t||S|||dp-|||dp||| d} | sdSdS)NcJ |\}}}n#t$r d}|\}}YnwxYw|||fSr) ValueError)rrjrBkwargss r*extractzcompare_call..extractsQ !% D$   DLD&&& T6!!s  z function namez argsz kwzmock.call not as expected:) compare_callrJrr3rro) rr r-rx_namex_argsx_kwy_namey_argsy_kwros r*rrs'Avv"""#71::FFD"71::FFD Ff,,GA{33WQ 5L5LgVVV Aww$q''DGGT!WWg666 &&*:;; -&&'22 -$e,,  ' 'r,ct|j|j|j}t|j|j|j}||krt ||||ddSdS)N)funcrBkeywordsr0r1)rZrrBrr7)rr r-r;r<s r*compare_partialrshQVajAAAGQVajAAAG''1 -u66 6r,cdt|}t|dkr |dddz}|S)Nz...)r3rn)rOrepr_s r*rgrgs3 IIE 5zzBcrc U" Lr, _registrytype_comparerc|t|<dS)z Register the supplied comparer for the specified type. This registration is global and will be in effect from the point this function is called until the end of the current process. N)r)rrs r*registerrs  Ier,c#Ktt|j}t|jD] }||vr|V dSr)rKr4rL)rr y_mroclass_s r* _shared_mrorsO Q Eq''/ U??LLLr,c eZdZdZdZdZdS)rdc0||_||_||_dSr)idrOr)selfid_rOrs r*__init__zAlreadySeen.__init__s$r,c8d|jd|jd|jdS)Nz)rOrrrs r*__repr__zAlreadySeen.__repr__s)W48WW4?WWTWWWWWr,cbt|tr|j|jkS|j|kSr)rGrdrrOrothers r*__eq__zAlreadySeen.__eq__s1 e[ ) ) %?e&66 68u$ $r,N)r __module__ __qualname__rrrrDr,r*rdrdsD%%% XXX%%%%%r,rdceZdZdZ ddeedeededed ed ed eee ffd Z d e de de de de de f dZ ddefdZdede defdZde de defdZdefdZdZde de dedeeeeffdZdS) r.zt Stores the context of the current comparison in process during a call to :func:`testfixtures.compare`. TFNr!r" recursivestrictr^ comparersoptionsc g|_|r|j||jt||_||_||_||_||_|pi|_d|_ g|_ i|_ dS)Nr) registriesrrr!r"rrr^rr breadcrumbs_seen)rr!r"rrr^rrs r*rzCompareContext.__init__s  . O " "9 - - - y)))  (" ('.}"  &( r,rBrr expectedactualr@c\gfd}|||||||||tdkrOd}r|dz }|jr|d|jz }t |S)NcH|tur|dSdSr) unspecifiedr)rhpossibles r*append_if_specifiedz8CompareContext.extract_args..append_if_specified#s.[((''''')(r,z)Exactly two objects needed, you supplied:z {})rrnrfrrI) rrBrr rrrrrs @r* extract_argszCompareContext.extract_argss ( ( ( ( ( H%%%F###AA x==A  AG 25<<111| 65<< 555G$$ $r,rjc8|j||Sr)rr[)rrjdefaults r*rYzCompareContext.get_option7s|g...r,siderUcdt|}t||dz}|r |d|zdzz }|S)N_labelz ())strrJ)rrrUrr8s r*r8zCompareContext.label:s? JJd8m,,  eC Ar,c|jr%t|t|urtSt||D])}|jD]}||}|r|ccS *t |trFt |tr1t |tst |tstSt |tst |trtStSr) rr4r5rrr[rG IterableABC_unsafe_iterablesrv Comparisonr>r_)rrr rregistryrs r*_lookupzCompareContext._lookupAs ; %477$q''11$ $!!Q'' $ $F O $ $#<<//$#OOOOO$ $ ; ' ' %Jq+,F,F % , - - % , - - %% $ a $ $ " 1j(A(A "! !r,cLdd|jddzS)Nz While comparing %s: rrm)r(rrs r* _separatorzCompareContext._separatorWs%)BGGD4DQRR4H,I,IIIr,ct|tr|St|}|j|}|t |||S||j|<|Sr)rGIMMUTABLE_TYPEsrrr[rd)rrOrr breadcrumb_s r* _break_loopszCompareContext._break_loopsZs_ c? + + JggjnnS))  "sC55 5(DJsOJr,rc|||}|||}t|j}|j||j}d|_d} t |t us|jsE|js> ||kr& ||z|_|j dSn#t$rYnwxYw| ||}||||}|tu} |r2| r|r| }| s|s||z }|jr ||jz }|||z|_|j S#||z|_|j wxYw)NrF)r boolrrrr4rdrr^rNRecursionErrorrr>r r) rrr rrecursedexisting_messagecurrent_messagerrspecific_comparers r*rozCompareContext.differentgs   a , ,   a , ,())  +++<  #Aww+%%dk%T^%Avv$.,o=DL   " " " " "3%D"&a!3!3HXaD))F ( >  8$88&*oo&7&7O$8H8#v-O~8'4<7,o=DL   " " " ",o=DL   " " " "s1,$EB>=E> C E C  A$E%E8)TFFNNr)rrr__doc__r rrRegistryr r rrurrrYr8Comparerrr r rrorDr,r*r.r.s# #"&&*c]c]      #s(^233#sW[0//s////#cc,JCJJJJ   '#3'#3'#C'#E$QT BU` for details of these. TrrrNrr$)rr.rrorrAssertionError)rr rrrkrr!r"rrrr^rrBr__tracebackhide__r-rs r*comparer sX  # #+(=(='Z%XWgy&)YX_``G   aHf = =DAq   Q2 & &oG 9''$.8 04-//// &W%%% Nr,cteZdZUdZdZeed<dZeed<dZ e eed<dZ d efd Z d efd Z d efd ZdS) StatefulComparisonz7 A base class for stateful comparison objects. rfailedNrrD name_attrsc||k SrrDrs r*rzStatefulComparison.__eq__s5=!!r,r@ctj}jr,|ddfdjDzz }|S)Nz(%s), c3BK|]}|dt|VdS)=N)rJ).0rTrs r* z*StatefulComparison.name.. s9&`&`1!!!WT15E5E5E'F&`&`&`&`&`&`r,)r4rr$r()rrjs` r*rjzStatefulComparison.namesUDzz" ? a FTYY&`&`&`&`PTP_&`&`&```` `D r,c:t|jddS)Nrmr)r rrs r*bodyzStatefulComparison.body st}%%ad++r,c|}|jp|}d||jrdpdd}d|vr'd|zdz|dzdzd|zzS|r||zdzS|S)Nz)rjr#r-strip)rrjr-rks r*rzStatefulComparison.__repr__syy{{{)diikk!T4;#=:#C#C#CD 4<<;t#DJJt$4$44T9'D.H H  )D=5( ( r,)rrrrr#r__annotations__rr r$rrrjr-rrDr,r*r"r"sFCHc "J """"""c ,c,,,,#r,r"cdeZdZdZ d deeefdedefdZded efd Z d efd Z d efd Z dS)ra These are used when you need to compare an object's type, a subset of its attributes or make equality checks with objects that do not natively support comparison. :param object_or_type: The object or class from which to create the :class:`Comparison`. :param attribute_dict: An optional dictionary containing attributes to place on the :class:`Comparison`. :param partial: If true, only the specified attributes will be checked and any extra attributes of the object being compared with will be ignored. :param attributes: Any other keyword parameters passed will placed as attributes on the :class:`Comparison`. NFattribute_dictr attributesc R||_|r||}n||t|tr0t |j}|t urtd|zn0t|tr|}n|j }|t|}||_ ||_ dS)Nz%r could not be resolved) rrMrGrrfoundrAttributeErrorr4rr6 expected_typeexpected_attributes)robject_or_typer3rr4cs r*rzComparison.__init__.s   2%!+%%j111 nc * * @''-AI~~$.? - - @AA(A%!/!?!?#1   r,rr@c |j|jur d|_dS|jdSt |j}|jri}n!t|}|t |z}|D]&} t||||<#t$rY#wxYwtdd}t|j||tdd|j |_t|jS) Nz wrong typeTFrr)r!r"r0r1)rrkrr)r8rr#r9rKrrr6rJr7r.r7rr)rrattribute_namesactual_attributesrjr-s r*__ne__zComparison.__ne__Hs#  U_ 4 4&DK4  # +5d6;;==>> < 6 "   .u 5 5  s#455 5O#  D *1%*>*>!$''!    !xHHH&t'?'8'.5>.;279=5E GGG DK   s7B  BBcd}t|jdd}|r||zdz}|t|jddpt|jz }|S)NzC:r.r)rJr8r3)rrjmodules r*rjzComparison.namegs_+\4@@  '&=3&D +Z>>Z$tGYBZBZ[ r,c|jrg}t|jD]A\}}t|}d|vrt |}||d|Bd|SdS)Nr$rr)r9ritemsr3rrr()rrkvrvs r*r-zComparison.bodyos  # $Et7==??@@ 1 11!WW2::B BB/000099U## #rr,)NF) rrrrr rr rrr?rjr-rDr,r*rrs*37!&22!%c3h22 # 22224!C!D!!!!>c c      r,rc@eZdZdZdZdddddededefd Zd efd Zd S) SequenceComparisonar An object that can be used in comparisons of expected and actual sequences. :param expected: The items expected to be in the sequence. :param ordered: If ``True``, then the items are expected to be in the order specified. If ``False``, they may be in any order. Defaults to ``True``. :param partial: If ``True``, then any keys not expected will be ignored. Defaults to ``False``. :param recursive: If a difference is found, recursively compare the item where the difference was found to highlight exactly what was different. Defaults to ``False``. orderedrTF)rKrrrKrrcd||_||_||_||_t |_dSr)rrKrrrKchecked_indices)rrKrrrs r*rzSequenceComparison.__init__s2!   ""uur,r@c  t|x}n#t$r d_YdSwxYwtj}t|}g}g}g}|}tt t |x}} g} g} d} t |D]\} } ||| }| |}| ||| | | |j |j r|} #t$r-| || | YwxYw|t|k}| p| }jo| }|sj s|s|rdS|| z}|} jrRjrFj r?|r=| |d|d|}d}n| |z } d}gfd}|d|j rx t#fdt|Dfdt| Djd d d d n$|d ||d | |d|d _dS)Nbad typeTrFc`|r*|dzt|zdSdS)Nz: )rr )rjcontentrs r* add_sectionz.SequenceComparison.__ne__..add_sections> <tEz''*:*::;;;;; < z-SequenceComparison.__ne__..s MMMq$-*MMMr,c g|] }| SrDrD)r*rroriginal_actuals r*rUz-SequenceComparison.__ne__..sKKKq*KKKr,rrrr rmrzin expected but not actualzin actual but not expected)listrIr#rrangernrindexrNrrMaddrKrrrrr r)r()rrrrmatchedmatched_expected_indicesmatched_actual_indicesmissing_from_expectedmissing_from_expected_indicesactual_indicesmissing_from_actualmissing_from_actual_indicesstarte_ierra_imatches_in_order all_matched partial_matchexpected_indicesrSrRrrWs` @@r*r?zSequenceComparison.__ne__s '+E{{ 2F__   $DK44  &&f#% !# &9=eCKK>P>P9Q9QQ% &(#))  FC LLE**$((++ 488;;<<<(//444&--c222$((---<E 8 8 8#**1---+22377777 82V4J4JKKK.  eFAq " # # # # K ( ( ( K46I J J J K46K L L Lkk'** ts,, +E4E87E8N)rrrrr$rrr?rDr,r*rIrI|s$(J.25\a%%%&*%<@%UY%%%%NtNNNNNNr,rIc&eZdZdZdZfdZxZS)Subsetzx A shortcut for :class:`SequenceComparison` that checks if the specified items are present in the sequence. rDcJtt|j|ddddS)NFTrJ)superrorrrrs r*rzSubset.__init__s-$fd$htLLLLLLr,)rrrrr$r __classcell__rs@r*rorosR JMMMMMMMMMr,roc"eZdZdZfdZxZS) Permutationz A shortcut for :class:`SequenceComparison` that checks if the set of items in the sequence is as expected, but without checking ordering. cJtt|j|ddddS)NFrJ)rqrvrrrs r*rzPermutation.__init__s-)k4  )8UERRRRRRr,)rrrrrrsrts@r*rvrvsK SSSSSSSSSr,rvc4eZdZdZdZdZdefdZdefdZ dS)MappingComparisona An object that can be used in comparisons of expected and actual mappings. :param expected_mapping: The mapping that should be matched expressed as either a sequence of ``(key, value)`` tuples or a mapping. :param expected_items: The items that should be matched. :param ordered: If ``True``, then the keys in the mapping are expected to be in the order specified. Defaults to ``False``. :param partial: If ``True``, then any keys not expected will be ignored. Defaults to ``False``. :param recursive: If a difference is found, recursively compare the value where the difference was found to highlight exactly what was different. Defaults to ``False``. rJc8|dd|_|dd|_|dd|_t |dkr t |}nt |}||||_dS)NrKFrrrm)rNrKrrrnrrMr)rexpected_mappingexpected_itemsrs r*rzMappingComparison.__init__s%)))U;; %)))U;; '++K??  A % %"$45HH"#344H'''  r,r@cg}d}|jD]N\}}t|dzt|z}|t |z }||O|dkrd}nd}||S)Nrr<z, r')rrDr3r rnrr()rr text_lengthrrUrseps r*r-zMappingComparison.body&s ---//  JC99T>'%..0D 3t99 $K LL       CCCxxr,c |}t|}n#t$r d|_YdSwxYw|j}|j}|jr6t|t|z D]}||= fd|D}nd t|||j d}|j r3tt|t||j d}nd}|s|rg} r2| dtt z|r/| |ddd|r2| d |dddzd| |_dSdS) NrOTcg|]}|v| SrDrD)r*rE ignored_keyss r*rUz,MappingComparison.__ne__..Ds#KKKQl5J5J15J5J5Jr,FrXz ignored: rYrmzwrong key order: )rrZrDr7r#rrrKr rrKrZrr rr)r() rr actual_keysactual_mapping expected_keysr{rmapping_differenceskey_differencesrrs @r*r?zMappingComparison.__ne__4s **,,K!%++--00NN   $DK44  **,, = < {++c-.@.@@L# ( ("3''KKKKkKKKKKL%%!n     < #%m,,K((. OO#O  1 G K|GF<4H4H,I,IIJJJ" H288CCAFGGG [5o6K6KFTU6V6VWX6YYZZZ ++g..DK4us59A AN) rrrrr$rrr-rr?rDr,r*ryrysj((J ! ! ! c    5t555555r,rycdeZdZdZd dededefdZdefdZdefd Z defd Z defd Z defd Z dS)StringComparisona, An object that can be used in comparisons of expected and actual strings where the string expected matches a pattern rather than a specific concrete string. :param regex_source: A string containing the source for a regular expression that will be used whenever this :class:`StringComparison` is compared with any :class:`str` instance. :param flags: Flags passed to :func:`re.compile`. :param flag_names: See the :ref:`examples `. N regex_sourceflags flag_namesc |g}g}|r|||d|D|r(|tt|t j||_dS)Nc3dK|]+}tt|V,dSr)rJreupper)r*fs r*r+z,StringComparison.__init__..s4AAgb!'')),,AAAAAAr,)rrrr rcompile)rrrrrBflags_s r*rzStringComparison.__init__{s~  ! MM%  AAjAAAAAA  0 KKvv.. / / /*d#r,r@clt|tsdS|j|rdSdS)NFT)rGrrmatchrs r*rzStringComparison.__eq__s9%%% 5 7==   4ur,c||k SrrDrs r*r?zStringComparison.__ne__5=  r,c d|jjzS)Nzrpatternrs r*rzStringComparison.__repr__s$'/))r,c"|jj|kSrrrs r*__lt__zStringComparison.__lt__w&&r,c"|jj|kSrrrs r*__gt__zStringComparison.__gt__rr,r) rrrrrintrrrr?rrrrDr,r*rrls   $ $S $ $3 $ $ $ $t!t!!!!*#****'t'''''t''''''r,rcFeZdZdZdedefdZdefdZdefdZ de fdZ d S) RoundComparisona An object that can be used in comparisons of expected and actual numerics to a specified precision. :param value: numeric to be compared. :param precision: Number of decimal places to round to in order to perform the comparison. rU precisionc>t|||_||_dSr)roundroundedr)rrUrs r*rzRoundComparison.__init__sUI.. "r,r@ct||j}t|jt|ur"t d|dt||j|kS)NzCannot compare z with )rrr4rrI)rr other_roundeds r*rzRoundComparison.__eq__s^eT^44   T-%8%8 8 8)444eMNN N|},,r,c||k SrrDrs r*r?zRoundComparison.__ne__rr,c$d|j|jfzS)Nz)rrrs r*rzRoundComparison.__repr__s$ dn'EEEr,N) rrrrfloatrrrrr?rrrDr,r*rrs#e#####-t---- !t!!!!F#FFFFFFr,rc<eZdZdZdZdefdZdefdZdefdZ dS)RangeComparisona An object that can be used in comparisons of orderable types to check that a value specified within the given range. :param lower_bound: the inclusive lower bound for the acceptable range. :param upper_bound: the inclusive upper bound for the acceptable range. c"||_||_dSr lower_bound upper_bound)rrrs r*rzRangeComparison.__init__s&&r,r@c6|j|cxko |jkncSrrrs r*rzRangeComparison.__eq__s*5<<<rrs r*rzRangeComparison.__repr__s!&*&6&6&68H8H8HIIr,N) rrrrrrrr?rrrDr,r*rrs'''=t====!t!!!!J#JJJJJJr,r)rr)r-r.r)rD)T)rrT)j collectionsrcollections.abcrrdecimalrdifflibr functoolsr partial_typeroperatorr pprintr typingr r r rrrrrrrrtypesrr testfixturesrrtestfixtures.resolvertestfixtures.utilsrtestfixtures.mockrr unittest.mockrunittest_mock_callrbytesrrrur4r r+r>r6r\r_ Exceptionrbr5rrsrvr|rZr~rrr7rKrr MULTILINErr1rrrrrrrgrrrZrrHrrrrrdobjectr.rrr r"rrIrorvryrrrrDr,r*rs #######333333 55555555  --------((((((%%%%%%44444444444444uc5%d;CC#S$PPPP0 $sCx.9Q<!6>sm c]MO66'6 ^$  ,$/ 8$ D H    $%%%%%%%%"N#N#N#N#N#VN#N#N#b999i && #!"___ _ _ _  _  __________ c]!____D@_____#___Dlllll+lll^ M M M M M  M M MSSSSS$SSShhhhh*hhhV,',',',',',',','^FFFFFFFF6JJJJJJJJJJr,