From d8c39f934d331742f6af4c6ef909c6e77eb0c703 Mon Sep 17 00:00:00 2001 From: Slawomir Strehlke Date: Thu, 17 Jun 2021 12:13:06 +0200 Subject: [PATCH 1/3] Updated pytest marking. --- .gitignore | 3 ++- tests/cli/test_image_zip_format.py | 8 ++++---- tests/test_cityscapes_format.py | 14 ++++++++++++++ tests/test_image_zip_format.py | 18 +++++++++--------- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 78d0010336..2b2bf6ca9f 100644 --- a/.gitignore +++ b/.gitignore @@ -57,4 +57,5 @@ cover/ docs/_build/ #Pycharm config files -.idea/ \ No newline at end of file +.idea/ +user_config.py \ No newline at end of file diff --git a/tests/cli/test_image_zip_format.py b/tests/cli/test_image_zip_format.py index da41a2ef33..86f6b6fa1a 100644 --- a/tests/cli/test_image_zip_format.py +++ b/tests/cli/test_image_zip_format.py @@ -10,7 +10,7 @@ from datumaro.components.dataset import Dataset, DatasetItem from datumaro.util.test_utils import TestDir, compare_datasets -from ..requirements import Requirements +from ..requirements import Requirements, mark_requirement def run(test, *args, expected_code=0): @@ -24,7 +24,7 @@ def make_zip_archive(src_path, dst_path): archive.write(path, osp.relpath(path, src_path)) class ImageZipIntegrationScenarios(TestCase): - @pytest.mark.reqids(Requirements.DATUM_267) + @mark_requirement(Requirements.DATUM_267) def test_can_save_and_load(self): source_dataset = Dataset.from_iterable([ DatasetItem(id='1', image=np.ones((5, 5, 3))), @@ -48,7 +48,7 @@ def test_can_save_and_load(self): parsed_dataset = Dataset.import_from(export_path, format='image_zip') compare_datasets(self, source_dataset, parsed_dataset) - @pytest.mark.reqids(Requirements.DATUM_267) + @mark_requirement(Requirements.DATUM_267) def test_can_export_zip_images_from_coco_dataset(self): with TestDir() as test_dir: coco_dir = osp.join(__file__[:__file__.rfind(osp.join('tests', ''))], @@ -67,7 +67,7 @@ def test_can_export_zip_images_from_coco_dataset(self): images = {f.filename for f in zf.filelist} self.assertTrue(images == {'a.jpg', 'b.jpg'}) - @pytest.mark.reqids(Requirements.DATUM_267) + @mark_requirement(Requirements.DATUM_267) def test_can_change_extension_for_images_in_zip(self): source_dataset = Dataset.from_iterable([ DatasetItem(id='1', image=np.ones((5, 5, 3))), diff --git a/tests/test_cityscapes_format.py b/tests/test_cityscapes_format.py index fd23de9d76..cbfde88567 100644 --- a/tests/test_cityscapes_format.py +++ b/tests/test_cityscapes_format.py @@ -13,11 +13,13 @@ from datumaro.util.image import Image from datumaro.util.test_utils import (TestDir, compare_datasets, test_save_and_load) +from .requirements import Requirements, mark_requirement DUMMY_DATASET_DIR = osp.join(osp.dirname(__file__), 'assets', 'cityscapes_dataset') class CityscapesFormatTest(TestCase): + @mark_requirement(Requirements.DATUM_267) def test_can_write_and_parse_labelmap(self): src_label_map = Cityscapes.CityscapesLabelMap @@ -30,6 +32,7 @@ def test_can_write_and_parse_labelmap(self): self.assertEqual(src_label_map, dst_label_map) class CityscapesImportTest(TestCase): + @mark_requirement(Requirements.DATUM_267) def test_can_import(self): source_dataset = Dataset.from_iterable([ DatasetItem(id='defaultcity/defaultcity_000001_000031', @@ -82,6 +85,7 @@ def test_can_import(self): compare_datasets(self, source_dataset, parsed_dataset) + @mark_requirement(Requirements.DATUM_267) def test_can_detect_cityscapes(self): self.assertTrue(CityscapesImporter.detect(DUMMY_DATASET_DIR)) @@ -100,6 +104,7 @@ def _test_save_and_load(self, source_dataset, converter, test_dir, importer='cityscapes', target_dataset=target_dataset, importer_args=importer_args, **kwargs) + @mark_requirement(Requirements.DATUM_267) def test_can_save_cityscapes_segm(self): class TestExtractor(TestExtractorBase): def __iter__(self): @@ -126,6 +131,7 @@ def __iter__(self): partial(CityscapesConverter.convert, label_map='cityscapes', save_images=True), test_dir) + @mark_requirement(Requirements.DATUM_267) def test_can_save_cityscapes_segm_unpainted(self): class TestExtractor(TestExtractorBase): def __iter__(self): @@ -146,6 +152,7 @@ def __iter__(self): partial(CityscapesConverter.convert, label_map='cityscapes', save_images=True, apply_colormap=False), test_dir) + @mark_requirement(Requirements.DATUM_267) def test_can_save_cityscapes_dataset_with_no_subsets(self): class TestExtractor(TestExtractorBase): def __iter__(self): @@ -172,6 +179,7 @@ def __iter__(self): partial(CityscapesConverter.convert, label_map='cityscapes', save_images=True), test_dir) + @mark_requirement(Requirements.DATUM_267) def test_can_save_cityscapes_dataset_without_frame_and_sequence(self): class TestExtractor(TestExtractorBase): def __iter__(self): @@ -189,6 +197,7 @@ def __iter__(self): partial(CityscapesConverter.convert, label_map='cityscapes', save_images=True), test_dir) + @mark_requirement(Requirements.DATUM_267) def test_can_save_dataset_with_cyrillic_and_spaces_in_filename(self): class TestExtractor(TestExtractorBase): def __iter__(self): @@ -207,6 +216,7 @@ def __iter__(self): partial(CityscapesConverter.convert, label_map='cityscapes', save_images=True), test_dir) + @mark_requirement(Requirements.DATUM_267) def test_can_save_cityscapes_dataset_with_strange_id(self): class TestExtractor(TestExtractorBase): def __iter__(self): @@ -225,6 +235,7 @@ def __iter__(self): partial(CityscapesConverter.convert, label_map='cityscapes', save_images=True), test_dir) + @mark_requirement(Requirements.DATUM_267) def test_can_save_with_no_masks(self): class TestExtractor(TestExtractorBase): def __iter__(self): @@ -239,6 +250,7 @@ def __iter__(self): partial(CityscapesConverter.convert, label_map='cityscapes', save_images=True), test_dir) + @mark_requirement(Requirements.DATUM_267) def test_dataset_with_source_labelmap_undefined(self): class SrcExtractor(TestExtractorBase): def __iter__(self): @@ -281,6 +293,7 @@ def categories(self): partial(CityscapesConverter.convert, label_map='source', save_images=True), test_dir, target_dataset=DstExtractor()) + @mark_requirement(Requirements.DATUM_267) def test_dataset_with_source_labelmap_defined(self): class SrcExtractor(TestExtractorBase): def __iter__(self): @@ -321,6 +334,7 @@ def categories(self): partial(CityscapesConverter.convert, label_map='source', save_images=True), test_dir, target_dataset=DstExtractor()) + @mark_requirement(Requirements.DATUM_267) def test_can_save_and_load_image_with_arbitrary_extension(self): class TestExtractor(TestExtractorBase): def __iter__(self): diff --git a/tests/test_image_zip_format.py b/tests/test_image_zip_format.py index 4de5ad37f8..e366279772 100644 --- a/tests/test_image_zip_format.py +++ b/tests/test_image_zip_format.py @@ -10,11 +10,11 @@ from datumaro.util.image import Image, save_image from datumaro.util.test_utils import TestDir, compare_datasets -from .requirements import Requirements +from .requirements import Requirements, mark_requirement class ImageZipConverterTest(TestCase): - @pytest.mark.reqids(Requirements.DATUM_267) + @mark_requirement(Requirements.DATUM_267) def _test_can_save_and_load(self, source_dataset, test_dir, **kwargs): archive_path = osp.join(test_dir, kwargs.get('name', @@ -24,7 +24,7 @@ def _test_can_save_and_load(self, source_dataset, test_dir, compare_datasets(self, source_dataset, parsed_dataset) - @pytest.mark.reqids(Requirements.DATUM_267) + @mark_requirement(Requirements.DATUM_267) def test_can_save_and_load(self): source_dataset = Dataset.from_iterable([ DatasetItem(id='1', image=np.ones((10, 6, 3))), @@ -34,7 +34,7 @@ def test_can_save_and_load(self): with TestDir() as test_dir: self._test_can_save_and_load(source_dataset, test_dir) - @pytest.mark.reqids(Requirements.DATUM_267) + @mark_requirement(Requirements.DATUM_267) def test_can_save_and_load_with_custom_archive_name(self): source_dataset = Dataset.from_iterable([ DatasetItem(id='img_1', image=np.ones((10, 10, 3))), @@ -44,7 +44,7 @@ def test_can_save_and_load_with_custom_archive_name(self): self._test_can_save_and_load(source_dataset, test_dir, name='my_archive.zip') - @pytest.mark.reqids(Requirements.DATUM_267) + @mark_requirement(Requirements.DATUM_267) def test_relative_paths(self): source_dataset = Dataset.from_iterable([ DatasetItem(id='1', image=np.ones((10, 10, 3))), @@ -55,7 +55,7 @@ def test_relative_paths(self): with TestDir() as test_dir: self._test_can_save_and_load(source_dataset, test_dir) - @pytest.mark.reqids(Requirements.DATUM_267) + @mark_requirement(Requirements.DATUM_267) def test_can_save_and_load_custom_compresion_method(self): source_dataset = Dataset.from_iterable([ DatasetItem(id='1', image=np.ones((5, 5, 3))), @@ -66,7 +66,7 @@ def test_can_save_and_load_custom_compresion_method(self): self._test_can_save_and_load(source_dataset, test_dir, compression='ZIP_DEFLATED') - @pytest.mark.reqids(Requirements.DATUM_267) + @mark_requirement(Requirements.DATUM_267) def test_can_save_and_load_with_arbitrary_extensions(self): source_dataset = Dataset.from_iterable([ DatasetItem(id='subset/1', @@ -87,7 +87,7 @@ def test_can_save_and_load_with_arbitrary_extensions(self): DUMMY_DATASET_DIR = osp.join(osp.dirname(__file__), 'assets', 'image_zip_dataset') class ImageZipImporterTest(TestCase): - @pytest.mark.reqids(Requirements.DATUM_267) + @mark_requirement(Requirements.DATUM_267) def test_can_import(self): source_dataset = Dataset.from_iterable([ DatasetItem(id='1', image=np.ones((10, 10, 3))) @@ -98,7 +98,7 @@ def test_can_import(self): compare_datasets(self, source_dataset, parsed_dataset) - @pytest.mark.reqids(Requirements.DATUM_267) + @mark_requirement(Requirements.DATUM_267) def test_can_import_from_directory(self): source_dataset = Dataset.from_iterable([ DatasetItem(id='1', image=np.ones((10, 10, 3))), From 5975166ca58c4a6bb5fc863d2388f2840fddb19a Mon Sep 17 00:00:00 2001 From: Slawomir Strehlke Date: Thu, 17 Jun 2021 13:13:54 +0200 Subject: [PATCH 2/3] Updated CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32c27abf99..d8afc4d202 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Subformat importers for VOC and COCO () - Support for KITTI dataset segmentation and detection format () - Updated YOLO format user manual () +- Updated test marking for cityscapes format and zip archives with images ### Changed - From d59cd404f8ff8f2566bb961ce12955a51a0dc570 Mon Sep 17 00:00:00 2001 From: Maxim Zhiltsov Date: Fri, 18 Jun 2021 11:25:59 +0300 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8afc4d202..32c27abf99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Subformat importers for VOC and COCO () - Support for KITTI dataset segmentation and detection format () - Updated YOLO format user manual () -- Updated test marking for cityscapes format and zip archives with images ### Changed -