<s> from wq . io import JsonFileIO , XmlFileIO <EOL> from wq . io . exceptions import MappingFailed <EOL> from . base import IoTestCase <EOL> class CustomJsonFileIO ( JsonFileIO ) : <EOL> namespace = "<STR_LIT>" <EOL> class ExtraJsonFileIO ( CustomJsonFileIO ) : <EOL> scan_fields = True <EOL> class CustomXmlFileIO ( XmlFileIO ) : <EOL> root_tag = "<STR_LIT>" <EOL> item_tag = "<STR_LIT>" <EOL> class CustomTestCase ( IoTestCase ) : <EOL> def test_custom_json ( self ) : <EOL> filename = self . get_filename ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> instance = CustomJsonFileIO ( filename = filename ) <EOL> self . check_instance ( instance ) <EOL> def test_scan_fields ( self ) : <EOL> filename = self . get_filename ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> instance = ExtraJsonFileIO ( filename = filename ) <EOL> self . check_instance ( instance ) <EOL> self . assertIn ( "<STR_LIT>" , instance . get_field_names ( ) ) <EOL> self . assertIsNone ( instance [ <NUM_LIT:0> ] . four ) <EOL> self . assertEqual ( instance [ <NUM_LIT:1> ] . four , "<STR_LIT>" ) <EOL> def test_unexpected_field ( self ) : <EOL> filename = self . get_filename ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> instance = CustomJsonFileIO ( filename = filename ) <EOL> with self . assertRaises ( MappingFailed ) as e : <EOL> instance [ <NUM_LIT:1> ] <EOL> self . assertIn ( "<STR_LIT>" , str ( e . exception ) ) <EOL> def test_custom_xml ( self ) : <EOL> filename = self . get_filename ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> instance = CustomXmlFileIO ( filename = filename ) <EOL> self . check_instance ( instance ) </s>
