[PATCH] ldb: The test api.py should not rely on order of entries in

Lukas Slebodnik lslebodn at fedoraproject.org
Mon Jan 28 09:20:37 UTC 2019


On (28/01/19 14:20), Douglas Bagnall via samba-technical wrote:
>On 23/01/19 3:00 AM, Lukas Slebodnik wrote:
>
>> I've just realized that unreliable order of entries is already solved
>> in the test for python3
>> 
>>     def test_repr(self):
>>         self.msg.dn = ldb.Dn(ldb.Ldb(), "dc=foo29")
>>         self.msg["dc"] = b"foo"
>>         if PY3:
>>             self.assertIn(repr(self.msg), [
>>                 "Message({'dn': Dn('dc=foo29'), 'dc': MessageElement([b'foo'])})",
>>                 "Message({'dc': MessageElement([b'foo']), 'dn': Dn('dc=foo29')})",
>>             ])
>>             self.assertIn(repr(self.msg.text), [
>>                 "Message({'dn': Dn('dc=foo29'), 'dc': MessageElement([b'foo'])}).text",
>>                 "Message({'dc': MessageElement([b'foo']), 'dn': Dn('dc=foo29')}).text",
>>             ])
>> 
>> Therefore we can use the same approach for python2. There will be just
>> difference between bytes and strings.
>
>Yes. RB+.
>
>Actually with 3.6+, the order of entries should be reliable given the
>new python dict behaviour (the dn always comes first).
>

It worked just by a chance in 3.6 and in 3.7 it is officially supported :-)
https://docs.python.org/3/whatsnew/3.7.html
"""
  the insertion-order preservation nature of dict objects has been declared to be
  an official part of the Python language spec.
"""

Thank you very much for review.

LS



More information about the samba-technical mailing list