Skip to content

Commit

Permalink
Split and sort input to ensure stable ordering of attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
yanokwa committed Jan 7, 2020
1 parent 5c7c5a0 commit cc9e490
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pyxform/tests/j2x_question_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from pyxform.builder import create_survey_element_from_dict
from pyxform.tests.utils import prep_class_config

import re

TESTING_BINDINGS = True


Expand All @@ -19,6 +21,12 @@ def ctw(control):
return control.toxml()


def make_testable(xml):
xml = re.sub("^<", "", xml)
xml = re.sub("/?>$", "", xml)
return sorted(xml.split())


class Json2XformQuestionValidationTests(TestCase):
maxDiff = None

Expand Down Expand Up @@ -163,7 +171,10 @@ def test_simple_phone_number_question_type_multilingual(self):
self.assertEqual(ctw(q.xml_control()), expected_phone_number_control_xml)

if TESTING_BINDINGS:
self.assertEqual(ctw(q.xml_binding()), expected_phone_number_binding_xml)
self.assertEqual(
make_testable(ctw(q.xml_binding())),
make_testable(expected_phone_number_binding_xml),
)

def test_simple_select_all_question_multilingual(self):
"""
Expand Down

0 comments on commit cc9e490

Please sign in to comment.