pull/9862/head
shenwei41 4 years ago
parent 9da686c014
commit 547f96717b

@ -81,6 +81,8 @@ def check_filename(path):
raise ParamValueError('File path is not allowed None or empty!')
if not isinstance(path, str):
raise ParamValueError("File path: {} is not string.".format(path))
if path.endswith("/"):
raise ParamValueError("File path can not end with '/'")
file_name = os.path.basename(path)
# '#', ':', '|', ' ', '}', '"', '+', '!', ']', '[', '\\', '`',

@ -114,3 +114,15 @@ def test_imagenet_to_mindrecord_illegal_filename(fixture_file):
IMAGENET_IMAGE_DIR, filename,
PARTITION_NUMBER)
imagenet_transformer.transform()
def test_imagenet_to_mindrecord_illegal_1_filename(fixture_file):
"""
test transform imagenet dataset to mindrecord
when file name end with '/'.
"""
filename = "test/path/"
with pytest.raises(Exception, match="File path can not end with '/'"):
imagenet_transformer = ImageNetToMR(IMAGENET_MAP_FILE,
IMAGENET_IMAGE_DIR, filename,
PARTITION_NUMBER)
imagenet_transformer.transform()

Loading…
Cancel
Save