diff --git a/python/paddle/fluid/tests/unittests/test_paddle_save_load.py b/python/paddle/fluid/tests/unittests/test_paddle_save_load.py index 3a5c43b2bab3ed75dda7c2f0e8daabcb73cc786b..be2a6a653cc6f40e6e606200b307c7755a8f9559 100644 --- a/python/paddle/fluid/tests/unittests/test_paddle_save_load.py +++ b/python/paddle/fluid/tests/unittests/test_paddle_save_load.py @@ -412,11 +412,10 @@ class TestSaveLoadAny(unittest.TestCase): ] obj2 = {'k1': obj1, 'k2': state_dict, 'epoch': 123} obj3 = (paddle.randn( - [5, 4], dtype='float32'), np.ndarray( - [3, 4], dtype="float32"), { - "state_dict": state_dict, - "opt": state_dict - }) + [5, 4], dtype='float32'), np.random.randn(3, 4).astype("float32"), { + "state_dict": state_dict, + "opt": state_dict + }) obj4 = (np.random.randn(5, 6), (123, )) path1 = "test_save_load_any_complex_object_dygraph/obj1" diff --git a/python/paddle/fluid/tests/unittests/test_paddle_save_load_binary.py b/python/paddle/fluid/tests/unittests/test_paddle_save_load_binary.py index 8b508d5c9ae79801fa6c0c865650205ca6932b4f..7385da56beab3eb9517e10f7cd6e37741daffbdf 100644 --- a/python/paddle/fluid/tests/unittests/test_paddle_save_load_binary.py +++ b/python/paddle/fluid/tests/unittests/test_paddle_save_load_binary.py @@ -19,6 +19,7 @@ import numpy as np import os import sys import six +import platform import paddle import paddle.nn as nn @@ -162,12 +163,13 @@ class TestSaveLoadBinaryFormat(unittest.TestCase): with self.assertRaises(NotImplementedError): path = 'test_save_load_error/temp' paddle.save({}, path, use_binary_format=True) - - with self.assertRaises(ValueError): - path = 'test_save_load_error/temp' - with open(path, "w") as f: - f.write('\0') - paddle.load(path) + # On the Windows platform, when parsing a string that can't be parsed as a `Program`, `desc_.ParseFromString` has a timeout risk. + if 'Windows' != platform.system(): + with self.assertRaises(ValueError): + path = 'test_save_load_error/temp' + with open(path, "w") as f: + f.write('\0') + paddle.load(path) with self.assertRaises(ValueError): temp_lod = fluid.core.LoDTensor()