<s> from django . template . defaultfilters import length <EOL> from django . test import SimpleTestCase <EOL> from django . utils . safestring import mark_safe <EOL> from . . utils import setup <EOL> class LengthTests ( SimpleTestCase ) : <EOL> @ setup ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> def test_length01 ( self ) : <EOL> output = self . engine . render_to_string ( '<STR_LIT>' , { '<STR_LIT:list>' : [ '<STR_LIT:4>' , None , True , { } ] } ) <EOL> self . assertEqual ( output , '<STR_LIT:4>' ) <EOL> @ setup ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> def test_length02 ( self ) : <EOL> output = self . engine . render_to_string ( '<STR_LIT>' , { '<STR_LIT:list>' : [ ] } ) <EOL> self . assertEqual ( output , '<STR_LIT:0>' ) <EOL> @ setup ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> def test_length03 ( self ) : <EOL> output = self . engine . render_to_string ( '<STR_LIT>' , { '<STR_LIT:string>' : '<STR_LIT>' } ) <EOL> self . assertEqual ( output , '<STR_LIT:0>' ) <EOL> @ setup ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> def test_length04 ( self ) : <EOL> output = self . engine . render_to_string ( '<STR_LIT>' , { '<STR_LIT:string>' : '<STR_LIT>' } ) <EOL> self . assertEqual ( output , '<STR_LIT>' ) <EOL> @ setup ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> def test_length05 ( self ) : <EOL> output = self . engine . render_to_string ( '<STR_LIT>' , { '<STR_LIT:string>' : mark_safe ( '<STR_LIT>' ) } ) <EOL> self . assertEqual ( output , '<STR_LIT>' ) <EOL> @ setup ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> def test_length06 ( self ) : <EOL> output = self . engine . render_to_string ( '<STR_LIT>' , { '<STR_LIT:int>' : <NUM_LIT:7> } ) <EOL> self . assertEqual ( output , '<STR_LIT:0>' ) <EOL> @ setup ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> def test_length07 ( self ) : <EOL> output = self . engine . render_to_string ( '<STR_LIT>' , { '<STR_LIT:None>' : None } ) <EOL> self . assertEqual ( output , '<STR_LIT:0>' ) <EOL> class FunctionTests ( SimpleTestCase ) : <EOL> def test_string ( self ) : <EOL> self . assertEqual ( length ( '<STR_LIT>' ) , <NUM_LIT:4> ) <EOL> def test_safestring ( self ) : <EOL> self . assertEqual ( length ( mark_safe ( '<STR_LIT>' ) ) , <NUM_LIT:4> ) <EOL> def test_list ( self ) : <EOL> self . assertEqual ( length ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ) , <NUM_LIT:4> ) </s>
