summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@fedoraproject.org>2019-01-22 10:04:02 +0100
committerStefan Metzmacher <metze@samba.org>2019-02-26 13:00:12 +0100
commitbfa9353ce1d2fa7925b0efa0baafb34fcc29bb65 (patch)
tree40c5bcd518937a3afc71bc0a354650489488455b /lib
parent942822e7165565d9e9d462a7babb277c023bc2b5 (diff)
downloadsamba-bfa9353ce1d2fa7925b0efa0baafb34fcc29bb65.tar.gz
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> (cherry picked from commit 7a7a5ccf501f89c530970bde072509ed86d7bd89)
Diffstat (limited to 'lib')
-rwxr-xr-xlib/ldb/tests/python/api.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/ldb/tests/python/api.py b/lib/ldb/tests/python/api.py
index 1d9f33f8f73..e8826b5af3b 100755
--- a/lib/ldb/tests/python/api.py
+++ b/lib/ldb/tests/python/api.py
@@ -2317,12 +2317,14 @@ class LdbMsgTests(TestCase):
"Message({'dc': MessageElement([b'foo']), 'dn': Dn('dc=foo29')}).text",
])
else:
- self.assertEqual(
- repr(self.msg),
- "Message({'dn': Dn('dc=foo29'), 'dc': MessageElement(['foo'])})")
- self.assertEqual(
- repr(self.msg.text),
- "Message({'dn': Dn('dc=foo29'), 'dc': MessageElement(['foo'])}).text")
+ self.assertIn(repr(self.msg), [
+ "Message({'dn': Dn('dc=foo29'), 'dc': MessageElement(['foo'])})",
+ "Message({'dc': MessageElement(['foo']), 'dn': Dn('dc=foo29')})",
+ ])
+ self.assertIn(repr(self.msg.text), [
+ "Message({'dn': Dn('dc=foo29'), 'dc': MessageElement(['foo'])}).text",
+ "Message({'dc': MessageElement(['foo']), 'dn': Dn('dc=foo29')}).text",
+ ])
def test_len(self):
self.assertEqual(0, len(self.msg))