<s> """<STR_LIT>""" <EOL> import functools <EOL> import unittest <EOL> import six <EOL> from acme import test_util <EOL> class ComparableX509Test ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . req1 = test_util . load_comparable_csr ( '<STR_LIT>' ) <EOL> self . req2 = test_util . load_comparable_csr ( '<STR_LIT>' ) <EOL> self . req_other = test_util . load_comparable_csr ( '<STR_LIT>' ) <EOL> self . cert1 = test_util . load_comparable_cert ( '<STR_LIT>' ) <EOL> self . cert2 = test_util . load_comparable_cert ( '<STR_LIT>' ) <EOL> self . cert_other = test_util . load_comparable_cert ( '<STR_LIT>' ) <EOL> def test_getattr_proxy ( self ) : <EOL> self . assertTrue ( self . cert1 . has_expired ( ) ) <EOL> def test_eq ( self ) : <EOL> self . assertEqual ( self . req1 , self . req2 ) <EOL> self . assertEqual ( self . cert1 , self . cert2 ) <EOL> def test_ne ( self ) : <EOL> self . assertNotEqual ( self . req1 , self . req_other ) <EOL> self . assertNotEqual ( self . cert1 , self . cert_other ) <EOL> def test_ne_wrong_types ( self ) : <EOL> self . assertNotEqual ( self . req1 , <NUM_LIT:5> ) <EOL> self . assertNotEqual ( self . cert1 , <NUM_LIT:5> ) <EOL> def test_hash ( self ) : <EOL> self . assertEqual ( hash ( self . req1 ) , hash ( self . req2 ) ) <EOL> self . assertNotEqual ( hash ( self . req1 ) , hash ( self . req_other ) ) <EOL> self . assertEqual ( hash ( self . cert1 ) , hash ( self . cert2 ) ) <EOL> self . assertNotEqual ( hash ( self . cert1 ) , hash ( self . cert_other ) ) <EOL> def test_repr ( self ) : <EOL> for x509 in self . req1 , self . cert1 : <EOL> self . assertEqual ( repr ( x509 ) , <EOL> '<STR_LIT>' . format ( x509 . wrapped ) ) <EOL> class ComparableRSAKeyTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . key = test_util . load_rsa_private_key ( '<STR_LIT>' ) <EOL> self . key_same = test_util . load_rsa_private_key ( '<STR_LIT>' ) <EOL> self . key2 = test_util . load_rsa_private_key ( '<STR_LIT>' ) <EOL> def test_getattr_proxy ( self ) : <EOL> self . assertEqual ( <NUM_LIT> , self . key . key_size ) <EOL> def test_eq ( self ) : <EOL> self . assertEqual ( self . key , self . key_same ) <EOL> def test_ne ( self ) : <EOL> self . assertNotEqual ( self . key , self . key2 ) <EOL> def test_ne_different_types ( self ) : <EOL> self . assertNotEqual ( self . key , <NUM_LIT:5> ) <EOL> def test_ne_not_wrapped ( self ) : <EOL> self . assertNotEqual ( self . key , self . key_same . _wrapped ) <EOL> def test_ne_no_serialization ( self ) : <EOL> from acme . jose . util import ComparableRSAKey <EOL> self . assertNotEqual ( ComparableRSAKey ( <NUM_LIT:5> ) , ComparableRSAKey ( <NUM_LIT:5> ) ) <EOL> def test_hash ( self ) : <EOL> self . assertTrue ( isinstance ( hash ( self . key ) , int ) ) <EOL> self . assertEqual ( hash ( self . key ) , hash ( self . key_same ) ) <EOL> self . assertNotEqual ( hash ( self . key ) , hash ( self . key2 ) ) <EOL> def test_repr ( self ) : <EOL> self . assertTrue ( repr ( self . key ) . startswith ( <EOL> '<STR_LIT>' ) ) <EOL> def test_public_key ( self ) : <EOL> from acme . jose . util import ComparableRSAKey <EOL> self . assertTrue ( isinstance ( self . key . public_key ( ) , ComparableRSAKey ) ) <EOL> class ImmutableMapTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> from acme . jose . util import ImmutableMap <EOL> class A ( ImmutableMap ) : <EOL> __slots__ = ( '<STR_LIT:x>' , '<STR_LIT:y>' ) <EOL> class B ( ImmutableMap ) : <EOL> __slots__ = ( '<STR_LIT:x>' , '<STR_LIT:y>' ) <EOL> self . A = A <EOL> self . B = B <EOL> self . a1 = self . A ( x = <NUM_LIT:1> , y = <NUM_LIT:2> ) <EOL> self . a1_swap = self . A ( y = <NUM_LIT:2> , x = <NUM_LIT:1> ) <EOL> self . a2 = self . A ( x = <NUM_LIT:3> , y = <NUM_LIT:4> ) <EOL> self . b = self . B ( x = <NUM_LIT:1> , y = <NUM_LIT:2> ) <EOL> def test_update ( self ) : <EOL> self . assertEqual ( self . A ( x = <NUM_LIT:2> , y = <NUM_LIT:2> ) , self . a1 . update ( x = <NUM_LIT:2> ) ) <EOL> self . assertEqual ( self . a2 , self . a1 . update ( x = <NUM_LIT:3> , y = <NUM_LIT:4> ) ) <EOL> def test_get_missing_item_raises_key_error ( self ) : <EOL> self . assertRaises ( KeyError , self . a1 . __getitem__ , '<STR_LIT:z>' ) <EOL> def test_order_of_args_does_not_matter ( self ) : <EOL> self . assertEqual ( self . a1 , self . a1_swap ) <EOL> def test_type_error_on_missing ( self ) : <EOL> self . assertRaises ( TypeError , self . A , x = <NUM_LIT:1> ) <EOL> self . assertRaises ( TypeError , self . A , y = <NUM_LIT:2> ) <EOL> def test_type_error_on_unrecognized ( self ) : <EOL> self . assertRaises ( TypeError , self . A , x = <NUM_LIT:1> , z = <NUM_LIT:2> ) <EOL> self . assertRaises ( TypeError , self . A , x = <NUM_LIT:1> , y = <NUM_LIT:2> , z = <NUM_LIT:3> ) <EOL> def test_get_attr ( self ) : <EOL> self . assertEqual ( <NUM_LIT:1> , self . a1 . x ) <EOL> self . assertEqual ( <NUM_LIT:2> , self . a1 . y ) <EOL> self . assertEqual ( <NUM_LIT:1> , self . a1_swap . x ) <EOL> self . assertEqual ( <NUM_LIT:2> , self . a1_swap . y ) <EOL> def test_set_attr_raises_attribute_error ( self ) : <EOL> self . assertRaises ( <EOL> AttributeError , functools . partial ( self . a1 . __setattr__ , '<STR_LIT:x>' ) , <NUM_LIT:10> ) <EOL> def test_equal ( self ) : <EOL> self . assertEqual ( self . a1 , self . a1 ) <EOL> self . assertEqual ( self . a2 , self . a2 ) <EOL> self . assertNotEqual ( self . a1 , self . a2 ) <EOL> def test_hash ( self ) : <EOL> self . assertEqual ( hash ( ( <NUM_LIT:1> , <NUM_LIT:2> ) ) , hash ( self . a1 ) ) <EOL> def test_unhashable ( self ) : <EOL> self . assertRaises ( TypeError , self . A ( x = <NUM_LIT:1> , y = { } ) . __hash__ ) <EOL> def test_repr ( self ) : <EOL> self . assertEqual ( '<STR_LIT>' , repr ( self . a1 ) ) <EOL> self . assertEqual ( '<STR_LIT>' , repr ( self . a1_swap ) ) <EOL> self . assertEqual ( '<STR_LIT>' , repr ( self . b ) ) <EOL> self . assertEqual ( "<STR_LIT>" , repr ( self . B ( x = '<STR_LIT:foo>' , y = '<STR_LIT:bar>' ) ) ) <EOL> class frozendictTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> from acme . jose . util import frozendict <EOL> self . fdict = frozendict ( x = <NUM_LIT:1> , y = '<STR_LIT:2>' ) <EOL> def test_init_dict ( self ) : <EOL> from acme . jose . util import frozendict <EOL> self . assertEqual ( self . fdict , frozendict ( { '<STR_LIT:x>' : <NUM_LIT:1> , '<STR_LIT:y>' : '<STR_LIT:2>' } ) ) <EOL> def test_init_other_raises_type_error ( self ) : <EOL> from acme . jose . util import frozendict <EOL> self . assertRaises ( TypeError , frozendict , six . iteritems ( { '<STR_LIT:a>' : '<STR_LIT:b>' } ) ) <EOL> def test_len ( self ) : <EOL> self . assertEqual ( <NUM_LIT:2> , len ( self . fdict ) ) <EOL> def test_hash ( self ) : <EOL> self . assertTrue ( isinstance ( hash ( self . fdict ) , int ) ) <EOL> def test_getattr_proxy ( self ) : <EOL> self . assertEqual ( <NUM_LIT:1> , self . fdict . x ) <EOL> self . assertEqual ( '<STR_LIT:2>' , self . fdict . y ) <EOL> def test_getattr_raises_attribute_error ( self ) : <EOL> self . assertRaises ( AttributeError , self . fdict . __getattr__ , '<STR_LIT:z>' ) <EOL> def test_setattr_immutable ( self ) : <EOL> self . assertRaises ( AttributeError , self . fdict . __setattr__ , '<STR_LIT:z>' , <NUM_LIT:3> ) <EOL> def test_repr ( self ) : <EOL> self . assertEqual ( "<STR_LIT>" , repr ( self . fdict ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
