From 47761ee449bd08e89fba05e5bfbe584524c638a5 Mon Sep 17 00:00:00 2001 From: Joe Guo Date: Thu, 5 Apr 2018 10:47:16 +1200 Subject: [PATCH] selftest: enable py3 for samba.tests.samdb_api Fix bytes and string. Signed-off-by: Joe Guo Reviewed-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- python/samba/tests/samdb_api.py | 20 ++++++++++---------- selftest/tests.py | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/python/samba/tests/samdb_api.py b/python/samba/tests/samdb_api.py index 259952031b55..c57da62410f2 100644 --- a/python/samba/tests/samdb_api.py +++ b/python/samba/tests/samdb_api.py @@ -72,15 +72,15 @@ class SamDBApiTestCase(TestCaseInTempDir): # def test_create_db_existing_file_non_tdb_file(self): existing_name = self.tempdir + "/existing.db" - existing = open(existing_name, "w") - existing.write("This is not a tdb file!!!!!!") + existing = open(existing_name, "wb") + existing.write(b"This is not a tdb file!!!!!!") existing.close() SamDB(url="tdb://" + existing_name, flags=0) - existing = open(existing_name, "r") + existing = open(existing_name, "rb") contents = existing.readline() - self.assertEquals("TDB file\n", contents) + self.assertEquals(b"TDB file\n", contents) # # Attempt to open an existing tdb file as a tdb file. @@ -99,11 +99,11 @@ class SamDBApiTestCase(TestCaseInTempDir): }) cn = initial.searchone("cn", dn) - self.assertEquals("test_dont_create_db_existing_tdb_file", cn) + self.assertEquals(b"test_dont_create_db_existing_tdb_file", cn) second = SamDB(url="tdb://" + existing_name) cn = second.searchone("cn", dn) - self.assertEquals("test_dont_create_db_existing_tdb_file", cn) + self.assertEquals(b"test_dont_create_db_existing_tdb_file", cn) # # Attempt to open an existing tdb file as a tdb file. @@ -122,11 +122,11 @@ class SamDBApiTestCase(TestCaseInTempDir): }) cn = initial.searchone("cn", dn) - self.assertEquals("test_dont_create_db_existing_tdb_file", cn) + self.assertEquals(b"test_dont_create_db_existing_tdb_file", cn) second = SamDB(url="tdb://" + existing_name, flags=0) cn = second.searchone("cn", dn) - self.assertEquals("test_dont_create_db_existing_tdb_file", cn) + self.assertEquals(b"test_dont_create_db_existing_tdb_file", cn) # Open a non existent TDB file. # Don't create new db is set, the default @@ -155,6 +155,6 @@ class SamDBApiTestCase(TestCaseInTempDir): # def test_create_db_new_file(self): SamDB(url="tdb://" + self.tempdir + "/test.db", flags=0) - existing = open(self.tempdir + "/test.db", "r") + existing = open(self.tempdir + "/test.db", mode="rb") contents = existing.readline() - self.assertEquals("TDB file\n", contents) + self.assertEquals(b"TDB file\n", contents) diff --git a/selftest/tests.py b/selftest/tests.py index 26e053fce792..03f189782327 100644 --- a/selftest/tests.py +++ b/selftest/tests.py @@ -156,7 +156,7 @@ planpythontestsuite("none", "samba.tests.graph") plantestsuite("wafsamba.duplicate_symbols", "none", [os.path.join(srcdir(), "buildtools/wafsamba/test_duplicate_symbol.sh")]) planpythontestsuite("none", "samba.tests.glue", py3_compatible=True) planpythontestsuite("none", "samba.tests.tdb_util", py3_compatible=True) -planpythontestsuite("none", "samba.tests.samdb_api") +planpythontestsuite("none", "samba.tests.samdb_api", py3_compatible=True) if with_pam: plantestsuite("samba.tests.pam_winbind(local)", "ad_member", -- 2.34.1