From e2d150d69f8e45a76cd40370967ee0ab245a660d Mon Sep 17 00:00:00 2001 From: jrycw Date: Tue, 17 Dec 2024 10:48:42 +0800 Subject: [PATCH] Add additional test cases for `resolve_mask_i()` --- tests/test_tab_create_modify.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_tab_create_modify.py b/tests/test_tab_create_modify.py index 2d8c86e21..98ccc9ada 100644 --- a/tests/test_tab_create_modify.py +++ b/tests/test_tab_create_modify.py @@ -125,3 +125,23 @@ def test_tab_style_loc_body_mask_not_polars_expression_raises(gt2: GT): with pytest.raises(ValueError) as exc_info: tab_style(gt2, style, LocBody(mask=mask)) assert err_msg in exc_info.value.args[0] + + +def test_tab_style_loc_body_mask_columns_not_inside_raises(gt2: GT): + style = CellStyleFill(color="blue") + mask = pl.len() + err_msg = "The `mask` may reference columns not in the original DataFrame." + + with pytest.raises(ValueError) as exc_info: + tab_style(gt2, style, LocBody(mask=mask)) + assert err_msg in exc_info.value.args[0] + + +def test_tab_style_loc_body_mask_rows_not_equal_raises(gt2: GT): + style = CellStyleFill(color="blue") + mask = pl.len().alias("x") + err_msg = "The DataFrame length after applying `mask` differs from the original." + + with pytest.raises(ValueError) as exc_info: + tab_style(gt2, style, LocBody(mask=mask)) + assert err_msg in exc_info.value.args[0]