def test_cifar100_to_mindrecord(fixture_file): """test transform cifar100 dataset to mindrecord.""" cifar100_transformer = Cifar100ToMR(CIFAR100_DIR, MINDRECORD_FILE) cifar100_transformer.transform(['fine_label', 'coarse_label']) assert os.path.exists(MINDRECORD_FILE) assert os.path.exists(MINDRECORD_FILE + "_test") read()
def test_cifar100_to_mindrecord_without_index_fields(fixture_file): """test transform cifar100 dataset to mindrecord without index fields.""" cifar100_transformer = Cifar100ToMR(CIFAR100_DIR, MINDRECORD_FILE) ret = cifar100_transformer.transform() assert ret == SUCCESS, "Failed to transform from cifar100 to mindrecord" assert os.path.exists(MINDRECORD_FILE) assert os.path.exists(MINDRECORD_FILE + "_test") read()
def test_cifar100_to_mindrecord_illegal_file_name(fixture_file): """ test transform cifar100 dataset to mindrecord when file name contains illegal character. """ filename = "./:no_ok" with pytest.raises(Exception, match="File name should not contains"): cifar100_transformer = Cifar100ToMR(CIFAR100_DIR, filename) cifar100_transformer.transform()
def test_cifar100_to_mindrecord_directory(fixture_file): """ test transform cifar10 dataset to mindrecord when destination path is directory. """ with pytest.raises(MRMOpenError, match="MindRecord File could not open successfully"): cifar100_transformer = Cifar100ToMR(CIFAR100_DIR, CIFAR100_DIR) cifar100_transformer.transform()
def test_cifar100_to_mindrecord_filename_start_with_space(fixture_file): """ test transform cifar10 dataset to mindrecord when file name starts with space. """ filename = "./ no_ok" with pytest.raises(Exception, match="File name should not start/end with space"): cifar100_transformer = Cifar100ToMR(CIFAR100_DIR, filename) cifar100_transformer.transform()
def test_cifar100_to_mindrecord_filename_equals_cifar100(fixture_file): """ test transform cifar10 dataset to mindrecord when destination path equals source path. """ with pytest.raises(MRMOpenError, match="MindRecord File could not open successfully"): cifar100_transformer = Cifar100ToMR(CIFAR100_DIR, CIFAR100_DIR + "/train") cifar100_transformer.transform()
def test_cifar100_to_mindrecord_filename_contain_space(fixture_file): """ test transform cifar10 dataset to mindrecord when file name contains space. """ filename = "./yes ok" cifar100_transformer = Cifar100ToMR(CIFAR100_DIR, filename) cifar100_transformer.transform() assert os.path.exists(filename) assert os.path.exists(filename + "_test")
def test_cifar100_to_mindrecord(): """test transform cifar100 dataset to mindrecord.""" cifar100_transformer = Cifar100ToMR(CIFAR100_DIR, MINDRECORD_FILE) cifar100_transformer.transform(['fine_label', 'coarse_label']) assert os.path.exists(MINDRECORD_FILE) assert os.path.exists(MINDRECORD_FILE + "_test") read() os.remove("{}".format(MINDRECORD_FILE)) os.remove("{}.db".format(MINDRECORD_FILE)) os.remove("{}".format(MINDRECORD_FILE + "_test")) os.remove("{}.db".format(MINDRECORD_FILE + "_test"))
def test_cifar100_to_mindrecord_without_index_fields(): """test transform cifar100 dataset to mindrecord without index fields.""" cifar100_transformer = Cifar100ToMR(CIFAR100_DIR, MINDRECORD_FILE) cifar100_transformer.transform() assert os.path.exists(MINDRECORD_FILE) assert os.path.exists(MINDRECORD_FILE + "_test") read() os.remove("{}".format(MINDRECORD_FILE)) os.remove("{}.db".format(MINDRECORD_FILE)) os.remove("{}".format(MINDRECORD_FILE + "_test")) os.remove("{}.db".format(MINDRECORD_FILE + "_test"))