Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiltsov-max committed Feb 26, 2025
1 parent 0e19fde commit e11bda3
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion tests/integration/cli/test_detect_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import os
import os.path as osp
from pathlib import Path
import shutil
from typing import List
from unittest.case import TestCase
Expand All @@ -11,7 +12,7 @@
from datumaro.plugins.data_formats.ade20k2020 import Ade20k2020Importer
from datumaro.plugins.data_formats.camvid import CamvidImporter
from datumaro.plugins.data_formats.lfw import LfwImporter
from datumaro.util.os_util import suppress_output
from datumaro.util.os_util import SPECIAL_MACOS_FOLDERS, is_subpath, suppress_output

from tests.requirements import Requirements, mark_requirement
from tests.utils.assets import get_test_asset_path
Expand Down Expand Up @@ -77,6 +78,29 @@ def test_nested_folders(self):

self.assertEqual([Ade20k2020Importer.NAME], output)

@mark_requirement(Requirements.DATUM_GENERAL_REQ)
def test_can_ignore_special_dirs_in_nested_folders(self):
with TestDir() as test_dir:
output_file = io.StringIO()

annotation_dir = osp.join(test_dir, "a", "b", "c", "annotations")
os.makedirs(annotation_dir)
shutil.copy(osp.join(LFW_DIR, "test", "annotations", "pairs.txt"), annotation_dir)

for subdir_path in Path(annotation_dir).parents:
if not is_subpath(str(subdir_path), test_dir):
continue

for special_dir_name in SPECIAL_MACOS_FOLDERS:
(subdir_path / special_dir_name).mkdir(exist_ok=True)

with contextlib.redirect_stdout(output_file):
run(self, "detect", test_dir, "--depth", "3")

output = self._extract_detect_format_name(output_file)

self.assertEqual([LfwImporter.NAME], output)

@mark_requirement(Requirements.DATUM_GENERAL_REQ)
def test_ambiguous(self):
with TestDir() as test_dir:
Expand Down

0 comments on commit e11bda3

Please sign in to comment.