<s> import datetime <EOL> import unittest <EOL> from coaster . utils import LabeledEnum , make_password , check_password , parse_isoformat , sanitize_html , sorted_timezones , namespace_from_url , deobfuscate_email <EOL> class MY_ENUM ( LabeledEnum ) : <EOL> FIRST = ( <NUM_LIT:1> , "<STR_LIT>" ) <EOL> SECOND = ( <NUM_LIT:2> , "<STR_LIT>" ) <EOL> THIRD = ( <NUM_LIT:3> , "<STR_LIT>" ) <EOL> class TestCoasterUtils ( unittest . TestCase ) : <EOL> def test_labeled_enum ( self ) : <EOL> self . assertEqual ( MY_ENUM . FIRST , <NUM_LIT:1> ) <EOL> self . assertEqual ( MY_ENUM . SECOND , <NUM_LIT:2> ) <EOL> self . assertEqual ( MY_ENUM . THIRD , <NUM_LIT:3> ) <EOL> self . assertEqual ( MY_ENUM [ MY_ENUM . FIRST ] , "<STR_LIT>" ) <EOL> self . assertEqual ( MY_ENUM [ MY_ENUM . SECOND ] , "<STR_LIT>" ) <EOL> self . assertEqual ( MY_ENUM [ MY_ENUM . THIRD ] , "<STR_LIT>" ) <EOL> self . assertEqual ( MY_ENUM . items ( ) , [ ( <NUM_LIT:1> , "<STR_LIT>" ) , ( <NUM_LIT:2> , "<STR_LIT>" ) , ( <NUM_LIT:3> , "<STR_LIT>" ) ] ) <EOL> try : <EOL> MY_ENUM [ <NUM_LIT:2> ] = "<STR_LIT>" <EOL> except TypeError : <EOL> pass <EOL> def test_unlisted_make_password_encoding ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertRaises ( ValueError , make_password , password = '<STR_LIT:password>' , encoding = u'<STR_LIT>' ) <EOL> def test_check_password ( self ) : <EOL> self . assertFalse ( check_password ( u'<STR_LIT>' , u'<STR_LIT>' ) ) <EOL> self . assertTrue ( check_password ( u'<STR_LIT>' , u'<STR_LIT>' ) ) <EOL> self . assertTrue ( check_password ( u'<STR_LIT>' , u'<STR_LIT:test>' ) ) <EOL> self . assertTrue ( check_password ( u'<STR_LIT>' , u'<STR_LIT:test>' ) ) <EOL> def test_parse_isoformat ( self ) : <EOL> self . assertEqual ( parse_isoformat ( "<STR_LIT>" ) , datetime . datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:11> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT> ) ) <EOL> self . assertEqual ( parse_isoformat ( "<STR_LIT>" ) , datetime . datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:11> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> def test_sanitize_html ( self ) : <EOL> html = """<STR_LIT>""" <EOL> self . assertEqual ( sanitize_html ( html ) , u'<STR_LIT>' ) <EOL> self . assertEqual ( sanitize_html ( "<STR_LIT>" ) , u'<STR_LIT>' ) <EOL> def test_sorted_timezones ( self ) : <EOL> self . assertTrue ( isinstance ( sorted_timezones ( ) , list ) ) <EOL> def test_namespace_from_url ( self ) : <EOL> self . assertEqual ( namespace_from_url ( u'<STR_LIT>' ) , u'<STR_LIT>' ) <EOL> self . assertEqual ( namespace_from_url ( u'<STR_LIT>' ) , <EOL> u'<STR_LIT>' ) <EOL> self . assertEqual ( namespace_from_url ( u'<STR_LIT>' ) , u'<STR_LIT>' ) <EOL> self . assertEqual ( namespace_from_url ( u'<STR_LIT>' ) , None ) <EOL> self . assertEqual ( namespace_from_url ( u'<STR_LIT>' ) , None ) <EOL> self . assertEqual ( namespace_from_url ( '<STR_LIT:127.0.0.1>' ) , None ) <EOL> self . assertTrue ( isinstance ( namespace_from_url ( u'<STR_LIT>' ) , unicode ) ) <EOL> self . assertTrue ( isinstance ( namespace_from_url ( '<STR_LIT>' ) , str ) ) <EOL> def test_deobfuscate_email ( self ) : <EOL> input = """<STR_LIT>""" <EOL> output = """<STR_LIT>""" <EOL> self . assertEqual ( deobfuscate_email ( input ) , output ) </s>
