mirror of
https://github.com/open-mmlab/mmpretrain.git
synced 2025-06-03 14:59:18 +08:00
* Update workflow to add Windows CI * Add some optional requirements to requirements/optional.txt * Update setup.py * Update PyTorch version in Windows CI * Update CI and requirement * Replace `tempfile.NamedTemporaryFile` to avoid unit test error on Windows * Update tests * Update CI * Add OpenCV installation * Update CI
23 lines
809 B
Python
23 lines
809 B
Python
# Copyright (c) OpenMMLab. All rights reserved.
|
|
import os.path as osp
|
|
import random
|
|
import string
|
|
|
|
from mmcls.datasets.utils import check_integrity, rm_suffix
|
|
|
|
|
|
def test_dataset_utils():
|
|
# test rm_suffix
|
|
assert rm_suffix('a.jpg') == 'a'
|
|
assert rm_suffix('a.bak.jpg') == 'a.bak'
|
|
assert rm_suffix('a.bak.jpg', suffix='.jpg') == 'a.bak'
|
|
assert rm_suffix('a.bak.jpg', suffix='.bak.jpg') == 'a'
|
|
|
|
# test check_integrity
|
|
rand_file = ''.join(random.sample(string.ascii_letters, 10))
|
|
assert not check_integrity(rand_file, md5=None)
|
|
assert not check_integrity(rand_file, md5=2333)
|
|
test_file = osp.join(osp.dirname(__file__), '../../data/color.jpg')
|
|
assert check_integrity(test_file, md5='08252e5100cb321fe74e0e12a724ce14')
|
|
assert not check_integrity(test_file, md5=2333)
|