<s> try : <EOL> import unittest2 as unittest <EOL> except ImportError : <EOL> import unittest <EOL> from cassandra import Unavailable , Timeout , ConsistencyLevel <EOL> import re <EOL> class ConsistencyExceptionTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def extract_consistency ( self , msg ) : <EOL> """<STR_LIT>""" <EOL> match = re . search ( "<STR_LIT>" , msg ) <EOL> return match and match . group ( <NUM_LIT:1> ) <EOL> def test_timeout_consistency ( self ) : <EOL> """<STR_LIT>""" <EOL> consistency_str = self . extract_consistency ( repr ( Timeout ( "<STR_LIT>" , consistency = None ) ) ) <EOL> self . assertEqual ( consistency_str , '<STR_LIT>' ) <EOL> for c in ConsistencyLevel . value_to_name . keys ( ) : <EOL> consistency_str = self . extract_consistency ( repr ( Timeout ( "<STR_LIT>" , consistency = c ) ) ) <EOL> self . assertEqual ( consistency_str , ConsistencyLevel . value_to_name [ c ] ) <EOL> def test_unavailable_consistency ( self ) : <EOL> """<STR_LIT>""" <EOL> consistency_str = self . extract_consistency ( repr ( Unavailable ( "<STR_LIT>" , consistency = None ) ) ) <EOL> self . assertEqual ( consistency_str , '<STR_LIT>' ) <EOL> for c in ConsistencyLevel . value_to_name . keys ( ) : <EOL> consistency_str = self . extract_consistency ( repr ( Unavailable ( "<STR_LIT>" , consistency = c ) ) ) <EOL> self . assertEqual ( consistency_str , ConsistencyLevel . value_to_name [ c ] ) </s>
