<s> import sys <EOL> import unittest <EOL> from test import test_support <EOL> class Empty : <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' <EOL> class Coerce : <EOL> def __init__ ( self , arg ) : <EOL> self . arg = arg <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % self . arg <EOL> def __coerce__ ( self , other ) : <EOL> if isinstance ( other , Coerce ) : <EOL> return self . arg , other . arg <EOL> else : <EOL> return self . arg , other <EOL> class Cmp : <EOL> def __init__ ( self , arg ) : <EOL> self . arg = arg <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % self . arg <EOL> def __cmp__ ( self , other ) : <EOL> return cmp ( self . arg , other ) <EOL> class ComparisonTest ( unittest . TestCase ) : <EOL> set1 = [ <NUM_LIT:2> , <NUM_LIT> , <NUM_LIT:2> L , <NUM_LIT:2> + <NUM_LIT> , Coerce ( <NUM_LIT:2> ) , Cmp ( <NUM_LIT> ) ] <EOL> set2 = [ [ <NUM_LIT:1> ] , ( <NUM_LIT:3> , ) , None , Empty ( ) ] <EOL> candidates = set1 + set2 <EOL> def test_comparisons ( self ) : <EOL> for a in self . candidates : <EOL> for b in self . candidates : <EOL> if ( ( a in self . set1 ) and ( b in self . set1 ) ) or a is b : <EOL> self . assertEqual ( a , b ) <EOL> else : <EOL> self . assertNotEqual ( a , b ) <EOL> def test_id_comparisons ( self ) : <EOL> L = [ ] <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> L . insert ( len ( L ) // <NUM_LIT:2> , Empty ( ) ) <EOL> for a in L : <EOL> for b in L : <EOL> self . assertEqual ( cmp ( a , b ) , cmp ( id ( a ) , id ( b ) ) , <EOL> '<STR_LIT>' % ( a , b ) ) <EOL> def test_main ( ) : <EOL> test_support . run_unittest ( ComparisonTest ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> test_main ( ) </s>
