Commit c0c696fd authored by Philip Meier's avatar Philip Meier Committed by Francisco Massa
Browse files

Added tests for check_md5 and check_integrity (#873)

* fixed check integrity

* stylistic changes

* added test for check_md5 and check_integrity

* flake8

* fix path to test file if not executed from test folder
parent 25154f99
import os
import shutil
import tempfile
import torch
import torchvision.datasets.utils as utils
import unittest
TEST_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'assets', 'grace_hopper_517x606.jpg')
class Tester(unittest.TestCase):
def test_check_md5(self):
fpath = TEST_FILE
correct_md5 = '9c0bb82894bb3af7f7675ef2b3b6dcdc'
false_md5 = ''
assert utils.check_md5(fpath, correct_md5)
assert not utils.check_md5(fpath, false_md5)
def test_check_integrity(self):
existing_fpath = TEST_FILE
nonexisting_fpath = ''
correct_md5 = '9c0bb82894bb3af7f7675ef2b3b6dcdc'
false_md5 = ''
assert utils.check_integrity(existing_fpath, correct_md5)
assert not utils.check_integrity(existing_fpath, false_md5)
assert utils.check_integrity(existing_fpath)
assert not utils.check_integrity(nonexisting_fpath)
def test_download_url(self):
temp_dir = tempfile.mkdtemp()
url = "http://github.com/pytorch/vision/archive/master.zip"
......
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