Browse Source

Fix Bug

tags/v1.1.0
shenwei41 5 years ago
parent
commit
547f96717b
2 changed files with 14 additions and 0 deletions
  1. +2
    -0
      mindspore/mindrecord/shardutils.py
  2. +12
    -0
      tests/ut/python/mindrecord/test_imagenet_to_mindrecord.py

+ 2
- 0
mindspore/mindrecord/shardutils.py View File

@@ -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)

# '#', ':', '|', ' ', '}', '"', '+', '!', ']', '[', '\\', '`',


+ 12
- 0
tests/ut/python/mindrecord/test_imagenet_to_mindrecord.py View File

@@ -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