summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2021-02-11 15:50:53 +1300
committerDavid Mulder <dmulder@samba.org>2021-02-22 15:50:55 +0000
commite49a0b444ab5dfd5dc4a82fae2e5939cc9cfe5a4 (patch)
treeca57ed48b39fd9fd612eff93fd0df2241ec149b5
parentbc7224fbc7902e68b104fb5938c8348a11647be5 (diff)
downloadsamba-e49a0b444ab5dfd5dc4a82fae2e5939cc9cfe5a4.tar.gz
ldb: remove some 'if PY3's in tests
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: David Mulder <dmulder@suse.com> Autobuild-User(master): David Mulder <dmulder@samba.org> Autobuild-Date(master): Mon Feb 22 15:50:55 UTC 2021 on sn-devel-184
-rwxr-xr-xlib/ldb/tests/python/api.py60
-rwxr-xr-xlib/ldb/tests/python/index.py1
2 files changed, 17 insertions, 44 deletions
diff --git a/lib/ldb/tests/python/api.py b/lib/ldb/tests/python/api.py
index 1d3d765e607..5198f3fbbb5 100755
--- a/lib/ldb/tests/python/api.py
+++ b/lib/ldb/tests/python/api.py
@@ -10,7 +10,6 @@ import time
import ldb
import shutil
-PY3 = sys.version_info > (3, 0)
TDB_PREFIX = "tdb://"
MDB_PREFIX = "mdb://"
@@ -150,12 +149,9 @@ class SimpleLdb(LdbBaseTest):
except UnicodeDecodeError as e:
raise
except TypeError as te:
- if PY3:
- p3errors = ["argument 2 must be str, not bytes",
- "Can't convert 'bytes' object to str implicitly"]
- self.assertIn(str(te), p3errors)
- else:
- raise
+ p3errors = ["argument 2 must be str, not bytes",
+ "Can't convert 'bytes' object to str implicitly"]
+ self.assertIn(str(te), p3errors)
def test_search_attrs(self):
l = ldb.Ldb(self.url(), flags=self.flags())
@@ -3031,24 +3027,14 @@ class LdbMsgTests(TestCase):
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",
- ])
- else:
- 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",
- ])
+ 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",
+ ])
def test_len(self):
self.assertEqual(0, len(self.msg))
@@ -3288,20 +3274,12 @@ class MessageElementTests(TestCase):
def test_repr(self):
x = ldb.MessageElement([b"foo"])
- if PY3:
- self.assertEqual("MessageElement([b'foo'])", repr(x))
- self.assertEqual("MessageElement([b'foo']).text", repr(x.text))
- else:
- self.assertEqual("MessageElement(['foo'])", repr(x))
- self.assertEqual("MessageElement(['foo']).text", repr(x.text))
+ self.assertEqual("MessageElement([b'foo'])", repr(x))
+ self.assertEqual("MessageElement([b'foo']).text", repr(x.text))
x = ldb.MessageElement([b"foo", b"bla"])
self.assertEqual(2, len(x))
- if PY3:
- self.assertEqual("MessageElement([b'foo',b'bla'])", repr(x))
- self.assertEqual("MessageElement([b'foo',b'bla']).text", repr(x.text))
- else:
- self.assertEqual("MessageElement(['foo','bla'])", repr(x))
- self.assertEqual("MessageElement(['foo','bla']).text", repr(x.text))
+ self.assertEqual("MessageElement([b'foo',b'bla'])", repr(x))
+ self.assertEqual("MessageElement([b'foo',b'bla']).text", repr(x.text))
def test_get_item(self):
x = ldb.MessageElement([b"foo", b"bar"])
@@ -3332,12 +3310,8 @@ class MessageElementTests(TestCase):
def test_extended(self):
el = ldb.MessageElement([b"456"], ldb.FLAG_MOD_ADD, "bla")
- if PY3:
- self.assertEqual("MessageElement([b'456'])", repr(el))
- self.assertEqual("MessageElement([b'456']).text", repr(el.text))
- else:
- self.assertEqual("MessageElement(['456'])", repr(el))
- self.assertEqual("MessageElement(['456']).text", repr(el.text))
+ self.assertEqual("MessageElement([b'456'])", repr(el))
+ self.assertEqual("MessageElement([b'456']).text", repr(el.text))
def test_bad_text(self):
el = ldb.MessageElement(b'\xba\xdd')
diff --git a/lib/ldb/tests/python/index.py b/lib/ldb/tests/python/index.py
index f957087f01c..c1da76d67e2 100755
--- a/lib/ldb/tests/python/index.py
+++ b/lib/ldb/tests/python/index.py
@@ -30,7 +30,6 @@ import sys
import ldb
import shutil
-PY3 = sys.version_info > (3, 0)
TDB_PREFIX = "tdb://"
MDB_PREFIX = "mdb://"