#!/usr/bin/python
# -*- coding: utf-8 -*-

from __future__ import print_function
from xml.etree.ElementTree import ParseError
import xml.etree.ElementTree as ET
import glob
import sys

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

def parse():
    for infile in glob.glob('*.xml'):
        try:
            tree = ET.parse(infile)
            root = tree.getroot()
            if root.findall('.//FatalError'):
                element=root.findall('.//FatalError')[0]
                eprint("Error detected")
                print(infile)
                print(element.text)
                sys.exit(1)
        except ParseError:
            eprint("The file xml isn't correct. There were some mistakes in the tests ")
            sys.exit(1)

def main():
    parse()

if __name__ == '__main__':
    main()

@@ -261,22 +261,48 @@
 ef parse
-():%0A  
+XmlReports():%0A  all_errors = %5B%5D%0A
   for in
@@ -325,28 +325,24 @@
 b('*.xml'):%0A
-    
     try:%0A   
@@ -338,22 +338,16 @@
    try:%0A
-      
       tr
@@ -374,22 +374,16 @@
 )%0A      
-    
-  
 root = t
@@ -406,16 +406,16 @@
     
-      if
+errors =
  roo
@@ -444,144 +444,331 @@
 or')
-:%0A                element=root.findall('.//FatalError')%5B0%5D%0A                eprint(%22Error detected%22)%0A                print(infile
+%0A      exceptions = root.findall('.//Exception')%0A      all_errors = all_errors + errors + exceptions%0A    except ParseError:%0A      eprint(%22The file format is not a correct xml. There were some mistakes in the tests %22)%0A      sys.exit(1)%0A  if all_errors:%0A    for occur in all_errors:%0A      eprint(%22*******************%22
 )%0A      
     
@@ -767,92 +767,194 @@
     
- 
-   
+eprint(%22type: %22 +occur.tag)%0A
       
+e
 print(
-element.text)%0A                sys.exit(1)%0A        except ParseError:
+%22message: %22+occur.text)%0A      eprint(%22additional message: %22 + str(occur.attrib))%0A      for subInfo in occur:%0A        eprint(%22info:%22 +subInfo.tag)
 %0A   
@@ -958,28 +958,24 @@
         
-    
 eprint(%22
 The file
@@ -970,85 +970,135 @@
 nt(%22
-The file xml isn't correct. There were some mistakes in the tests %22
+additional info: %22 + str(subInfo.attrib))%0A    return False %0A  return True%0A%0Adef main():%0A  res = parseXmlReports(
 )%0A  
- 
-     
+if not res:%0A
     
@@ -1113,33 +1113,12 @@
 (1)%0A
-%0Adef main():%0A    parse()%0A
+    
 %0Aif 

Correct parseXML script for unit tests