Skip to content

Commit f94b768

Browse files
authored
feat: add test for empty tables for the method Table.sort_rows (#431)
Closes #402 ### Summary of Changes implement the test for empty table in the tests for non empty tables.
1 parent 5e3da8d commit f94b768

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tests/safeds/data/tabular/containers/_table/test_sort_rows.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77
@pytest.mark.parametrize(
88
("table", "comparator", "expected"),
99
[
10-
# Check that it works with an empty table when https://github.com/Safe-DS/Stdlib/issues/75 is fixed.
10+
(
11+
Table(),
12+
lambda row1, row2: row1["col1"] - row2["col1"],
13+
Table(),
14+
),
1115
(
1216
Table({"col1": [3, 2, 1]}),
1317
lambda row1, row2: row1["col1"] - row2["col1"],
1418
Table({"col1": [1, 2, 3]}),
1519
),
1620
],
21+
ids=["empty", "3 rows"],
1722
)
1823
def test_should_return_sorted_table(
1924
table: Table,
@@ -27,13 +32,18 @@ def test_should_return_sorted_table(
2732
@pytest.mark.parametrize(
2833
("table", "comparator", "expected"),
2934
[
30-
# Check that it works with an empty table when https://github.com/Safe-DS/Stdlib/issues/75 is fixed.
35+
(
36+
Table(),
37+
lambda row1, row2: row1["col1"] - row2["col1"],
38+
Table(),
39+
),
3140
(
3241
Table({"col1": [3, 2, 1]}),
3342
lambda row1, row2: row1["col1"] - row2["col1"],
3443
Table({"col1": [3, 2, 1]}),
3544
),
3645
],
46+
ids=["empty", "3 rows"],
3747
)
3848
def test_should_not_modify_original_table(
3949
table: Table,
@@ -43,7 +53,3 @@ def test_should_not_modify_original_table(
4353
table.sort_rows(comparator)
4454
assert table.schema == expected.schema
4555
assert table == expected
46-
47-
48-
def test_should_not_sort_anything_on_empty_table() -> None:
49-
assert Table() == Table().sort_rows(lambda row1, row2: row1["col1"] - row2["col1"])

0 commit comments

Comments
 (0)