<s> from builtins import range <EOL> import re <EOL> try : <EOL> from django . utils . unittest import TestCase <EOL> except ImportError : <EOL> from django . test import TestCase <EOL> from . ansi import ANSIString <EOL> from evennia import utils <EOL> class ANSIStringTestCase ( TestCase ) : <EOL> def checker ( self , ansi , raw , clean ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( unicode ( ansi . clean ( ) ) , clean ) <EOL> self . assertEqual ( unicode ( ansi . raw ( ) ) , raw ) <EOL> def table_check ( self , ansi , char , code ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( ansi . _char_indexes , char ) <EOL> self . assertEqual ( ansi . _code_indexes , code ) <EOL> def test_instance ( self ) : <EOL> """<STR_LIT>""" <EOL> clean = u'<STR_LIT>' <EOL> encoded = u'<STR_LIT>' <EOL> target = ANSIString ( r'<STR_LIT>' ) <EOL> char_table = [ <NUM_LIT:9> , <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:30> , <NUM_LIT> , <EOL> <NUM_LIT:32> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> code_table = [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:16> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:20> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> self . checker ( target , encoded , clean ) <EOL> self . table_check ( target , char_table , code_table ) <EOL> self . checker ( ANSIString ( target ) , encoded , clean ) <EOL> self . table_check ( ANSIString ( target ) , char_table , code_table ) <EOL> self . checker ( ANSIString ( encoded , decoded = True ) , encoded , clean ) <EOL> self . table_check ( ANSIString ( encoded , decoded = True ) , char_table , <EOL> code_table ) <EOL> self . checker ( ANSIString ( '<STR_LIT>' ) , u'<STR_LIT>' , u'<STR_LIT>' ) <EOL> self . table_check ( ANSIString ( '<STR_LIT>' ) , [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , [ ] ) <EOL> self . checker ( ANSIString ( '<STR_LIT>' ) , u'<STR_LIT>' , u'<STR_LIT>' ) <EOL> def test_slice ( self ) : <EOL> """<STR_LIT>""" <EOL> target = ANSIString ( r'<STR_LIT>' ) <EOL> result = target [ : <NUM_LIT:3> ] <EOL> self . checker ( result , u'<STR_LIT>' , u'<STR_LIT>' ) <EOL> result = target [ : <NUM_LIT:4> ] <EOL> self . checker ( result , u'<STR_LIT>' , u'<STR_LIT>' ) <EOL> result = target [ : ] <EOL> self . checker ( <EOL> result , <EOL> u'<STR_LIT>' , <EOL> u'<STR_LIT>' ) <EOL> result = target [ : - <NUM_LIT:1> ] <EOL> self . checker ( <EOL> result , <EOL> u'<STR_LIT>' , <EOL> u'<STR_LIT>' ) <EOL> result = target [ <NUM_LIT:0> : <NUM_LIT:0> ] <EOL> self . checker ( <EOL> result , <EOL> u'<STR_LIT>' , <EOL> u'<STR_LIT>' ) <EOL> def test_split ( self ) : <EOL> """<STR_LIT>""" <EOL> target = ANSIString ( "<STR_LIT>" ) <EOL> first = ( u'<STR_LIT>' , u'<STR_LIT>' ) <EOL> second = ( u'<STR_LIT>' , <EOL> u'<STR_LIT>' ) <EOL> re_split = re . split ( '<STR_LIT:A>' , target ) <EOL> normal_split = target . split ( '<STR_LIT:A>' ) <EOL> self . assertEqual ( re_split , normal_split ) <EOL> self . assertEqual ( len ( normal_split ) , <NUM_LIT:2> ) <EOL> self . checker ( normal_split [ <NUM_LIT:0> ] , * first ) <EOL> self . checker ( normal_split [ <NUM_LIT:1> ] , * second ) <EOL> def test_join ( self ) : <EOL> """<STR_LIT>""" <EOL> l = [ ANSIString ( "<STR_LIT>" ) for s in range ( <NUM_LIT:0> , <NUM_LIT:3> ) ] <EOL> result = "<STR_LIT>" . join ( l ) <EOL> self . assertEqual ( unicode ( result ) , u'<STR_LIT>' ) <EOL> result = ANSIString ( "<STR_LIT>" ) . join ( l ) <EOL> self . checker ( result , u'<STR_LIT>' <EOL> u'<STR_LIT>' <EOL> u'<STR_LIT>' , u'<STR_LIT>' ) <EOL> def test_len ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( len ( ANSIString ( '<STR_LIT>' ) ) , <NUM_LIT:4> ) <EOL> def test_capitalize ( self ) : <EOL> """<STR_LIT>""" <EOL> target = ANSIString ( '<STR_LIT>' ) <EOL> result = u'<STR_LIT>' <EOL> self . checker ( target . capitalize ( ) , result , u'<STR_LIT>' ) <EOL> def test_mxp_agnostic ( self ) : <EOL> """<STR_LIT>""" <EOL> mxp1 = "<STR_LIT>" <EOL> mxp2 = "<STR_LIT>" <EOL> self . assertEqual ( <NUM_LIT:15> , len ( ANSIString ( mxp1 ) ) ) <EOL> self . assertEqual ( <NUM_LIT> , len ( ANSIString ( mxp2 ) ) ) <EOL> self . assertEqual ( len ( ANSIString ( mxp1 ) ) , len ( ANSIString ( mxp1 ) . split ( "<STR_LIT:\n>" ) [ <NUM_LIT:0> ] ) ) <EOL> self . assertEqual ( len ( ANSIString ( mxp2 ) ) , len ( ANSIString ( mxp2 ) . split ( "<STR_LIT:\n>" ) [ <NUM_LIT:0> ] ) ) <EOL> self . assertEqual ( mxp1 , ANSIString ( mxp1 ) ) <EOL> self . assertEqual ( mxp2 , unicode ( ANSIString ( mxp2 ) ) ) <EOL> def test_add ( self ) : <EOL> """<STR_LIT>""" <EOL> a = ANSIString ( "<STR_LIT>" ) <EOL> b = ANSIString ( "<STR_LIT>" ) <EOL> c = a + b <EOL> result = u'<STR_LIT>' <EOL> self . checker ( c , result , u'<STR_LIT>' ) <EOL> char_table = [ <NUM_LIT:9> , <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> code_table = [ <EOL> <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:15> , <NUM_LIT:16> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:20> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:30> , <NUM_LIT> <EOL> ] <EOL> self . table_check ( c , char_table , code_table ) <EOL> class TestIsIter ( TestCase ) : <EOL> def test_is_iter ( self ) : <EOL> self . assertEqual ( True , utils . is_iter ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ) ) <EOL> self . assertEqual ( False , utils . is_iter ( "<STR_LIT>" ) ) <EOL> class TestCrop ( TestCase ) : <EOL> def test_crop ( self ) : <EOL> self . assertEqual ( "<STR_LIT>" , utils . crop ( "<STR_LIT>" , width = <NUM_LIT:10> , suffix = "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , utils . crop ( "<STR_LIT>" , width = <NUM_LIT:10> , suffix = "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , utils . crop ( "<STR_LIT>" , width = <NUM_LIT:9> , suffix = "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , utils . crop ( "<STR_LIT>" , width = <NUM_LIT:9> , suffix = "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , utils . crop ( "<STR_LIT>" , width = <NUM_LIT:3> , suffix = "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , utils . crop ( "<STR_LIT>" , width = <NUM_LIT:5> , suffix = "<STR_LIT>" ) ) <EOL> class TestDedent ( TestCase ) : <EOL> def test_dedent ( self ) : <EOL> self . assertEqual ( "<STR_LIT>" , utils . dedent ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , utils . dedent ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , utils . dedent ( "<STR_LIT>" ) ) <EOL> input_string = "<STR_LIT>" <EOL> expected_string = "<STR_LIT>" <EOL> self . assertEqual ( expected_string , utils . dedent ( input_string ) ) <EOL> class TestListToString ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_list_to_string ( self ) : <EOL> self . assertEqual ( '<STR_LIT>' , utils . list_to_string ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , endsep = "<STR_LIT>" ) ) <EOL> self . assertEqual ( '<STR_LIT>' , utils . list_to_string ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , endsep = "<STR_LIT>" , addquote = True ) ) <EOL> self . assertEqual ( '<STR_LIT>' , utils . list_to_string ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) ) <EOL> self . assertEqual ( '<STR_LIT>' , utils . list_to_string ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , endsep = "<STR_LIT>" , addquote = True ) ) <EOL> class TestMLen ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_non_mxp_string ( self ) : <EOL> self . assertEqual ( utils . m_len ( '<STR_LIT>' ) , <NUM_LIT:11> ) <EOL> def test_mxp_string ( self ) : <EOL> self . assertEqual ( utils . m_len ( '<STR_LIT>' ) , <NUM_LIT:2> ) <EOL> def test_mxp_ansi_string ( self ) : <EOL> self . assertEqual ( utils . m_len ( ANSIString ( '<STR_LIT>' ) ) , <NUM_LIT:2> ) <EOL> def test_non_mxp_ansi_string ( self ) : <EOL> self . assertEqual ( utils . m_len ( ANSIString ( '<STR_LIT>' ) ) , <NUM_LIT:5> ) <EOL> def test_list ( self ) : <EOL> self . assertEqual ( utils . m_len ( [ None , None ] ) , <NUM_LIT:2> ) <EOL> def test_dict ( self ) : <EOL> self . assertEqual ( utils . m_len ( { '<STR_LIT:hello>' : True , '<STR_LIT>' : False } ) , <NUM_LIT:2> ) <EOL> from . text2html import TextToHTMLparser <EOL> class TestTextToHTMLparser ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . parser = TextToHTMLparser ( ) <EOL> def tearDown ( self ) : <EOL> del self . parser <EOL> def test_url_scheme_ftp ( self ) : <EOL> self . assertEqual ( self . parser . convert_urls ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_url_scheme_www ( self ) : <EOL> self . assertEqual ( self . parser . convert_urls ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_url_scheme_ftpproto ( self ) : <EOL> self . assertEqual ( self . parser . convert_urls ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_url_scheme_http ( self ) : <EOL> self . assertEqual ( self . parser . convert_urls ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_url_scheme_https ( self ) : <EOL> self . assertEqual ( self . parser . convert_urls ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_url_chars_slash ( self ) : <EOL> self . assertEqual ( self . parser . convert_urls ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_url_chars_colon ( self ) : <EOL> self . assertEqual ( self . parser . convert_urls ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_url_chars_querystring ( self ) : <EOL> self . assertEqual ( self . parser . convert_urls ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_url_chars_anchor ( self ) : <EOL> self . assertEqual ( self . parser . convert_urls ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_url_chars_exclam ( self ) : <EOL> self . assertEqual ( self . parser . convert_urls ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_url_edge_leadingw ( self ) : <EOL> self . assertEqual ( self . parser . convert_urls ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_url_edge_following_period_eol ( self ) : <EOL> self . assertEqual ( self . parser . convert_urls ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_url_edge_following_period ( self ) : <EOL> self . assertEqual ( self . parser . convert_urls ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_url_edge_brackets ( self ) : <EOL> self . assertEqual ( self . parser . convert_urls ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_url_edge_multiline ( self ) : <EOL> self . assertEqual ( self . parser . convert_urls ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_url_edge_following_htmlentity ( self ) : <EOL> self . assertEqual ( self . parser . convert_urls ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_url_edge_surrounded_spans ( self ) : <EOL> self . assertEqual ( self . parser . convert_urls ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> from evennia . utils import nested_inlinefuncs <EOL> class TestNestedInlineFuncs ( TestCase ) : <EOL> "<STR_LIT>" <EOL> def test_nofunc ( self ) : <EOL> self . assertEqual ( nested_inlinefuncs . parse_inlinefunc ( <EOL> "<STR_LIT>" ) , <EOL> "<STR_LIT>" ) <EOL> def test_incomplete ( self ) : <EOL> self . assertEqual ( nested_inlinefuncs . parse_inlinefunc ( <EOL> "<STR_LIT>" ) , <EOL> "<STR_LIT>" ) <EOL> def test_single_func ( self ) : <EOL> self . assertEqual ( nested_inlinefuncs . parse_inlinefunc ( <EOL> "<STR_LIT>" ) , <EOL> "<STR_LIT>" ) <EOL> def test_nested ( self ) : <EOL> self . assertEqual ( nested_inlinefuncs . parse_inlinefunc ( <EOL> "<STR_LIT>" ) , <EOL> "<STR_LIT>" ) <EOL> def test_escaped ( self ) : <EOL> self . assertEqual ( nested_inlinefuncs . parse_inlinefunc ( <EOL> "<STR_LIT>" ) , <EOL> "<STR_LIT>" ) <EOL> def test_escaped2 ( self ) : <EOL> self . assertEqual ( nested_inlinefuncs . parse_inlinefunc ( <EOL> '<STR_LIT>' ) , <EOL> "<STR_LIT>" ) <EOL> from evennia . utils import evform <EOL> class TestEvForm ( TestCase ) : <EOL> def test_form ( self ) : <EOL> self . assertEqual ( unicode ( evform . _test ( ) ) , <EOL> u'<STR_LIT>' ) <EOL> def test_ansi_escape ( self ) : <EOL> self . assertEqual ( unicode ( evform . EvForm ( form = { "<STR_LIT>" : "<STR_LIT>" } ) ) , "<STR_LIT>" ) </s>
