forked from open-mmlab/mmpretrain
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Refactor] Refactor unittest (open-mmlab#321)
* Refactor unit tests folder structure. * Remove label smooth and Vit test in `test_classifiers.py` * Rename test_utils in dataset to test_dataset_utils * Split test_models/test_utils/test_utils.py to multiple sub files. * Add unit tests of classifiers and heads * Use patch context manager. * Add unit test of `is_tracing`, and add warning in `is_tracing` if torch verison is smaller than 1.6.0
- Loading branch information
Showing
34 changed files
with
502 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import random | ||
import string | ||
import tempfile | ||
|
||
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) | ||
tmp_file = tempfile.NamedTemporaryFile() | ||
assert check_integrity(tmp_file.name, md5=None) | ||
assert not check_integrity(tmp_file.name, md5=2333) |
Oops, something went wrong.