"vscode:/vscode.git/clone" did not exist on "4903d3cc9deeece7b28024971d1279f4f085d83e"
Unverified Commit 174e135d authored by Francisco Massa's avatar Francisco Massa Committed by GitHub
Browse files

Make test_save_image more robust (#1037)

parent 3b8a1403
import os
import tempfile
import torch
import torchvision.utils as utils
import unittest
......@@ -37,11 +38,10 @@ class Tester(unittest.TestCase):
assert torch.equal(norm_min, rounded_grid_min), 'Normalized min is not equal to 0'
def test_save_image(self):
with tempfile.NamedTemporaryFile(suffix='.png') as f:
t = torch.rand(2, 3, 64, 64)
file_name = 'test_image.png'
utils.save_image(t, file_name)
assert os.path.exists(file_name), 'The image is not present after save'
os.remove(file_name)
utils.save_image(t, f.name)
assert os.path.exists(f.name), 'The image is not present after save'
if __name__ == '__main__':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment