From: Amit Bawer <abawer.com(a)gmail.com>
This patch is preparation for python3 convension.
No regression for tests under python2 which is agnostic to
strings/bytes.
Signed-off-by: Amit Bawer <abawer(a)redhat.com>
---
tests/daemon_test.py | 10 +++++-----
tests/python_test.py | 18 +++++++++---------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/tests/daemon_test.py b/tests/daemon_test.py
index 8896fb2..fe02ef6 100644
--- a/tests/daemon_test.py
+++ b/tests/daemon_test.py
@@ -188,11 +188,11 @@ def test_lookup(tmpdir, sanlock_daemon):
util.sanlock("client", "add_lockspace", "-s",
lockspace, "-o", "1")
util.sanlock("client", "create", "-x", rindex,
"-e", "res")
lookup = util.sanlock("client", "lookup", "-x", rindex,
"-e", "res")
- assert lookup == "lookup done 0\nname res offset 3145728\n"
+ assert lookup == b"lookup done 0\nname res offset 3145728\n"
def test_lookup_uninitialized(tmpdir, sanlock_daemon):
path = tmpdir.join("rindex")
util.create_file(str(path), 1024**2)
@@ -200,12 +200,12 @@ def test_lookup_uninitialized(tmpdir, sanlock_daemon):
with pytest.raises(util.CommandError) as e:
util.sanlock("client", "lookup", "-x", rindex,
"-e", "res")
assert e.value.returncode == 1
- assert e.value.stdout == "lookup done -2\n"
- assert e.value.stderr == ""
+ assert e.value.stdout == b"lookup done -2\n"
+ assert e.value.stderr == b""
def test_lookup_missing(tmpdir, sanlock_daemon):
path = tmpdir.join("rindex")
# Slots: lockspace rindex master-lease user-lease-1 ... user-lease-7
@@ -222,7 +222,7 @@ def test_lookup_missing(tmpdir, sanlock_daemon):
util.sanlock("client", "add_lockspace", "-s",
lockspace, "-o", "1")
with pytest.raises(util.CommandError) as e:
util.sanlock("client", "lookup", "-x", rindex,
"-e", "res")
assert e.value.returncode == 1
- assert e.value.stdout == "lookup done -2\n"
- assert e.value.stderr == ""
+ assert e.value.stdout == b"lookup done -2\n"
+ assert e.value.stderr == b""
diff --git a/tests/python_test.py b/tests/python_test.py
index 12358c7..7e3910b 100644
--- a/tests/python_test.py
+++ b/tests/python_test.py
@@ -41,11 +41,11 @@ def test_write_lockspace(tmpdir, sanlock_daemon, size, offset):
# Test read and write with default alignment and sector size values.
sanlock.write_lockspace("name", path, offset=offset, iotimeout=1)
ls = sanlock.read_lockspace(path, offset=offset)
- assert ls == {"iotimeout": 1, "lockspace": "name"}
+ assert ls == {"iotimeout": 1, "lockspace": b"name"}
# Test read and write with explicit alignment and sector size values.
sanlock.write_lockspace(
"name", path, offset=offset, iotimeout=1, align=ALIGNMENT_1M,
sector=SECTOR_SIZE_512)
@@ -127,12 +127,12 @@ def test_write_resource(tmpdir, sanlock_daemon, size, offset):
# Test read and write with default alignment and sector size values.
sanlock.write_resource("ls_name", "res_name", disks)
res = sanlock.read_resource(path, offset=offset)
assert res == {
- "lockspace": "ls_name",
- "resource": "res_name",
+ "lockspace": b"ls_name",
+ "resource": b"res_name",
"version": 0
}
# Test read and write with explicit alignment and sector size values.
sanlock.write_resource(
@@ -355,12 +355,12 @@ def test_acquire_release_resource(tmpdir, sanlock_daemon, size,
offset):
disks = [(res_path, offset)]
sanlock.write_resource("ls_name", "res_name", disks)
res = sanlock.read_resource(res_path, offset=offset)
assert res == {
- "lockspace": "ls_name",
- "resource": "res_name",
+ "lockspace": b"ls_name",
+ "resource": b"res_name",
"version": 0
}
owners = sanlock.read_resource_owners("ls_name", "res_name",
disks)
assert owners == []
@@ -368,12 +368,12 @@ def test_acquire_release_resource(tmpdir, sanlock_daemon, size,
offset):
fd = sanlock.register()
sanlock.acquire("ls_name", "res_name", disks, slkfd=fd)
res = sanlock.read_resource(res_path, offset=offset)
assert res == {
- "lockspace": "ls_name",
- "resource": "res_name",
+ "lockspace": b"ls_name",
+ "resource": b"res_name",
"version": 1
}
owner = sanlock.read_resource_owners("ls_name", "res_name",
disks)[0]
@@ -389,12 +389,12 @@ def test_acquire_release_resource(tmpdir, sanlock_daemon, size,
offset):
sanlock.release("ls_name", "res_name", disks, slkfd=fd)
res = sanlock.read_resource(res_path, offset=offset)
assert res == {
- "lockspace": "ls_name",
- "resource": "res_name",
+ "lockspace": b"ls_name",
+ "resource": b"res_name",
"version": 1
}
owners = sanlock.read_resource_owners("ls_name", "res_name",
disks)
assert owners == []
--
2.17.2