<commit_before>from unittest import TestCase
from pyxform import create_survey_from_xls
import re

class XMLTests(TestCase):

    def setUp(self):
        self.survey = create_survey_from_xls("pyxform/tests/yes_or_no_question.xls")
    
    def test_to_xml(self):
        xml_str = u'''<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <h:head>
    <h:title>yes_or_no_question</h:title>
    <model>
      <itext>
        <translation lang="english">
          <text id="/yes_or_no_question/good_day:label">
            <value>have you had a good day today?</value>
          </text>
          <text id="/yes_or_no_question/good_day/no:label">
            <value>no</value>
          </text>
          <text id="/yes_or_no_question/good_day/yes:label">
            <value>yes</value>
          </text>
        </translation>
      </itext>
      <instance>
        <yes_or_no_question id="yes_or_no_question_2011_04_22">
          <good_day/>
        </yes_or_no_question>
      </instance>
      <bind nodeset="/yes_or_no_question/good_day" required="true()" type="select1"/>
    </model>
  </h:head>
  <h:body>
    <select1 ref="/yes_or_no_question/good_day">
      <label ref="jr:itext('/yes_or_no_question/good_day:label')"/>
      <item>
        <label ref="jr:itext('/yes_or_no_question/good_day/yes:label')"/>
        <value>yes</value>
      </item>
      <item>
        <label ref="jr:itext('/yes_or_no_question/good_day/no:label')"/>
        <value>no</value>
      </item>
    </select1>
  </h:body>
</h:html>'''
        xml_str = re.sub(u">\s+<", u"><", xml_str)
        self.assertEquals(xml_str, self.survey.to_xml())<commit_msg>Fixed test that was failing because the id string changes with the day.<commit_after>from unittest import TestCase
from pyxform import create_survey_from_xls
import re

class XMLTests(TestCase):

    def setUp(self):
        self.survey = create_survey_from_xls("pyxform/tests/yes_or_no_question.xls")
    
    def test_to_xml(self):
        xml_str = u'''<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <h:head>
    <h:title>yes_or_no_question</h:title>
    <model>
      <itext>
        <translation lang="english">
          <text id="/yes_or_no_question/good_day:label">
            <value>have you had a good day today?</value>
          </text>
          <text id="/yes_or_no_question/good_day/no:label">
            <value>no</value>
          </text>
          <text id="/yes_or_no_question/good_day/yes:label">
            <value>yes</value>
          </text>
        </translation>
      </itext>
      <instance>
        <yes_or_no_question id="yes_or_no_question_2011_04_22">
          <good_day/>
        </yes_or_no_question>
      </instance>
      <bind nodeset="/yes_or_no_question/good_day" required="true()" type="select1"/>
    </model>
  </h:head>
  <h:body>
    <select1 ref="/yes_or_no_question/good_day">
      <label ref="jr:itext('/yes_or_no_question/good_day:label')"/>
      <item>
        <label ref="jr:itext('/yes_or_no_question/good_day/yes:label')"/>
        <value>yes</value>
      </item>
      <item>
        <label ref="jr:itext('/yes_or_no_question/good_day/no:label')"/>
        <value>no</value>
      </item>
    </select1>
  </h:body>
</h:html>'''
        xml_str = re.sub(u">\s+<", u"><", xml_str)
        xml_str = re.sub(r"yes_or_no_question_2011_04_22", self.survey.id_string(), xml_str)
        self.assertEquals(xml_str, self.survey.to_xml())
{'fraction_non_alphanumeric': 0.1667992574913816, 'fraction_numerical': 0.01856271546009016, 'mean_word_length': 2.8333333333333335, 'pattern_counts': {'":': 0, '<': 97, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, 'xml': 26}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6407573', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1391, 'n_words': 189}