From: Amit Bawer <abawer(a)redhat.com>
Currently we have two tests expecting to fail, this holds until we add
the path converter funcationality.
- Py2: currenlty not supporing non-ascii paths
- Py3: currently not supporting bytes paths
---
tests/python_test.py | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/tests/python_test.py b/tests/python_test.py
index e721fe8..a24990d 100644
--- a/tests/python_test.py
+++ b/tests/python_test.py
@@ -6,10 +6,11 @@ from __future__ import absolute_import
import errno
import io
import struct
import time
+import six
import pytest
import sanlock
from . import constants
@@ -30,18 +31,35 @@ ALIGNMENT_1M = 1 * MiB
ALIGNMENT_2M = 2 * MiB
SECTOR_SIZE_512 = 512
SECTOR_SIZE_4K = 4 * KiB
+FILE_NAMES = [
+ #name, encoding
+ ("ascii", None),
+ (u"ascii", None),
+ pytest.param(
+ u"\u05d0", None,
+ marks=pytest.mark.xfail(
+ six.PY2,
+ reason="currently not supporting non-ascii paths")),
+ pytest.param(
+ u"\u05d0", "utf-8",
+ marks=pytest.mark.xfail(
+ six.PY3,
+ reason="currently not supporting bytes paths")),
+]
+
+(a)pytest.mark.parametrize("filename, encoding" , FILE_NAMES)
@pytest.mark.parametrize("size,offset", [
# Smallest offset.
(LOCKSPACE_SIZE, 0),
# Large offset.
(LARGE_FILE_SIZE, LARGE_FILE_SIZE - LOCKSPACE_SIZE),
])
-def test_write_lockspace(tmpdir, sanlock_daemon, size, offset):
- path = str(tmpdir.join("lockspace"))
+def test_write_lockspace(tmpdir, sanlock_daemon, filename, encoding, size, offset):
+ path = util.generate_path(tmpdir, filename, encoding)
util.create_file(path, size)
# Test read and write with default alignment and sector size values.
sanlock.write_lockspace("name", path, offset=offset, iotimeout=1)
@@ -114,18 +132,19 @@ def test_read_lockspace_4k_invalid_sector_size(sanlock_daemon,
user_4k_path):
with pytest.raises(sanlock.SanlockException) as e:
sanlock.read_lockspace(user_4k_path, sector=SECTOR_SIZE_512)
assert e.value.errno == errno.EINVAL
+(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES)
@pytest.mark.parametrize("size,offset", [
# Smallest offset.
(MIN_RES_SIZE, 0),
# Large offset.
(LARGE_FILE_SIZE, LARGE_FILE_SIZE - MIN_RES_SIZE),
])
-def test_write_resource(tmpdir, sanlock_daemon, size, offset):
- path = str(tmpdir.join("resources"))
+def test_write_resource(tmpdir, sanlock_daemon, filename, encoding, size, offset):
+ path = util.generate_path(tmpdir, filename, encoding)
util.create_file(path, size)
disks = [(path, offset)]
# Test read and write with default alignment and sector size values.
sanlock.write_resource("ls_name", "res_name", disks)
--
2.17.2