def test_translations(self):
     translator = Libxml2Translator()
     for input_data, it_message in self.samples.items():
         domain, type_, en_message = input_data
         en_error = XMLError(1, 2, domain, type_, en_message, '')
         it_error = translator.translate(en_error)
         self.assertEqual(it_error.message, it_message)
 def test_multiple_error_translation(self):
     translator = Libxml2Translator()
     errors = [
         XMLError(1, 2, 'domain1', 'type1', 'an error occured', 'path1'),
         XMLError(3, 4, 'domain2', 'type2', 'another error occured', 'path2')
     ]
     actual = translator.translate_many(errors)
     self.assertEqual(actual, errors)
 def test_translations(self):
     translator = Libxml2Translator()
     for input_data, it_message in list(self.samples.items()):
         domain, type_, en_message = input_data
         en_error = ValidationDetail(None, 1, 2, domain, type_, en_message,
                                     '')
         it_error = translator.translate(en_error)
         self.assertEqual(it_error.message, it_message)
Exemplo n.º 4
0
 def __init__(self, schema_loader=None, parser=None, translator=None):
     self._schema_loader = schema_loader or XMLSchemaFileLoader()
     self._parser = parser or etree.XMLParser()
     self._translator = translator or Libxml2Translator()
Exemplo n.º 5
0
 def __init__(self, parser=None, translator=None):
     self._parser = parser or etree.XMLParser()
     self._translator = translator or Libxml2Translator()