ldb: The test api.py should not rely on order of entries in dict
authorLukas Slebodnik <lslebodn@fedoraproject.org>
Tue, 22 Jan 2019 09:04:02 +0000 (10:04 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 29 Jan 2019 21:09:07 +0000 (22:09 +0100)
commit7a7a5ccf501f89c530970bde072509ed86d7bd89
tree2641f8c249392b9acea0c7d3e698df54dcadd3f5
parent29f9618e38c42e8ccbabc5d2eedae94287c67355
ldb: The test api.py should not rely on order of entries in dict

Test failed on s390x but there is a simple reproducer for any
architecture.

The built-in function repr returns the canonical string representation
of the object. We needn't care about order attributes in string
representation. Therefore test should pass for any order.

    for i in {1..30}; do
        PYTHONHASHSEED=random \
        python2 -c 'import ldb; msg = ldb.Message(); msg.dn = ldb.Dn(ldb.Ldb(), "dc=foo29"); msg["dc"] = b"foo"; print(repr(msg)) '
    done

  ======================================================================
  FAIL: test_repr (__main__.LdbMsgTests)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "tests/python/api.py", line 2322, in test_repr
      "Message({'dn': Dn('dc=foo29'), 'dc': MessageElement(['foo'])})")
  AssertionError: "Message({'dc': MessageElement(['foo']), 'dn': Dn('dc=foo29')})" != "Message({'dn': Dn('dc=foo29'), 'dc': MessageElement(['foo'])})"
  ----------------------------------------------------------------------
  Ran 1025 tests in 29.146s
  FAILED (failures=1)

Signed-off-by: Lukas Slebodnik <lslebodn@fedoraproject.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
lib/ldb/tests/python/api.py