<s> from thunderdome . containers import Table <EOL> from unittest import TestCase <EOL> class Person ( object ) : <EOL> def __init__ ( self , name ) : <EOL> self . name = name <EOL> class SomeEdge ( object ) : <EOL> def __init__ ( self , nickname ) : <EOL> self . nickname = nickname <EOL> class TableTest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . data = [ { '<STR_LIT:v>' : Person ( '<STR_LIT>' ) , '<STR_LIT:e>' : SomeEdge ( '<STR_LIT>' ) } , <EOL> { '<STR_LIT:v>' : Person ( '<STR_LIT>' ) , '<STR_LIT:e>' : SomeEdge ( '<STR_LIT>' ) } , <EOL> { '<STR_LIT:v>' : Person ( '<STR_LIT>' ) , '<STR_LIT:e>' : SomeEdge ( '<STR_LIT>' ) } ] <EOL> self . t = Table ( self . data ) <EOL> def test_length ( self ) : <EOL> assert len ( self . t ) == <NUM_LIT:3> <EOL> def test_iteration ( self ) : <EOL> i = <NUM_LIT:0> <EOL> for r in self . t : <EOL> i += <NUM_LIT:1> <EOL> assert r . v . name is not None <EOL> assert i == <NUM_LIT:3> <EOL> def test_access_element ( self ) : <EOL> assert self . t [ <NUM_LIT:0> ] . v . name == '<STR_LIT>' <EOL> assert self . t [ <NUM_LIT:0> ] . e . nickname == '<STR_LIT>' <EOL> assert self . t [ <NUM_LIT:1> ] . v . name == '<STR_LIT>' , self . t [ <NUM_LIT:1> ] . v . name <EOL> assert self . t [ <NUM_LIT:2> ] . e . nickname == '<STR_LIT>' <EOL> class EmptyTableTest ( TestCase ) : <EOL> def test_empty ( self ) : <EOL> t = Table ( [ ] ) <EOL> with self . assertRaises ( IndexError ) : <EOL> t [ <NUM_LIT:0> ] <EOL> def test_empty2 ( self ) : <EOL> t = Table ( [ [ ] ] ) <EOL> with self . assertRaises ( IndexError ) : <EOL> t [ <NUM_LIT:0> ] </s>
