[Python-Dev] Is XML serialization output guaranteed to be bytewise identical forever?
Ned Batchelder
ned at nedbatchelder.com
Tue Mar 19 07:53:11 EDT 2019
On 3/19/19 4:13 AM, Serhiy Storchaka wrote:
> 19.03.19 00:41, Raymond Hettinger пише:
>> 3) Add a standards compliant canonicalization tool (see
>> https://en.wikipedia.org/wiki/Canonical_XML ). This is likely to be
>> the right-way-to-do-it but takes time and energy.
>>
>> 4) Fix the tests in the third-party modules to be more focused on
>> their actual test objectives, the semantics of the generated XML
>> rather than the exact serialization. This option would seem like the
>> right-thing-to-do but it isn't trivial because the entire premise of
>> the existing test is invalid. For every case, we'll actually have to
>> think through what the test objective really is.
>
> I think the combination of options 3 and 4 is the right thing. Not
> always the stable output is needed, in these cases option 4 should be
> considered. But there are valid use cases for the stable output, in
> these cases we need to provide an alternative in the stdlib. I am
> working on this.
Option 4 is misleading. Is anyone here really offering to "fix the
tests in third-party modules"? Option 4 is actually, "do nothing, and
let a multitude of projects figure out how to fix their tests, slowing
progress in those projects as they try to support Python 3.8."
In my case, the test code has a generic function to compare an actual
directory of files to an expected directory of files, so it isn't quite
as simple as "just use the right XML comparison." And I support Python
2.7, 3.5, etc, so tests still need to work under those versions. None
of this is impossible, but please try not to preach to us maintainers
that we are doing it wrong, that it will be easy to fix, etc. Using
language like "the entire premise of the test is invalid" seems
needlessly condescending.
As one of the suggested solutions, a DOM comparison is not enough. I
don't just want to know that my actual XML is different than my expected
XML. I want to know where and how it differs.
Textual comparison may be the "wrong" way to check XML, but it gives me
many tools for working with the test results. It was simple and it
worked. Now in Python 3.8, because Python doesn't want to add an
optional flag to continue doing what it has always done, I need to
re-engineer my tests.
--Ned.
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/ned%40nedbatchelder.com
More information about the Python-Dev
mailing list