diff --git a/python/paddle/fluid/io.py b/python/paddle/fluid/io.py index 5a75331e1d93f51cfd609ded03c360e8926e4cb3..d7e194c24d1c5b64a5b4b6769602e10fdd2b997d 100644 --- a/python/paddle/fluid/io.py +++ b/python/paddle/fluid/io.py @@ -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__' diff --git a/python/paddle/fluid/tests/unittests/test_inference_model_io.py b/python/paddle/fluid/tests/unittests/test_inference_model_io.py index f9408dfee5393a71f8b2fc3cc6fa229500c302dc..5d3d536100b74e69de70abcecdf1e3b9893c3a15 100644 --- a/python/paddle/fluid/tests/unittests/test_inference_model_io.py +++ b/python/paddle/fluid/tests/unittests/test_inference_model_io.py @@ -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()