Fix error message of load_inference_model (#24314)

* fix error message, test=develop

* add unittest, test=develop
revert-24314-dev/fix_err_msg
Leo Chen 5 years ago committed by GitHub
parent c1df7048c7
commit 5b285470db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1371,7 +1371,7 @@ def load_inference_model(dirname,
if dirname is not None:
load_dirname = os.path.normpath(dirname)
if not os.path.isdir(load_dirname):
raise ValueError("There is no directory named '%s'", dirname)
raise ValueError("There is no directory named '%s'" % dirname)
if model_filename is None:
model_filename = '__model__'

@ -192,5 +192,13 @@ class TestInstance(unittest.TestCase):
[MODEL_DIR, ["x", "y"], [avg_cost], [], cp_prog])
class TestLoadInferenceModelError(unittest.TestCase):
def test_load_model_not_exist(self):
place = core.CPUPlace()
exe = executor.Executor(place)
self.assertRaises(ValueError, load_inference_model,
'./test_not_exist_dir', exe)
if __name__ == '__main__':
unittest.main()

Loading…
Cancel
Save