python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_compare.cpython-312.pyc

͑eEdZddlZddlmZddlmZddlmZGddejZ	Gdd	ejZ
ed
k(rejyy)z$Test equality and order comparisons.N)	ALWAYS_EQ)Fraction)DecimalceZdZdZGddZGddZddddedgZd	gd
degZeezZdZ	d
Z
dZdZdZ
dZdZy)ComparisonSimpleTestz:Test equality and order comparisons for some simple cases.ceZdZdZy)ComparisonSimpleTest.Emptycy)Nz<Empty>selfs E/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_compare.py__repr__z#ComparisonSimpleTest.Empty.__repr__sN)__name__
__module____qualname__rrrrEmptyr	s	rrceZdZdZdZdZy)ComparisonSimpleTest.Cmpc||_yNarg)r
rs  r__init__z!ComparisonSimpleTest.Cmp.__init__s	DHrc d|jzS)Nz<Cmp %s>rrs rrz!ComparisonSimpleTest.Cmp.__repr__s((rc |j|k(Srrr
others  r__eq__zComparisonSimpleTest.Cmp.__eq__s88u$$rN)rrrrrr rrrCmprs		)	%rr!g@y@)Nc|jD]X}|jD]G}||jvr||jvs||ur|j||6|j||IZyr)
candidatesset1assertEqualassertNotEqualr
abs   rtest_comparisonsz%ComparisonSimpleTest.test_comparisonssc	.A__
.$))^!tyy.a1f$$Q*''1-	
.	.rc
g}tdD].}|jt|dz|j0|D]'}|D] }|j	||k(||ud|d|")y)N
r"za=z, b=)rangeinsertlenrr()r
Lir+r,s     rtest_id_comparisonsz(ComparisonSimpleTest.test_id_comparisons%swr	.A
HHSVQY

-	.	HA
H  aaA1FG
H	Hrc|jd}|jd}|jd}|j||k(d|j||k7d|j||k7dy)Nr#r"TF)r!assertIs)r
r+r,cs    rtest_ne_defaults_to_not_eqz/ComparisonSimpleTest.test_ne_defaults_to_not_eq.s_HHQKHHQKHHQK

a1fd#

a1fe$

a1fd#rcgGfdd}Gfdd}||k7|jddgy)z;object.__ne__() should allow reflected __ne__() to be triedceZdZfdZy)8ComparisonSimpleTest.test_ne_high_priority.<locals>.Leftc2jdtS)NLeft.__eq__appendNotImplementedargscallss rr z?ComparisonSimpleTest.test_ne_high_priority.<locals>.Left.__eq__;]+%%rNrrrr rDsrLeftr<9
&rrHc"eZdZfdZfdZy)9ComparisonSimpleTest.test_ne_high_priority.<locals>.Rightc2jdtS)NzRight.__eq__r?rBs rr z@ComparisonSimpleTest.test_ne_high_priority.<locals>.Right.__eq__?^,%%rc2jdtS)NRight.__ne__r?rBs r__ne__z@ComparisonSimpleTest.test_ne_high_priority.<locals>.Right.__ne__BrMrNrrrr rPrGsrRightrK>

&
&rrRr>rONassertSequenceEqual)r
rHrRrDs   @rtest_ne_high_priorityz*ComparisonSimpleTest.test_ne_high_priority6s?	&	&
	&	&	
%'  (GHrcgGfdd}Gfdd|}||k7|jddgy)z4object.__ne__() should not invoke reflected __eq__()ceZdZfdZy)7ComparisonSimpleTest.test_ne_low_priority.<locals>.Basec2jdtS)NBase.__eq__r?rBs rr z>ComparisonSimpleTest.test_ne_low_priority.<locals>.Base.__eq__MrErNrFrGsrBaserYKrIrr\c"eZdZfdZfdZy):ComparisonSimpleTest.test_ne_low_priority.<locals>.Derivedc2jdtS)NzDerived.__eq__r?rBs rr zAComparisonSimpleTest.test_ne_low_priority.<locals>.Derived.__eq__Q-.%%rc2jdtS)NDerived.__ne__r?rBs rrPzAComparisonSimpleTest.test_ne_low_priority.<locals>.Derived.__ne__Tr`rNrQrGsrDerivedr^PrSrrcrbr[NrT)r
r\rcrDs   @rtest_ne_low_priorityz)ComparisonSimpleTest.test_ne_low_priorityHsB	&	&
	&d	&	
')  )9=(IJrc	ddfddfddfddfd	d
ff}|D]\}}j|5fdGfdd
}|D]\}}||k7st|||dk(r'j||tdn%j	t
||tdddy#1swYxYw)z8No default delegation between operations except __ne__()r c||k(Srrr+r,s  r<lambda>z<ComparisonSimpleTest.test_other_delegation.<locals>.<lambda>]
AFr__lt__c||kSrrrgs  rrhz<ComparisonSimpleTest.test_other_delegation.<locals>.<lambda>^
AEr__le__c||kSrrrgs  rrhz<ComparisonSimpleTest.test_other_delegation.<locals>.<lambda>_rir__gt__c||kDSrrrgs  rrhz<ComparisonSimpleTest.test_other_delegation.<locals>.<lambda>`rlr__ge__c||k\Srrrgs  rrhz<ComparisonSimpleTest.test_other_delegation.<locals>.<lambda>arirc(jdy)Nz!Unexpected operator method called)fail)rCr
s r
unexpectedz>ComparisonSimpleTest.test_other_delegation.<locals>.unexpectedesIIABrceZdZWZy)5ComparisonSimpleTest.test_other_delegation.<locals>.CN)rrrrP)rusrCrwgs'FrrxFN)subTestsetattrr7objectassertRaises	TypeError)r
opsnamefuncrxr_rus`      @rtest_other_delegationz*ComparisonSimpleTest.test_other_delegationZs*+
)*
*+
)*
*+
	FJD$d#
FC(( #6HE1}5*568#MM$qsFH"5u=%%iqsFHE
F
F	F
F
FsB=A B==C	cd}|j|t|jt|t}|j|t|jt|y)Ncyrrrrrrhz6ComparisonSimpleTest.test_issue_1393.<locals>.<lambda>rsr)r(rr{)r
xys   rtest_issue_1393z$ComparisonSimpleTest.test_issue_1393qsNI&A&HI&A&r)rrr__doc__rr!r'set2r&r-r5r9rVrdrrrrrrrsqD%%
sAtSX&D
CtUW%DJ.H$I$K$F.'rrc
eZdZdZGddZGddeZGddeZGdd	eZGd
deZGdd
eZ	GddeZ
GddeZGddeZGddeZ
GddeZeeeee	e
eee
ef
ZdZdZd+dZdZdZdZdZd Zd!Zd"Zd#Zd$Zd%Zd&Zd'Zd(Zd)Z d*Z!y),ComparisonFullTestzTest equality and ordering comparisons for built-in types and
    user-defined classes that implement relevant combinations of rich
    comparison methods.
    ceZdZdZy)ComparisonFullTest.CompBaseaBase class for classes with rich comparison methods.

        The "x" attribute should be set to an underlying value to compare.

        Derived classes have a "meth" tuple attribute listing names of
        comparison methods implemented. See assert_total_order().
        N)rrrrrrrCompBasers	rrceZdZdZy)ComparisonFullTest.CompNonerN)rrrmethrrrCompNonersrrceZdZdZdZy)ComparisonFullTest.CompEq)eqc4|j|jk(Srrrs  rr z ComparisonFullTest.CompEq.__eq__66UWW$$rN)rrrrr rrrCompEqr	%rrceZdZdZdZy)ComparisonFullTest.CompNe)nec4|j|jk7Srrrs  rrPz ComparisonFullTest.CompNe.__ne__rrN)rrrrrPrrrCompNerrrrceZdZdZdZdZy)ComparisonFullTest.CompEqNe)rrc4|j|jk(Srrrs  rr z"ComparisonFullTest.CompEqNe.__eq__rrc4|j|jk7Srrrs  rrPz"ComparisonFullTest.CompEqNe.__ne__rrN)rrrrr rPrrrCompEqNer	%	%rrceZdZdZdZy)ComparisonFullTest.CompLt)ltc4|j|jkSrrrs  rrjz ComparisonFullTest.CompLt.__lt__66EGG##rN)rrrrrjrrrCompLtr	$rrceZdZdZdZy)ComparisonFullTest.CompGt)gtc4|j|jkDSrrrs  rroz ComparisonFullTest.CompGt.__gt__rrN)rrrrrorrrCompGtrrrrceZdZdZdZdZy)ComparisonFullTest.CompLtGt)rrc4|j|jkSrrrs  rrjz"ComparisonFullTest.CompLtGt.__lt__rrc4|j|jkDSrrrs  rroz"ComparisonFullTest.CompLtGt.__gt__rrN)rrrrrjrorrrCompLtGtrs	$	$rrceZdZdZdZy)ComparisonFullTest.CompLe)lec4|j|jkSrrrs  rrmz ComparisonFullTest.CompLe.__le__rrN)rrrrrmrrrCompLerrrrceZdZdZdZy)ComparisonFullTest.CompGe)gec4|j|jk\Srrrs  rrqz ComparisonFullTest.CompGe.__ge__rrN)rrrrrqrrrCompGerrrrceZdZdZdZdZy)ComparisonFullTest.CompLeGe)rrc4|j|jkSrrrs  rrmz"ComparisonFullTest.CompLeGe.__le__rrc4|j|jk\Srrrs  rrqz"ComparisonFullTest.CompLeGe.__ge__rrN)rrrrrmrqrrrCompLeGerrrrctt|Dcgc]	}|}}|jtt	||D]\}}||_|Scc}w)aCreate objects of type `class_` and return them in a list.

        `values` is a list of values that determines the value of data
        attribute `x` of each object.

        Objects in the returned list are sorted by their identity.  They
        assigned values in `values` list order.  By assign decreasing
        values to objects with increasing identities, testcases can assert
        that order comparison is performed by value and not by identity.
        )key)r0r2sortidzipr)r
class_values__	instancesinstvalues       rcreate_sorted_instancesz*ComparisonFullTest.create_sorted_instancess\).c&k(:;"VX;	;2y&1	KD%DF	<sAc|j||k(||j||k(||j||k7||j||k7||jtd5||kddd|jtd5||kddd|jtd5||kDddd|jtd5||k\ddd|jtd5||kddd|jtd5||kddd|jtd5||kDddd|jtd5||k\dddy#1swYxYw#1swYxYw#1swYxYw#1swYxYw#1swYxYw#1swYxYw#1swYwxYw#1swYyxYw)zAssert equality result and that ordering is not implemented.

        a, b: Instances to be tested (of same or different type).
        equal: Boolean indicating the expected equality comparison results.
        
not supportedNr(assertRaisesRegexr})r
r+r,equals    rassert_equality_onlyz'ComparisonFullTest.assert_equality_onlys	
a'a'aU+aU+

#
#I
?	
E	

#
#I
?	
F	

#
#I
?	
E	

#
#I
?	
F	

#
#I
?	
E	

#
#I
?	
F	

#
#I
?	
E	

#
#I
?	
F																		s`-E8F5FF=F)!F5G)G
8FFFF&)F25F>G

GNc|j||||||j||||||j||||||j||||||j	||||||j|||||y)aFTest total ordering comparison of two instances.

        a, b: Instances to be tested (of same or different type).

        comp: -1, 0, or 1 indicates that the expected order comparison
           result for operations that are supported by the classes is
           a <, ==, or > b.

        a_meth, b_meth: Either None, indicating that all rich comparison
           methods are available, aa for builtins, or the tuple (subset)
           of "eq", "ne", "lt", "le", "gt", and "ge" that are available
           for the corresponding instance (of a user-defined class).
        N)assert_eq_subtestassert_ne_subtestassert_lt_subtestassert_le_subtestassert_gt_subtestassert_ge_subtestr
r+r,compa_methb_meths      rassert_total_orderz%ComparisonFullTest.assert_total_orders	
q!T66:q!T66:q!T66:q!T66:q!T66:q!T66:rc|d|vsd|vr1|j||k(|dk(|j||k(|dk(y|j||k(||u|j||k(||uy)Nrr)r(rs      rrz$ComparisonFullTest.assert_eq_subtestss>TV^tv~Q!VTQY/Q!VTQY/Q!VQ!V,Q!VQ!V,rc|ddhj||zs1|j||k7|dk7|j||k7|dk7y|j||k7||u|j||k7||uy)Nrrr)
isdisjointr(rs      rrz$ComparisonFullTest.assert_ne_subtests|>$!8!8&!IQ!VTQY/Q!VTQY/Q!VQaZ0Q!VQaZ0rc:|d|vsd|vr1|j||k|dk|j||kD|dky|jtd5||kddd|jtd5||kDdddy#1swY.xYw#1swYyxYw)Nrrrrrrs      rrz$ComparisonFullTest.assert_lt_subtest'>TV^tv~QUD1H-QUD1H-''	?C
A
''	?C
A





B6BBBc:|d|vsd|vr1|j||k|dk|j||k\|dky|jtd5||kddd|jtd5||k\dddy#1swY.xYw#1swYyxYw)Nrrrrrrs      rrz$ComparisonFullTest.assert_le_subtest1>TV^tv~Q!VTQY/Q!VTQY/''	?C
Q
''	?C
Q





rc:|d|vsd|vr1|j||kD|dkD|j||k|dkDy|jtd5||kDddd|jtd5||kdddy#1swY.xYw#1swYyxYw)Nrrrrrrs      rrz$ComparisonFullTest.assert_gt_subtest;rrc:|d|vsd|vr1|j||k\|dk\|j||k|dk\y|jtd5||k\ddd|jtd5||kdddy#1swY.xYw#1swYyxYw)Nrrrrrrs      rrz$ComparisonFullTest.assert_ge_subtestErrcxt}t}|j||d|j||dy)z#Compare instances of type 'object'.TFN)r{rr*s   rtest_objectszComparisonFullTest.test_objectsOs4HH!!!Q-!!!Q.rc	|jD]}|j|5|j|d}|j|d|dd|j|j|j|d|dd|j|j|j|d|dd|j|j|j|d|dd|j|jdddy#1swYxYw)z5Compare same-class instances with comparison methods.)r#r"r#rr"r#N)all_comp_classesryrrr)r
clsrs   rtest_comp_classes_samez)ComparisonFullTest.test_comp_classes_sameVs((	<Cc"
< 88iH	''	!ilA(+#((<''	!ilA(+#((<''	!ilB(+#((<''	!ilB(+#((<%
<
<	<
<
<sCC;;D	c
|jD]}|jD]}|j||5|}d|_|}d|_|}d|_|j||d|j|j|j||d|j|jdddy#1swYxYw)z:Compare different-class instances with comparison methods.rgr#r"rrN)rryrrr)r
cls_acls_ba1b1b2s      rtest_comp_classes_differentz.ComparisonFullTest.test_comp_classes_differentos**
	<E..
<\\EU\3<BBDBBDBBD++B5::uzz;++BEJJ

<<<
<
	<<<sA=B<<CcGddt}td}td}|d}|d}|d}|j||d|j||d|j||d|j||d|j||d|j||d|j||d|j||d|j||dy)z(Compare instances of str and a subclass.ceZdZy)9ComparisonFullTest.test_str_subclass.<locals>.StrSubclassN)rrrrrrStrSubclassrsrrr+r,rrN)strr)r
rs1s2c1c2c3s       rtest_str_subclassz$ComparisonFullTest.test_str_subclasss	#	X
X





B!,B+B!,B+B!,B+B!,B+B!,rcd}d}|j||d|j||dd}d}|j||d|j||dtdd}td	d}|j||d|j||dtd
}td}|j||d|j||dd}	d
}
|j|	|	d|j|	|
d||f||f||f||f||f||ffD]\}}|j||d||||fD]}|j||	dy)zCompare number types.iirrgH@gH@ir"iz1001.0z1001.1yH@yH@?TFN)rrrr)
r
i1i2f1f2q1q2d1d2rrn1n2s
             rtest_numberszComparisonFullTest.test_numberssx
B*B+

B*B+
dA

dA
B*B+
X

X
B*B+

!!"b$/!!"b%02wB"R2b'Br7RGL	/FB##BA.	/r2r"	4B%%b"d3	4rcddg}ddg}|j||d|j||dd}d}|j||d|j||dtdd}tdd}|j||d|j||d	|j||d	|j||d	|j||d	y
)zCompare list, tuple, and range.r#r"r$rrr#r"r"r$TFN)rr0r)r
l1l2t1t2r1r2s       rtest_sequencesz!ComparisonFullTest.test_sequencessVVB*B+

B*B+
1a[
1a[!!"b$/!!"b%0!!"b%0!!"b%0!!"b%0rchd}d}|j||d|j||dtd}td}|j||d|j||d|j||d|j||d|j||d|j||dy)zCompare bytes and bytearray.sa1sb2rrN)r	bytearray)r
bs1bs2ba1ba2s     r
test_byteszComparisonFullTest.test_bytessS!,S"-S1-S"-S!,S"-S!,S"-rcpddh}hd}|j||d|j||dt|}t|}|j||d|j||d|j||d|j||d|j||d|j||dy)zCompare set and frozenset.r#r">r#r"r$rrN)r	frozenset)r
rrr
rs     r	test_setszComparisonFullTest.test_setssV
B*B+
r]
r]B+B+B*B+B*B+rcddd}ddd}ddd}|j||d|j||d|j||dy	)
z Compare dict.
        r+r,rr8r)r$r"TFN)r)r
rrd3s    r
test_mappingsz ComparisonFullTest.test_mappingssX


!!"b$/!!"b%0!!"b$/r)NN)"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr#r&r)rrrrrzs
8%%
%%
%8%$$
$$
$8$%%
%%
%8%
FHFHFH	&&6;8-1/<2<$-,"4H1*.","0rr__main__)
runittesttest.supportr	fractionsrdecimalrTestCaserrrmainrrr<module>r1sX*"o'8,,o'd@0**@0FzHMMOr