from django.test import SimpleTestCase as TestCase
from corehq.apps.app_manager.models import _parse_xml
import os

class XMLParsingTest(TestCase):
    
    def testUnicodeError(self):
        """Tests a bug found in Unicode processing of a form"""
        file_path = os.path.join(os.path.dirname(__file__), "data", "unicode_error_form.xhtml")
        with open(file_path, "rb") as f:
            xml_data = f.read()
        try:
            _parse_xml(xml_data) # this should not raise an error
        except:    
            self.fail("Parsing normal string data shouldn't fail!")
        try:
            _parse_xml(unicode(xml_data))
        except:    
            self.fail("Parsing unicode data shouldn't fail!")

[((9, 33, 9, 58), 'os.path.dirname', 'os.path.dirname', ({(9, 49, 9, 57): '__file__'}, {}), '(__file__)', False, 'import os\n'), ((13, 12, 13, 32), 'corehq.apps.app_manager.models._parse_xml', '_parse_xml', ({(13, 23, 13, 31): 'xml_data'}, {}), '(xml_data)', False, 'from corehq.apps.app_manager.models import _parse_xml\n')]