Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
plyfager committed Dec 13, 2022
1 parent 9cda555 commit 065e2bd
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/data/coco/annotations/captions_train2014.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"annotations": [{"image_id": 9, "caption": "a good meal"}]
}
3 changes: 3 additions & 0 deletions tests/data/coco/annotations/captions_val2014.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"annotations": [{"image_id": 42, "caption": "a pair of slippers"}]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions tests/test_datasets/test_mscoco_dataset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) OpenMMLab. All rights reserved.
import os
from pathlib import Path


from mmedit.datasets import MSCoCoDataset


class TestMSCoCoDatasets:

@classmethod
def setup_class(cls):
cls.data_root = Path(__file__).parent.parent / 'data' / 'coco'

def test_mscoco(self):

# test basic usage
dataset = MSCoCoDataset(data_root=self.data_root, pipeline=[])
assert dataset[0] == dict(
gt_label="a good meal",
img_path=os.path.join(
self.data_root,
'train2014/COCO_train2014_000000000009.jpg'),
sample_idx=0)

# test with different phase
dataset = MSCoCoDataset(
data_root=self.data_root, phase="val", pipeline=[])
assert dataset[0] == dict(
gt_label="a pair of slippers",
img_path=os.path.join(
self.data_root,
'val2014/COCO_val2014_000000000042.jpg'),
sample_idx=0)

0 comments on commit 065e2bd

Please # to comment.