未验证 提交 5b285470 编写于 作者: L Leo Chen 提交者: GitHub

Fix error message of load_inference_model (#24314)

* fix error message, test=develop

* add unittest, test=develop
上级 c1df7048
......@@ -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()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册