From a2a461136a5da95bd84faefe54d9fded7bd7a86e Mon Sep 17 00:00:00 2001 From: PhilipGutberlet <92990487+PhilipGutberlet@users.noreply.github.com> Date: Fri, 30 Jun 2023 16:02:11 +0200 Subject: [PATCH 01/12] added the missing ids in parameterized tests --- tests/safeds/data/tabular/transformation/test_imputer.py | 1 + tests/safeds/data/tabular/transformation/test_label_encoder.py | 2 ++ tests/safeds/data/tabular/transformation/test_range_scaler.py | 2 ++ .../safeds/data/tabular/transformation/test_standard_scaler.py | 2 ++ tests/safeds/ml/classical/regression/test_regressor.py | 1 + 5 files changed, 8 insertions(+) diff --git a/tests/safeds/data/tabular/transformation/test_imputer.py b/tests/safeds/data/tabular/transformation/test_imputer.py index 73f667caa..91bcad68e 100644 --- a/tests/safeds/data/tabular/transformation/test_imputer.py +++ b/tests/safeds/data/tabular/transformation/test_imputer.py @@ -30,6 +30,7 @@ class TestStr: (Imputer.Strategy.Median(), "Median"), (Imputer.Strategy.Mode(), "Mode"), ], + ids=["Constant", "Mean", "Median", "Mode"], ) def test_should_return_correct_string_representation(self, strategy: ImputerStrategy, expected: str) -> None: assert str(strategy) == expected diff --git a/tests/safeds/data/tabular/transformation/test_label_encoder.py b/tests/safeds/data/tabular/transformation/test_label_encoder.py index be5668eb3..57614335d 100644 --- a/tests/safeds/data/tabular/transformation/test_label_encoder.py +++ b/tests/safeds/data/tabular/transformation/test_label_encoder.py @@ -130,6 +130,7 @@ class TestFitAndTransform: ), ), ], + ids=["no_column_names", "with_column_names"], ) def test_should_return_transformed_table( self, @@ -205,6 +206,7 @@ class TestInverseTransform: }, ), ], + ids=["no_column_names"], ) def test_should_return_original_table(self, table: Table) -> None: transformer = LabelEncoder().fit(table, None) diff --git a/tests/safeds/data/tabular/transformation/test_range_scaler.py b/tests/safeds/data/tabular/transformation/test_range_scaler.py index cfa82029c..5d8e1dde6 100644 --- a/tests/safeds/data/tabular/transformation/test_range_scaler.py +++ b/tests/safeds/data/tabular/transformation/test_range_scaler.py @@ -142,6 +142,7 @@ class TestFitAndTransform: ), ), ], + ids=["one_column", "two_columns"], ) def test_should_return_transformed_table( self, @@ -183,6 +184,7 @@ def test_should_return_transformed_table( ), ), ], + ids=["one_column", "two_columns"], ) def test_should_return_transformed_table_with_correct_range( self, diff --git a/tests/safeds/data/tabular/transformation/test_standard_scaler.py b/tests/safeds/data/tabular/transformation/test_standard_scaler.py index 11b887bf5..68361f064 100644 --- a/tests/safeds/data/tabular/transformation/test_standard_scaler.py +++ b/tests/safeds/data/tabular/transformation/test_standard_scaler.py @@ -143,6 +143,7 @@ class TestFitAndTransformOnMultipleTables: ), ), ], + ids=["two columns"], ) def test_should_return_transformed_tables( self, @@ -224,6 +225,7 @@ class TestInverseTransform: }, ), ], + ids=["one column"], ) def test_should_return_original_table(self, table: Table) -> None: transformer = StandardScaler().fit(table, None) diff --git a/tests/safeds/ml/classical/regression/test_regressor.py b/tests/safeds/ml/classical/regression/test_regressor.py index 7179d6781..5f75a399a 100644 --- a/tests/safeds/ml/classical/regression/test_regressor.py +++ b/tests/safeds/ml/classical/regression/test_regressor.py @@ -346,6 +346,7 @@ class TestMeanSquaredError: @pytest.mark.parametrize( ("predicted", "expected", "result"), [([1, 2], [1, 2], 0), ([0, 0], [1, 1], 1), ([1, 1, 1], [2, 2, 11], 34)], + ids=["perfect_prediction", "bad_prediction", "worst_prediction"], ) def test_valid_data(self, predicted: list[float], expected: list[float], result: float) -> None: table = Table({"predicted": predicted, "expected": expected}).tag_columns( From 30f5bae3fc9dff2699ff4d6723de7dfc96fa98d6 Mon Sep 17 00:00:00 2001 From: daniaHu <129186516+daniaHu@users.noreply.github.com> Date: Fri, 30 Jun 2023 16:22:54 +0200 Subject: [PATCH 02/12] Update tests/safeds/data/tabular/transformation/test_standard_scaler.py Co-authored-by: Junior Atemebang <129027012+jxnior01@users.noreply.github.com> --- .../safeds/data/tabular/transformation/test_standard_scaler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/safeds/data/tabular/transformation/test_standard_scaler.py b/tests/safeds/data/tabular/transformation/test_standard_scaler.py index 68361f064..f109f05e4 100644 --- a/tests/safeds/data/tabular/transformation/test_standard_scaler.py +++ b/tests/safeds/data/tabular/transformation/test_standard_scaler.py @@ -143,7 +143,7 @@ class TestFitAndTransformOnMultipleTables: ), ), ], - ids=["two columns"], + ids=["two_columns"], ) def test_should_return_transformed_tables( self, From ee2eb3caff2783a96f48e746161954eaa5d1bc43 Mon Sep 17 00:00:00 2001 From: daniaHu <129186516+daniaHu@users.noreply.github.com> Date: Fri, 30 Jun 2023 16:23:02 +0200 Subject: [PATCH 03/12] Update tests/safeds/data/tabular/transformation/test_standard_scaler.py Co-authored-by: Junior Atemebang <129027012+jxnior01@users.noreply.github.com> --- .../safeds/data/tabular/transformation/test_standard_scaler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/safeds/data/tabular/transformation/test_standard_scaler.py b/tests/safeds/data/tabular/transformation/test_standard_scaler.py index f109f05e4..e11069d5b 100644 --- a/tests/safeds/data/tabular/transformation/test_standard_scaler.py +++ b/tests/safeds/data/tabular/transformation/test_standard_scaler.py @@ -225,7 +225,7 @@ class TestInverseTransform: }, ), ], - ids=["one column"], + ids=["one_column"], ) def test_should_return_original_table(self, table: Table) -> None: transformer = StandardScaler().fit(table, None) From ccc6a441d4dc30e898a6817b27283b0fc669c15e Mon Sep 17 00:00:00 2001 From: PhilipGutberlet <92990487+PhilipGutberlet@users.noreply.github.com> Date: Fri, 7 Jul 2023 09:37:59 +0200 Subject: [PATCH 04/12] added missing ids --- .../safeds/data/image/containers/test_image.py | 17 +++++++++++++++-- .../containers/_table/test_slice_rows.py | 1 + .../tabular/containers/_table/test_sort_rows.py | 2 ++ .../tabular/containers/_table/test_to_dict.py | 1 + .../containers/_table/test_transform_table.py | 1 + 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/safeds/data/image/containers/test_image.py b/tests/safeds/data/image/containers/test_image.py index ee1d1cfc3..90bd7f434 100644 --- a/tests/safeds/data/image/containers/test_image.py +++ b/tests/safeds/data/image/containers/test_image.py @@ -13,6 +13,7 @@ class TestFromJpegFile: @pytest.mark.parametrize( "path", ["image/white_square.jpg", Path("image/white_square.jpg")], + ids=["white_square_jpg", "white_square_jpg,"], ) def test_should_load_jpeg_file(self, path: str | Path) -> None: Image.from_jpeg_file(resolve_resource_path(path)) @@ -20,6 +21,7 @@ def test_should_load_jpeg_file(self, path: str | Path) -> None: @pytest.mark.parametrize( "path", ["image/missing_file.jpg", Path("image/missing_file.jpg")], + ids=["missing_file_jpg",], ) def test_should_raise_if_file_not_found(self, path: str | Path) -> None: with pytest.raises(FileNotFoundError): @@ -30,6 +32,7 @@ class TestFromPngFile: @pytest.mark.parametrize( "path", ["image/white_square.png", Path("image/white_square.png")], + ids=["white_square_png"], ) def test_should_load_png_file(self, path: str | Path) -> None: Image.from_png_file(resolve_resource_path(path)) @@ -37,6 +40,7 @@ def test_should_load_png_file(self, path: str | Path) -> None: @pytest.mark.parametrize( "path", ["image/missing_file.png", Path("image/missing_file.png")], + ids=["missing_file_png"] ) def test_should_raise_if_file_not_found(self, path: str | Path) -> None: with pytest.raises(FileNotFoundError): @@ -50,6 +54,7 @@ class TestFormat: (Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg")), ImageFormat.JPEG), (Image.from_png_file(resolve_resource_path("image/white_square.png")), ImageFormat.PNG), ], + ids=["jpg","png"] ) def test_should_return_correct_format(self, image: Image, format_: ImageFormat) -> None: assert image.format == format_ @@ -97,6 +102,7 @@ def test_should_save_jpeg_file_by_str(self, path: str) -> None: @pytest.mark.parametrize( "path", ["image/white_square.jpg"], + ids=["jpg"] ) def test_should_save_jpeg_file_by_path(self, path: str) -> None: image = Image.from_jpeg_file(resolve_resource_path(path)) @@ -115,7 +121,9 @@ class TestToPngFile: @pytest.mark.parametrize( "path", ["image/white_square.png"], + ids=["png"] ) + def test_should_save_png_file_by_str(self, path: str) -> None: image = Image.from_png_file(resolve_resource_path(path)) @@ -131,6 +139,7 @@ def test_should_save_png_file_by_str(self, path: str) -> None: @pytest.mark.parametrize( "path", ["image/white_square.png"], + ids=["png"] ) def test_should_save_png_file_by_path(self, path: str) -> None: image = Image.from_png_file(resolve_resource_path(path)) @@ -149,6 +158,7 @@ class TestReprJpeg: @pytest.mark.parametrize( "image", [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], + ids=["jpg"] ) def test_should_return_bytes_if_image_is_jpeg(self, image: Image) -> None: assert isinstance(image._repr_jpeg_(), bytes) @@ -156,6 +166,7 @@ def test_should_return_bytes_if_image_is_jpeg(self, image: Image) -> None: @pytest.mark.parametrize( "image", [Image.from_png_file(resolve_resource_path("image/white_square.png"))], + ids=["png"] ) def test_should_return_none_if_image_is_not_jpeg(self, image: Image) -> None: assert image._repr_jpeg_() is None @@ -165,6 +176,7 @@ class TestReprPng: @pytest.mark.parametrize( "image", [Image.from_png_file(resolve_resource_path("image/white_square.png"))], + ids=["png"] ) def test_should_return_bytes_if_image_is_png(self, image: Image) -> None: assert isinstance(image._repr_png_(), bytes) @@ -172,6 +184,7 @@ def test_should_return_bytes_if_image_is_png(self, image: Image) -> None: @pytest.mark.parametrize( "image", [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], + ids=["jpg"] ) def test_should_return_none_if_image_is_not_png(self, image: Image) -> None: assert image._repr_png_() is None @@ -262,7 +275,7 @@ def test_should_be_original(self) -> None: class TestAdjustContrast: - @pytest.mark.parametrize("factor", [0.75, 5]) + @pytest.mark.parametrize("factor", [0.75, 5], ids=["factor"]) def test_should_adjust_contrast(self, factor: float) -> None: image = Image.from_png_file(resolve_resource_path("image/contrast/to_adjust_contrast.png")) image2 = image.adjust_contrast(factor) @@ -288,7 +301,7 @@ def test_should_raise(self) -> None: class TestBrightness: - @pytest.mark.parametrize("factor", [0.5, 10]) + @pytest.mark.parametrize("factor", [0.5, 10], ids=["factor"]) def test_should_adjust_brightness(self, factor: float) -> None: image = Image.from_png_file(resolve_resource_path("image/brightness/to_brighten.png")) image2 = image.adjust_brightness(factor) diff --git a/tests/safeds/data/tabular/containers/_table/test_slice_rows.py b/tests/safeds/data/tabular/containers/_table/test_slice_rows.py index 065b0a67a..fc4020d4c 100644 --- a/tests/safeds/data/tabular/containers/_table/test_slice_rows.py +++ b/tests/safeds/data/tabular/containers/_table/test_slice_rows.py @@ -36,6 +36,7 @@ def test_should_slice_rows(table: Table, test_table: Table, second_test_table: T (-4, 0, 1, r"There is no element at index '-4'"), (0, -4, 1, r"There is no element in the range \[0, -4\]"), ], + ids=["Start > End", "Start > Length", "End > Length", "Start < 0", "End < 0", "Start > End > 0"] ) def test_should_raise_if_index_out_of_bounds(start: int, end: int, step: int, error_message: str) -> None: table = Table({"col1": [1, 2, 1], "col2": [1, 2, 4]}) diff --git a/tests/safeds/data/tabular/containers/_table/test_sort_rows.py b/tests/safeds/data/tabular/containers/_table/test_sort_rows.py index dbb0dbfa6..600e5157f 100644 --- a/tests/safeds/data/tabular/containers/_table/test_sort_rows.py +++ b/tests/safeds/data/tabular/containers/_table/test_sort_rows.py @@ -14,6 +14,7 @@ Table({"col1": [1, 2, 3]}), ), ], + ids=["Table with three rows"], ) def test_should_return_sorted_table( table: Table, @@ -34,6 +35,7 @@ def test_should_return_sorted_table( Table({"col1": [3, 2, 1]}), ), ], + ids=["Table with three rows"], ) def test_should_not_modify_original_table( table: Table, diff --git a/tests/safeds/data/tabular/containers/_table/test_to_dict.py b/tests/safeds/data/tabular/containers/_table/test_to_dict.py index a9c173ac6..b6f7e16f0 100644 --- a/tests/safeds/data/tabular/containers/_table/test_to_dict.py +++ b/tests/safeds/data/tabular/containers/_table/test_to_dict.py @@ -24,6 +24,7 @@ }, ), ], + ids=["Empty table", "Table with one row"], ) def test_should_return_dict_for_table(table: Table, expected: dict[str, list[Any]]) -> None: assert table.to_dict() == expected diff --git a/tests/safeds/data/tabular/containers/_table/test_transform_table.py b/tests/safeds/data/tabular/containers/_table/test_transform_table.py index 52bb294f6..eccae6b0f 100644 --- a/tests/safeds/data/tabular/containers/_table/test_transform_table.py +++ b/tests/safeds/data/tabular/containers/_table/test_transform_table.py @@ -94,6 +94,7 @@ def test_should_return_transformed_table( ), Table(), ], + ids=["non-empty table", "empty table"], ) def test_should_raise_if_column_not_found(table_to_fit: Table) -> None: table_to_fit = Table( From 236b1c12738a7accb8e15e3d3f2fadc676fd2097 Mon Sep 17 00:00:00 2001 From: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com> Date: Fri, 7 Jul 2023 07:44:39 +0000 Subject: [PATCH 05/12] style: apply automated linter fixes --- .../data/image/containers/test_image.py | 45 +++++-------------- .../containers/_table/test_slice_rows.py | 2 +- 2 files changed, 13 insertions(+), 34 deletions(-) diff --git a/tests/safeds/data/image/containers/test_image.py b/tests/safeds/data/image/containers/test_image.py index 90bd7f434..92cf6925c 100644 --- a/tests/safeds/data/image/containers/test_image.py +++ b/tests/safeds/data/image/containers/test_image.py @@ -21,7 +21,9 @@ def test_should_load_jpeg_file(self, path: str | Path) -> None: @pytest.mark.parametrize( "path", ["image/missing_file.jpg", Path("image/missing_file.jpg")], - ids=["missing_file_jpg",], + ids=[ + "missing_file_jpg", + ], ) def test_should_raise_if_file_not_found(self, path: str | Path) -> None: with pytest.raises(FileNotFoundError): @@ -38,9 +40,7 @@ def test_should_load_png_file(self, path: str | Path) -> None: Image.from_png_file(resolve_resource_path(path)) @pytest.mark.parametrize( - "path", - ["image/missing_file.png", Path("image/missing_file.png")], - ids=["missing_file_png"] + "path", ["image/missing_file.png", Path("image/missing_file.png")], ids=["missing_file_png"], ) def test_should_raise_if_file_not_found(self, path: str | Path) -> None: with pytest.raises(FileNotFoundError): @@ -54,7 +54,7 @@ class TestFormat: (Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg")), ImageFormat.JPEG), (Image.from_png_file(resolve_resource_path("image/white_square.png")), ImageFormat.PNG), ], - ids=["jpg","png"] + ids=["jpg", "png"], ) def test_should_return_correct_format(self, image: Image, format_: ImageFormat) -> None: assert image.format == format_ @@ -99,11 +99,7 @@ def test_should_save_jpeg_file_by_str(self, path: str) -> None: assert image._image.tobytes() == image_read_back._image.tobytes() - @pytest.mark.parametrize( - "path", - ["image/white_square.jpg"], - ids=["jpg"] - ) + @pytest.mark.parametrize("path", ["image/white_square.jpg"], ids=["jpg"]) def test_should_save_jpeg_file_by_path(self, path: str) -> None: image = Image.from_jpeg_file(resolve_resource_path(path)) @@ -118,12 +114,7 @@ def test_should_save_jpeg_file_by_path(self, path: str) -> None: class TestToPngFile: - @pytest.mark.parametrize( - "path", - ["image/white_square.png"], - ids=["png"] - ) - + @pytest.mark.parametrize("path", ["image/white_square.png"], ids=["png"]) def test_should_save_png_file_by_str(self, path: str) -> None: image = Image.from_png_file(resolve_resource_path(path)) @@ -136,11 +127,7 @@ def test_should_save_png_file_by_str(self, path: str) -> None: assert image._image.tobytes() == image_read_back._image.tobytes() - @pytest.mark.parametrize( - "path", - ["image/white_square.png"], - ids=["png"] - ) + @pytest.mark.parametrize("path", ["image/white_square.png"], ids=["png"]) def test_should_save_png_file_by_path(self, path: str) -> None: image = Image.from_png_file(resolve_resource_path(path)) @@ -156,17 +143,13 @@ def test_should_save_png_file_by_path(self, path: str) -> None: class TestReprJpeg: @pytest.mark.parametrize( - "image", - [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], - ids=["jpg"] + "image", [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], ids=["jpg"], ) def test_should_return_bytes_if_image_is_jpeg(self, image: Image) -> None: assert isinstance(image._repr_jpeg_(), bytes) @pytest.mark.parametrize( - "image", - [Image.from_png_file(resolve_resource_path("image/white_square.png"))], - ids=["png"] + "image", [Image.from_png_file(resolve_resource_path("image/white_square.png"))], ids=["png"], ) def test_should_return_none_if_image_is_not_jpeg(self, image: Image) -> None: assert image._repr_jpeg_() is None @@ -174,17 +157,13 @@ def test_should_return_none_if_image_is_not_jpeg(self, image: Image) -> None: class TestReprPng: @pytest.mark.parametrize( - "image", - [Image.from_png_file(resolve_resource_path("image/white_square.png"))], - ids=["png"] + "image", [Image.from_png_file(resolve_resource_path("image/white_square.png"))], ids=["png"], ) def test_should_return_bytes_if_image_is_png(self, image: Image) -> None: assert isinstance(image._repr_png_(), bytes) @pytest.mark.parametrize( - "image", - [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], - ids=["jpg"] + "image", [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], ids=["jpg"], ) def test_should_return_none_if_image_is_not_png(self, image: Image) -> None: assert image._repr_png_() is None diff --git a/tests/safeds/data/tabular/containers/_table/test_slice_rows.py b/tests/safeds/data/tabular/containers/_table/test_slice_rows.py index fc4020d4c..af11a59c5 100644 --- a/tests/safeds/data/tabular/containers/_table/test_slice_rows.py +++ b/tests/safeds/data/tabular/containers/_table/test_slice_rows.py @@ -36,7 +36,7 @@ def test_should_slice_rows(table: Table, test_table: Table, second_test_table: T (-4, 0, 1, r"There is no element at index '-4'"), (0, -4, 1, r"There is no element in the range \[0, -4\]"), ], - ids=["Start > End", "Start > Length", "End > Length", "Start < 0", "End < 0", "Start > End > 0"] + ids=["Start > End", "Start > Length", "End > Length", "Start < 0", "End < 0", "Start > End > 0"], ) def test_should_raise_if_index_out_of_bounds(start: int, end: int, step: int, error_message: str) -> None: table = Table({"col1": [1, 2, 1], "col2": [1, 2, 4]}) From 1300d6624e39401bd0feff8ba7dbbf76526ae397 Mon Sep 17 00:00:00 2001 From: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com> Date: Fri, 7 Jul 2023 07:46:46 +0000 Subject: [PATCH 06/12] style: apply automated linter fixes --- .../data/image/containers/test_image.py | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/safeds/data/image/containers/test_image.py b/tests/safeds/data/image/containers/test_image.py index 92cf6925c..885401a80 100644 --- a/tests/safeds/data/image/containers/test_image.py +++ b/tests/safeds/data/image/containers/test_image.py @@ -40,7 +40,9 @@ def test_should_load_png_file(self, path: str | Path) -> None: Image.from_png_file(resolve_resource_path(path)) @pytest.mark.parametrize( - "path", ["image/missing_file.png", Path("image/missing_file.png")], ids=["missing_file_png"], + "path", + ["image/missing_file.png", Path("image/missing_file.png")], + ids=["missing_file_png"], ) def test_should_raise_if_file_not_found(self, path: str | Path) -> None: with pytest.raises(FileNotFoundError): @@ -143,13 +145,17 @@ def test_should_save_png_file_by_path(self, path: str) -> None: class TestReprJpeg: @pytest.mark.parametrize( - "image", [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], ids=["jpg"], + "image", + [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], + ids=["jpg"], ) def test_should_return_bytes_if_image_is_jpeg(self, image: Image) -> None: assert isinstance(image._repr_jpeg_(), bytes) @pytest.mark.parametrize( - "image", [Image.from_png_file(resolve_resource_path("image/white_square.png"))], ids=["png"], + "image", + [Image.from_png_file(resolve_resource_path("image/white_square.png"))], + ids=["png"], ) def test_should_return_none_if_image_is_not_jpeg(self, image: Image) -> None: assert image._repr_jpeg_() is None @@ -157,13 +163,17 @@ def test_should_return_none_if_image_is_not_jpeg(self, image: Image) -> None: class TestReprPng: @pytest.mark.parametrize( - "image", [Image.from_png_file(resolve_resource_path("image/white_square.png"))], ids=["png"], + "image", + [Image.from_png_file(resolve_resource_path("image/white_square.png"))], + ids=["png"], ) def test_should_return_bytes_if_image_is_png(self, image: Image) -> None: assert isinstance(image._repr_png_(), bytes) @pytest.mark.parametrize( - "image", [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], ids=["jpg"], + "image", + [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], + ids=["jpg"], ) def test_should_return_none_if_image_is_not_png(self, image: Image) -> None: assert image._repr_png_() is None From 1c76f390094cdb609b74d5373909febe67daac37 Mon Sep 17 00:00:00 2001 From: PhilipGutberlet <92990487+PhilipGutberlet@users.noreply.github.com> Date: Fri, 7 Jul 2023 09:53:57 +0200 Subject: [PATCH 07/12] fixed failed tests --- tests/safeds/data/image/containers/test_image.py | 14 +++++++------- .../tabular/containers/_table/test_slice_rows.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/safeds/data/image/containers/test_image.py b/tests/safeds/data/image/containers/test_image.py index 90bd7f434..3c45fff62 100644 --- a/tests/safeds/data/image/containers/test_image.py +++ b/tests/safeds/data/image/containers/test_image.py @@ -13,7 +13,7 @@ class TestFromJpegFile: @pytest.mark.parametrize( "path", ["image/white_square.jpg", Path("image/white_square.jpg")], - ids=["white_square_jpg", "white_square_jpg,"], + ids=["jpg", "jpg_Path"] ) def test_should_load_jpeg_file(self, path: str | Path) -> None: Image.from_jpeg_file(resolve_resource_path(path)) @@ -21,7 +21,7 @@ def test_should_load_jpeg_file(self, path: str | Path) -> None: @pytest.mark.parametrize( "path", ["image/missing_file.jpg", Path("image/missing_file.jpg")], - ids=["missing_file_jpg",], + ids=["missing_file_jpg", "missing_file_jpg_Path"] ) def test_should_raise_if_file_not_found(self, path: str | Path) -> None: with pytest.raises(FileNotFoundError): @@ -32,7 +32,7 @@ class TestFromPngFile: @pytest.mark.parametrize( "path", ["image/white_square.png", Path("image/white_square.png")], - ids=["white_square_png"], + ids=["png", "png_Path"] ) def test_should_load_png_file(self, path: str | Path) -> None: Image.from_png_file(resolve_resource_path(path)) @@ -40,7 +40,7 @@ def test_should_load_png_file(self, path: str | Path) -> None: @pytest.mark.parametrize( "path", ["image/missing_file.png", Path("image/missing_file.png")], - ids=["missing_file_png"] + ids=["missing_file_png", "missing_file_png_Path"] ) def test_should_raise_if_file_not_found(self, path: str | Path) -> None: with pytest.raises(FileNotFoundError): @@ -54,7 +54,7 @@ class TestFormat: (Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg")), ImageFormat.JPEG), (Image.from_png_file(resolve_resource_path("image/white_square.png")), ImageFormat.PNG), ], - ids=["jpg","png"] + ids=["jpg", "png"] ) def test_should_return_correct_format(self, image: Image, format_: ImageFormat) -> None: assert image.format == format_ @@ -275,7 +275,7 @@ def test_should_be_original(self) -> None: class TestAdjustContrast: - @pytest.mark.parametrize("factor", [0.75, 5], ids=["factor"]) + @pytest.mark.parametrize("factor", [0.75, 5], ids=["small factor", "large factor"]) def test_should_adjust_contrast(self, factor: float) -> None: image = Image.from_png_file(resolve_resource_path("image/contrast/to_adjust_contrast.png")) image2 = image.adjust_contrast(factor) @@ -301,7 +301,7 @@ def test_should_raise(self) -> None: class TestBrightness: - @pytest.mark.parametrize("factor", [0.5, 10], ids=["factor"]) + @pytest.mark.parametrize("factor", [0.5, 10], ids=["small factor", "large factor"]) def test_should_adjust_brightness(self, factor: float) -> None: image = Image.from_png_file(resolve_resource_path("image/brightness/to_brighten.png")) image2 = image.adjust_brightness(factor) diff --git a/tests/safeds/data/tabular/containers/_table/test_slice_rows.py b/tests/safeds/data/tabular/containers/_table/test_slice_rows.py index fc4020d4c..69cdc06f1 100644 --- a/tests/safeds/data/tabular/containers/_table/test_slice_rows.py +++ b/tests/safeds/data/tabular/containers/_table/test_slice_rows.py @@ -36,7 +36,7 @@ def test_should_slice_rows(table: Table, test_table: Table, second_test_table: T (-4, 0, 1, r"There is no element at index '-4'"), (0, -4, 1, r"There is no element in the range \[0, -4\]"), ], - ids=["Start > End", "Start > Length", "End > Length", "Start < 0", "End < 0", "Start > End > 0"] + ids=["Start > End", "Start > Length", "End > Length", "Start < 0", "End < 0"] ) def test_should_raise_if_index_out_of_bounds(start: int, end: int, step: int, error_message: str) -> None: table = Table({"col1": [1, 2, 1], "col2": [1, 2, 4]}) From 60fa448f9679bd2f91f324250e9dea60580ed1d2 Mon Sep 17 00:00:00 2001 From: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com> Date: Fri, 7 Jul 2023 07:58:13 +0000 Subject: [PATCH 08/12] style: apply automated linter fixes --- .../data/image/containers/test_image.py | 49 +++++-------------- .../containers/_table/test_slice_rows.py | 2 +- 2 files changed, 13 insertions(+), 38 deletions(-) diff --git a/tests/safeds/data/image/containers/test_image.py b/tests/safeds/data/image/containers/test_image.py index 3c45fff62..989ffc652 100644 --- a/tests/safeds/data/image/containers/test_image.py +++ b/tests/safeds/data/image/containers/test_image.py @@ -11,9 +11,7 @@ class TestFromJpegFile: @pytest.mark.parametrize( - "path", - ["image/white_square.jpg", Path("image/white_square.jpg")], - ids=["jpg", "jpg_Path"] + "path", ["image/white_square.jpg", Path("image/white_square.jpg")], ids=["jpg", "jpg_Path"], ) def test_should_load_jpeg_file(self, path: str | Path) -> None: Image.from_jpeg_file(resolve_resource_path(path)) @@ -21,7 +19,7 @@ def test_should_load_jpeg_file(self, path: str | Path) -> None: @pytest.mark.parametrize( "path", ["image/missing_file.jpg", Path("image/missing_file.jpg")], - ids=["missing_file_jpg", "missing_file_jpg_Path"] + ids=["missing_file_jpg", "missing_file_jpg_Path"], ) def test_should_raise_if_file_not_found(self, path: str | Path) -> None: with pytest.raises(FileNotFoundError): @@ -30,9 +28,7 @@ def test_should_raise_if_file_not_found(self, path: str | Path) -> None: class TestFromPngFile: @pytest.mark.parametrize( - "path", - ["image/white_square.png", Path("image/white_square.png")], - ids=["png", "png_Path"] + "path", ["image/white_square.png", Path("image/white_square.png")], ids=["png", "png_Path"], ) def test_should_load_png_file(self, path: str | Path) -> None: Image.from_png_file(resolve_resource_path(path)) @@ -40,7 +36,7 @@ def test_should_load_png_file(self, path: str | Path) -> None: @pytest.mark.parametrize( "path", ["image/missing_file.png", Path("image/missing_file.png")], - ids=["missing_file_png", "missing_file_png_Path"] + ids=["missing_file_png", "missing_file_png_Path"], ) def test_should_raise_if_file_not_found(self, path: str | Path) -> None: with pytest.raises(FileNotFoundError): @@ -54,7 +50,7 @@ class TestFormat: (Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg")), ImageFormat.JPEG), (Image.from_png_file(resolve_resource_path("image/white_square.png")), ImageFormat.PNG), ], - ids=["jpg", "png"] + ids=["jpg", "png"], ) def test_should_return_correct_format(self, image: Image, format_: ImageFormat) -> None: assert image.format == format_ @@ -99,11 +95,7 @@ def test_should_save_jpeg_file_by_str(self, path: str) -> None: assert image._image.tobytes() == image_read_back._image.tobytes() - @pytest.mark.parametrize( - "path", - ["image/white_square.jpg"], - ids=["jpg"] - ) + @pytest.mark.parametrize("path", ["image/white_square.jpg"], ids=["jpg"]) def test_should_save_jpeg_file_by_path(self, path: str) -> None: image = Image.from_jpeg_file(resolve_resource_path(path)) @@ -118,12 +110,7 @@ def test_should_save_jpeg_file_by_path(self, path: str) -> None: class TestToPngFile: - @pytest.mark.parametrize( - "path", - ["image/white_square.png"], - ids=["png"] - ) - + @pytest.mark.parametrize("path", ["image/white_square.png"], ids=["png"]) def test_should_save_png_file_by_str(self, path: str) -> None: image = Image.from_png_file(resolve_resource_path(path)) @@ -136,11 +123,7 @@ def test_should_save_png_file_by_str(self, path: str) -> None: assert image._image.tobytes() == image_read_back._image.tobytes() - @pytest.mark.parametrize( - "path", - ["image/white_square.png"], - ids=["png"] - ) + @pytest.mark.parametrize("path", ["image/white_square.png"], ids=["png"]) def test_should_save_png_file_by_path(self, path: str) -> None: image = Image.from_png_file(resolve_resource_path(path)) @@ -156,17 +139,13 @@ def test_should_save_png_file_by_path(self, path: str) -> None: class TestReprJpeg: @pytest.mark.parametrize( - "image", - [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], - ids=["jpg"] + "image", [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], ids=["jpg"], ) def test_should_return_bytes_if_image_is_jpeg(self, image: Image) -> None: assert isinstance(image._repr_jpeg_(), bytes) @pytest.mark.parametrize( - "image", - [Image.from_png_file(resolve_resource_path("image/white_square.png"))], - ids=["png"] + "image", [Image.from_png_file(resolve_resource_path("image/white_square.png"))], ids=["png"], ) def test_should_return_none_if_image_is_not_jpeg(self, image: Image) -> None: assert image._repr_jpeg_() is None @@ -174,17 +153,13 @@ def test_should_return_none_if_image_is_not_jpeg(self, image: Image) -> None: class TestReprPng: @pytest.mark.parametrize( - "image", - [Image.from_png_file(resolve_resource_path("image/white_square.png"))], - ids=["png"] + "image", [Image.from_png_file(resolve_resource_path("image/white_square.png"))], ids=["png"], ) def test_should_return_bytes_if_image_is_png(self, image: Image) -> None: assert isinstance(image._repr_png_(), bytes) @pytest.mark.parametrize( - "image", - [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], - ids=["jpg"] + "image", [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], ids=["jpg"], ) def test_should_return_none_if_image_is_not_png(self, image: Image) -> None: assert image._repr_png_() is None diff --git a/tests/safeds/data/tabular/containers/_table/test_slice_rows.py b/tests/safeds/data/tabular/containers/_table/test_slice_rows.py index 69cdc06f1..b79440100 100644 --- a/tests/safeds/data/tabular/containers/_table/test_slice_rows.py +++ b/tests/safeds/data/tabular/containers/_table/test_slice_rows.py @@ -36,7 +36,7 @@ def test_should_slice_rows(table: Table, test_table: Table, second_test_table: T (-4, 0, 1, r"There is no element at index '-4'"), (0, -4, 1, r"There is no element in the range \[0, -4\]"), ], - ids=["Start > End", "Start > Length", "End > Length", "Start < 0", "End < 0"] + ids=["Start > End", "Start > Length", "End > Length", "Start < 0", "End < 0"], ) def test_should_raise_if_index_out_of_bounds(start: int, end: int, step: int, error_message: str) -> None: table = Table({"col1": [1, 2, 1], "col2": [1, 2, 4]}) From 36250e49b1661b631dabc8d87c7ef47ae74fac00 Mon Sep 17 00:00:00 2001 From: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com> Date: Fri, 7 Jul 2023 08:00:07 +0000 Subject: [PATCH 09/12] style: apply automated linter fixes --- .../data/image/containers/test_image.py | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/safeds/data/image/containers/test_image.py b/tests/safeds/data/image/containers/test_image.py index 989ffc652..96d992005 100644 --- a/tests/safeds/data/image/containers/test_image.py +++ b/tests/safeds/data/image/containers/test_image.py @@ -11,7 +11,9 @@ class TestFromJpegFile: @pytest.mark.parametrize( - "path", ["image/white_square.jpg", Path("image/white_square.jpg")], ids=["jpg", "jpg_Path"], + "path", + ["image/white_square.jpg", Path("image/white_square.jpg")], + ids=["jpg", "jpg_Path"], ) def test_should_load_jpeg_file(self, path: str | Path) -> None: Image.from_jpeg_file(resolve_resource_path(path)) @@ -28,7 +30,9 @@ def test_should_raise_if_file_not_found(self, path: str | Path) -> None: class TestFromPngFile: @pytest.mark.parametrize( - "path", ["image/white_square.png", Path("image/white_square.png")], ids=["png", "png_Path"], + "path", + ["image/white_square.png", Path("image/white_square.png")], + ids=["png", "png_Path"], ) def test_should_load_png_file(self, path: str | Path) -> None: Image.from_png_file(resolve_resource_path(path)) @@ -139,13 +143,17 @@ def test_should_save_png_file_by_path(self, path: str) -> None: class TestReprJpeg: @pytest.mark.parametrize( - "image", [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], ids=["jpg"], + "image", + [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], + ids=["jpg"], ) def test_should_return_bytes_if_image_is_jpeg(self, image: Image) -> None: assert isinstance(image._repr_jpeg_(), bytes) @pytest.mark.parametrize( - "image", [Image.from_png_file(resolve_resource_path("image/white_square.png"))], ids=["png"], + "image", + [Image.from_png_file(resolve_resource_path("image/white_square.png"))], + ids=["png"], ) def test_should_return_none_if_image_is_not_jpeg(self, image: Image) -> None: assert image._repr_jpeg_() is None @@ -153,13 +161,17 @@ def test_should_return_none_if_image_is_not_jpeg(self, image: Image) -> None: class TestReprPng: @pytest.mark.parametrize( - "image", [Image.from_png_file(resolve_resource_path("image/white_square.png"))], ids=["png"], + "image", + [Image.from_png_file(resolve_resource_path("image/white_square.png"))], + ids=["png"], ) def test_should_return_bytes_if_image_is_png(self, image: Image) -> None: assert isinstance(image._repr_png_(), bytes) @pytest.mark.parametrize( - "image", [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], ids=["jpg"], + "image", + [Image.from_jpeg_file(resolve_resource_path("image/white_square.jpg"))], + ids=["jpg"], ) def test_should_return_none_if_image_is_not_png(self, image: Image) -> None: assert image._repr_png_() is None From 5a5ac2cd5f97fa163f92c57b7877ab6ce903772b Mon Sep 17 00:00:00 2001 From: PhilipGutberlet <92990487+PhilipGutberlet@users.noreply.github.com> Date: Fri, 7 Jul 2023 10:15:58 +0200 Subject: [PATCH 10/12] fixed failed tests --- tests/safeds/data/image/containers/test_image.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/safeds/data/image/containers/test_image.py b/tests/safeds/data/image/containers/test_image.py index 3c45fff62..8a15cd4fc 100644 --- a/tests/safeds/data/image/containers/test_image.py +++ b/tests/safeds/data/image/containers/test_image.py @@ -86,6 +86,7 @@ class TestToJpegFile: @pytest.mark.parametrize( "path", ["image/white_square.jpg"], + ids=["jpg_file"] ) def test_should_save_jpeg_file_by_str(self, path: str) -> None: image = Image.from_jpeg_file(resolve_resource_path(path)) @@ -373,7 +374,7 @@ def test_should_return_cropped_image(self, image: Image, expected: Image) -> Non class TestSharpen: - @pytest.mark.parametrize("factor", [-1, 0.5, 10]) + @pytest.mark.parametrize("factor", [-1, 0.5, 10], ids=["negative factor", "small factor", "large factor"]) def test_should_sharpen(self, factor: float) -> None: image = Image.from_png_file(resolve_resource_path("image/sharpen/to_sharpen.png")) image2 = image.sharpen(factor) From 8d0d549992a1922fc466c81cf751ff7c60fd69f2 Mon Sep 17 00:00:00 2001 From: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com> Date: Fri, 7 Jul 2023 08:18:40 +0000 Subject: [PATCH 11/12] style: apply automated linter fixes --- tests/safeds/data/image/containers/test_image.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/safeds/data/image/containers/test_image.py b/tests/safeds/data/image/containers/test_image.py index 3fdb8aa75..fe7d93955 100644 --- a/tests/safeds/data/image/containers/test_image.py +++ b/tests/safeds/data/image/containers/test_image.py @@ -83,11 +83,7 @@ def test_should_return_image_properties(self, image: Image, width: int, height: class TestToJpegFile: - @pytest.mark.parametrize( - "path", - ["image/white_square.jpg"], - ids=["jpg_file"] - ) + @pytest.mark.parametrize("path", ["image/white_square.jpg"], ids=["jpg_file"]) def test_should_save_jpeg_file_by_str(self, path: str) -> None: image = Image.from_jpeg_file(resolve_resource_path(path)) From 7dbfc336b9830dc465fba0bf26c6cb74898f53d1 Mon Sep 17 00:00:00 2001 From: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com> Date: Fri, 7 Jul 2023 12:57:24 +0000 Subject: [PATCH 12/12] style: apply automated linter fixes --- tests/safeds/data/tabular/containers/_table/test_sort_rows.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/safeds/data/tabular/containers/_table/test_sort_rows.py b/tests/safeds/data/tabular/containers/_table/test_sort_rows.py index 80320ede7..9772dc112 100644 --- a/tests/safeds/data/tabular/containers/_table/test_sort_rows.py +++ b/tests/safeds/data/tabular/containers/_table/test_sort_rows.py @@ -18,9 +18,7 @@ Table({"col1": [1, 2, 3]}), ), ], - ids=["empty", "3 rows"], - ) def test_should_return_sorted_table( table: Table, @@ -45,9 +43,7 @@ def test_should_return_sorted_table( Table({"col1": [3, 2, 1]}), ), ], - ids=["empty", "3 rows"], - ) def test_should_not_modify_original_table( table: Table,