未验证 提交 197e62c2 编写于 作者: C Cleber Rosa

Merge remote-tracking branch 'apahim/fix_astring_safepath'

Signed-off-by: NCleber Rosa <crosa@redhat.com>
...@@ -35,14 +35,14 @@ from six.moves import xrange as range ...@@ -35,14 +35,14 @@ from six.moves import xrange as range
#: String containing all fs-unfriendly chars (Windows-fat/Linux-ext3) #: String containing all fs-unfriendly chars (Windows-fat/Linux-ext3)
FS_UNSAFE_CHARS = '<>:"/\\|?*' FS_UNSAFE_CHARS = '<>:"/\\|?*;'
# Translate table to replace fs-unfriendly chars # Translate table to replace fs-unfriendly chars
if PY3: if PY3:
_FS_TRANSLATE = bytes.maketrans(bytes(FS_UNSAFE_CHARS, "ascii"), _FS_TRANSLATE = bytes.maketrans(bytes(FS_UNSAFE_CHARS, "ascii"),
b'_________') b'__________')
else: else:
_FS_TRANSLATE = string.maketrans(FS_UNSAFE_CHARS, '_________') _FS_TRANSLATE = string.maketrans(FS_UNSAFE_CHARS, '__________')
def bitlist_to_string(data): def bitlist_to_string(data):
......
...@@ -79,13 +79,13 @@ class TestClassTestUnit(unittest.TestCase): ...@@ -79,13 +79,13 @@ class TestClassTestUnit(unittest.TestCase):
# Everything fits # Everything fits
check(1, "a" * 253, None, "1-" + ("a" * 253)) check(1, "a" * 253, None, "1-" + ("a" * 253))
check(2, "a" * 251, {"variant_id": 1}, "2-" + ("a" * 251) + ";1") check(2, "a" * 251, {"variant_id": 1}, "2-" + ("a" * 251) + "_1")
check(99, "a" * 249, {"variant_id": 88}, "99-" + ("a" * 249) + ";88") check(99, "a" * 249, {"variant_id": 88}, "99-" + ("a" * 249) + "_88")
# Shrink name # Shrink name
check(3, "a" * 252, {"variant_id": 1}, "3-" + ('a' * 251) + ";1") check(3, "a" * 252, {"variant_id": 1}, "3-" + ('a' * 251) + "_1")
# Shrink variant # Shrink variant
check("a" * 253, "whatever", {"variant_id": 99}, "a" * 253 + ";9") check("a" * 253, "whatever", {"variant_id": 99}, "a" * 253 + "_9")
check("a" * 254, "whatever", {"variant_id": 99}, "a" * 254 + ";") check("a" * 254, "whatever", {"variant_id": 99}, "a" * 254 + "_")
# No variant # No variant
tst = check("a" * 255, "whatever", {"variant_id": "whatever-else"}, tst = check("a" * 255, "whatever", {"variant_id": "whatever-else"},
"a" * 255) "a" * 255)
...@@ -375,7 +375,7 @@ class TestID(unittest.TestCase): ...@@ -375,7 +375,7 @@ class TestID(unittest.TestCase):
variant = {'variant_id': variant_id} variant = {'variant_id': variant_id}
test_id = test.TestID(uid, name, variant=variant) test_id = test.TestID(uid, name, variant=variant)
self.assertEqual(test_id.uid, 1) self.assertEqual(test_id.uid, 1)
self.assertEqual(test_id.str_filesystem, '%s;%s' % (uid, variant_id[:253])) self.assertEqual(test_id.str_filesystem, '%s_%s' % (uid, variant_id[:253]))
self.assertIs(test_id.variant, variant_id) self.assertIs(test_id.variant, variant_id)
self.assertEqual(test_id.str_variant, ";%s" % variant_id) self.assertEqual(test_id.str_variant, ";%s" % variant_id)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册