未验证 提交 6f8de31d 编写于 作者: W WeiXin 提交者: GitHub

fix test_paddle_save_load and test_paddle_save_load_binary (#32949)

* fix test_paddle_save_load and test_paddle_save_load_binary

* fix unittest:test_paddle_save_load and test_paddle_save_load_binary

* delete *.pyc

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