From 477117892b2d390aa4eebed76c9465aaad534d73 Mon Sep 17 00:00:00 2001 From: Jerry Wu Date: Sat, 23 Nov 2024 10:20:56 +0800 Subject: [PATCH] Fix missing exception raise in `_val_is_numeric()` and `_val_is_str()` (#510) * Raise `ValueError` in `_val_is_numeric()` and `_val_is_str()` * Update tests --- great_tables/_utils_nanoplots.py | 4 ++-- tests/test__utils_nanoplots.py | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/great_tables/_utils_nanoplots.py b/great_tables/_utils_nanoplots.py index fbf75d4ca..d13417f02 100644 --- a/great_tables/_utils_nanoplots.py +++ b/great_tables/_utils_nanoplots.py @@ -26,7 +26,7 @@ def _val_is_numeric(x: Any) -> bool: # If a list then signal a failure if isinstance(x, list): - ValueError("The input cannot be a list. It must be a single value.") + raise ValueError("The input cannot be a list. It must be a single value.") return isinstance(x, (int, float)) @@ -38,7 +38,7 @@ def _val_is_str(x: Any) -> bool: # If a list then signal a failure if isinstance(x, list): - ValueError("The input cannot be a list. It must be a single value.") + raise ValueError("The input cannot be a list. It must be a single value.") return isinstance(x, (str)) diff --git a/tests/test__utils_nanoplots.py b/tests/test__utils_nanoplots.py index ee61eacb6..9975bac1b 100644 --- a/tests/test__utils_nanoplots.py +++ b/tests/test__utils_nanoplots.py @@ -74,7 +74,6 @@ def test_val_is_numeric(): assert not _val_is_numeric("a") -@pytest.mark.xfail def test_val_is_numeric_fails_list_input(): with pytest.raises(ValueError): _val_is_numeric([1, 2, 3]) @@ -88,7 +87,6 @@ def test_val_is_str(): assert not _val_is_str(1) -@pytest.mark.xfail def test_val_is_str_fails_list_input(): with pytest.raises(ValueError): _val_is_str(["a", "b", "c"])