{{{#!python
class MyTestCase(TestCase):
def test_xml(self):
self.assertXMLEqual('<greeting>hello</greeting>',
'<greeting>hello</greeting>\n')
}}}
I believe this is a bug because white space outside root tag should not
matter. It makes testing rather confusing when reading XML documents from
files (which may or may not have trailing new line characters).
--
Ticket URL: <https://code.djangoproject.com/ticket/25170>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_docs: => 0
* version: 1.8 => master
* needs_tests: => 0
* stage: Unreviewed => Accepted
Comment:
Seems reasonable as the docstring says "Whitespace in most cases is
ignored".
--
Ticket URL: <https://code.djangoproject.com/ticket/25170#comment:1>
* owner: nobody => quamilek
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/25170#comment:2>
Comment (by mishunika):
At the time of analyzing the issue, I didn't notice that the issue is
already assigned. Anyway, just because the fix seems so simple, and there
is no pull request yet, I published my own solution as a PR.
The fixed branch is available here:
https://github.com/mishunika/django/tree/ticket_25170
And the PR is here: https://github.com/django/django/pull/5049
--
Ticket URL: <https://code.djangoproject.com/ticket/25170#comment:3>
Comment (by quamilek):
I started working on this bug after assigned.
This is PR for this issue: https://github.com/django/django/pull/5052
Resolution of this bug is different then @mishunika.
--
Ticket URL: <https://code.djangoproject.com/ticket/25170#comment:4>
* has_patch: 0 => 1
Comment:
I think [https://github.com/django/django/pull/5052 PR 5052] is more
correct in that it will continue to consider whitespace *inside* a tag
significant; e.g. the following snippets shouldn't be considered equal:
{{{
<tag>foo </tag>
<tag>foo</tag>
}}}
Anyone to confirm that? The author of
[https://github.com/django/django/pull/5049 PR 5049] argues otherwise.
--
Ticket URL: <https://code.djangoproject.com/ticket/25170#comment:5>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/25170#comment:6>
* needs_better_patch: 0 => 1
* stage: Ready for checkin => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/25170#comment:7>
Comment (by jbzdak):
Whitespace around tags is indeed siginificant --- technically following
documents *are* different
{{{
<foo></foo>
}}}
and
{{{
<foo>
</foo>
}}}
however for most practical purposes this difference is insignificant, as
most of XML-based formats ignore whitespace altogether (like html).
Despite that I think that in unittesting framework we should rather assume
pessimistic case that whitespace does matter.
--
Ticket URL: <https://code.djangoproject.com/ticket/25170#comment:8>
Comment (by nostalgiaz):
According to https://tools.ietf.org/html/rfc3470#section-4.16
> In XML instances all white space is considered significant and is by
default visible to processing applications
So, I think that @jbzdak is right.
--
Ticket URL: <https://code.djangoproject.com/ticket/25170#comment:9>
* needs_better_patch: 1 => 0
Comment:
The fixed branch is available here:
https://github.com/nostalgiaz/django/tree/pull_25170
And the PR is here: https://github.com/django/django/pull/5580
--
Ticket URL: <https://code.djangoproject.com/ticket/25170#comment:10>
* stage: Accepted => Ready for checkin
Comment:
Contained white-space should really be considered significant in the HTML
case.
If I remember correctly it affect `display: inline` elements in some way
(or it did in the past).
Stripping leading and trailing white space makes sense to me.
--
Ticket URL: <https://code.djangoproject.com/ticket/25170#comment:11>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"2085d8d5bc2625076983d3be14b30ea684c3f0d5" 2085d8d5]:
{{{
#!CommitTicketReference repository=""
revision="2085d8d5bc2625076983d3be14b30ea684c3f0d5"
Fixed #25170 -- Made assertXMLEqual()/assertXMLNotEqual() ignore leading
and trailing whitespace.
Thanks Jacek Bzdak for indepdently contributing a similar fix.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25170#comment:12>