Skip to content

Commit

Permalink
Fix VOC unit test not to remove data directory (open-mmlab#7270)
Browse files Browse the repository at this point in the history
* Fix VOC unit test not to remove data directory

* Fix CI
  • Loading branch information
shinya7y authored Mar 1, 2022
1 parent 01e67b8 commit 01b55b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
mmcv: 1.9
- torch: 1.10.1
torchvision: 0.11.2
mmcv: 1.10
mmcv: "1.10"
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:
- torch: 1.10.1+cu102
torch_version: torch1.10.1
torchvision: 0.11.2+cu102
mmcv: 1.10
mmcv: "1.10"

steps:
- uses: actions/checkout@v2
Expand Down
18 changes: 3 additions & 15 deletions tests/test_data/test_datasets/test_common.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Copyright (c) OpenMMLab. All rights reserved.
import copy
import logging
import os
import os.path as osp
import platform
import shutil
import tempfile
from unittest.mock import MagicMock, patch

Expand Down Expand Up @@ -106,26 +103,17 @@ def _create_dummy_results():

@pytest.mark.parametrize('config_path',
['./configs/_base_/datasets/voc0712.py'])
def test_dataset_init(config_path):
use_symlink = False
if not os.path.exists('./data'):
if platform.system() != 'Windows':
os.symlink('./tests/data', './data')
use_symlink = True
else:
shutil.copytree('./tests/data', './data')
def test_dataset_init(config_path, monkeypatch):
data_config = mmcv.Config.fromfile(config_path)
if 'data' not in data_config:
return

monkeypatch.chdir('./tests/') # to use ./tests/data
stage_names = ['train', 'val', 'test']
for stage_name in stage_names:
dataset_config = copy.deepcopy(data_config.data.get(stage_name))
dataset = build_dataset(dataset_config)
dataset[0]
if use_symlink:
os.unlink('./data')
else:
shutil.rmtree('./data')


def test_dataset_evaluation():
Expand Down

0 comments on commit 01b55b2

Please sign in to comment.