<s> import sys <EOL> import unittest <EOL> try : <EOL> import StringIO as io <EOL> except ImportError : <EOL> import io <EOL> from resync . resource import Resource <EOL> from resync . list_base_with_index import ListBaseWithIndex , ListBaseIndexError <EOL> from resync . sitemap import Sitemap , SitemapIndexError <EOL> etree_error_class = None <EOL> if ( sys . version_info < ( <NUM_LIT:2> , <NUM_LIT:7> ) ) : <EOL> from xml . parsers . expat import ExpatError <EOL> etree_error_class = ExpatError <EOL> else : <EOL> from xml . etree . ElementTree import ParseError <EOL> etree_error_class = ParseError <EOL> class TestListBaseWithIndex ( unittest . TestCase ) : <EOL> def test_08_print ( self ) : <EOL> lb = ListBaseWithIndex ( ) <EOL> lb . add ( Resource ( uri = '<STR_LIT:a>' , lastmod = '<STR_LIT>' , length = <NUM_LIT> ) ) <EOL> lb . add ( Resource ( uri = '<STR_LIT:b>' , lastmod = '<STR_LIT>' , length = <NUM_LIT> ) ) <EOL> lb . add ( Resource ( uri = '<STR_LIT:c>' , lastmod = '<STR_LIT>' , length = <NUM_LIT:0> ) ) <EOL> lb . md [ '<STR_LIT>' ] = None <EOL> self . assertEqual ( lb . as_xml ( ) , '<STR_LIT>' ) <EOL> def test_08_print_iter ( self ) : <EOL> r = [ Resource ( uri = '<STR_LIT:a>' , lastmod = '<STR_LIT>' , length = <NUM_LIT> ) , <EOL> Resource ( uri = '<STR_LIT:b>' , lastmod = '<STR_LIT>' , length = <NUM_LIT> ) , <EOL> Resource ( uri = '<STR_LIT:c>' , lastmod = '<STR_LIT>' , length = <NUM_LIT:0> ) ] <EOL> lb = ListBaseWithIndex ( resources = iter ( r ) ) <EOL> self . assertRaises ( TypeError , lb . as_xml ) <EOL> lb = ListBaseWithIndex ( resources = iter ( r ) , count = <NUM_LIT:3> ) <EOL> lb . max_sitemap_entries = <NUM_LIT:2> <EOL> self . assertRaises ( ListBaseIndexError , lb . as_xml ) <EOL> lb = ListBaseWithIndex ( resources = iter ( r ) , count = <NUM_LIT:3> ) <EOL> lb . md [ '<STR_LIT>' ] = None <EOL> self . assertEqual ( lb . as_xml ( ) , '<STR_LIT>' ) <EOL> def test_11_parse_2 ( self ) : <EOL> xml = '<STR_LIT>' <EOL> lb = ListBaseWithIndex ( ) <EOL> lb . parse ( fh = io . StringIO ( xml ) ) <EOL> self . assertEqual ( len ( lb . resources ) , <NUM_LIT:2> , '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> suite = unittest . TestLoader ( ) . loadTestsFromTestCase ( TestListBaseWithIndex ) <EOL> unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) . run ( suite ) </s>
