Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #25170 -- Made SimpleTestCase.assertXMLEqual() ignore whitespace outside of tags. #5052

Closed
wants to merge 1 commit into from

Conversation

quamilek
Copy link

In every argument passed to compare_xml will be applied split() function.
All withespaces in the beginning and or end of xml string in assertXMLEqual will be ignored.

@timgraham
Copy link
Member

The solution in #5049 seems a bit simpler. Do you see any behavioral differences between the two approaches?

@quamilek quamilek force-pushed the ticket_25170 branch 3 times, most recently from 2781d88 to dc07ebf Compare July 28, 2015 06:25
…esent

outside XML fragment

In every argument passed to ``compare_xml`` will be applied ``split()``
function.
@quamilek
Copy link
Author

@timgraham, the solution in #5049 strip all element content. In my opinion this is not good behavior.
Element <elem>hello \n</elem> is not the same as <elem>hello</elem>. Fix in #5049 considers them as the same.
I add test to detect this situation: https://github.com/django/django/pull/5052/files#diff-f17eb660f85f373b64bc9765dc74a166R737

@mishunika
Copy link

@quamilek actually the removal of newlines inside is done not by my fix (i.e. the strip() function) but by the regex which is based on lxml.

@timgraham
Copy link
Member

How about a case like this? I'd expect it to pass, but it doesn't.

    def test_simple_equal_with_whitespaces_multiple_elements(self):
        xml1 = "<elem>hello</elem><elem>hello</elem>"
        xml2 = " <elem>hello</elem> \t\n<elem>hello</elem>"
        self.assertXMLEqual(xml1, xml2)

@timgraham timgraham changed the title Fixed #25170 -- Assertion assertXMLEqual fails when white space is present outside XML fragment Fixed #25170 -- Made SimpleTestCase.assertXMLEqual() ignore whitespace outside of tags. Aug 12, 2015
@timgraham
Copy link
Member

Closing due to inactivity. Please send a new PR if you update it, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants