Path: blob/main/py-polars/tests/unit/meta/test_exceptions.py
8414 views
import pytest12from polars.exceptions import (3CategoricalRemappingWarning,4ComputeError,5CustomUFuncWarning,6MapWithoutReturnDtypeWarning,7OutOfBoundsError,8PerformanceWarning,9PolarsError,10PolarsInefficientMapWarning,11PolarsWarning,12)131415def test_polars_error_base_class() -> None:16msg = "msg"17assert isinstance(ComputeError(msg), PolarsError)18with pytest.raises(PolarsError, match=msg):19raise OutOfBoundsError(msg)202122def test_polars_warning_base_class() -> None:23msg = "msg"24assert isinstance(MapWithoutReturnDtypeWarning(msg), PolarsWarning)25with pytest.raises(PolarsWarning, match=msg):26raise CustomUFuncWarning(msg)272829def test_performance_warning_base_class() -> None:30msg = "msg"31assert isinstance(PolarsInefficientMapWarning(msg), PerformanceWarning)32with pytest.raises(PerformanceWarning, match=msg):33raise CategoricalRemappingWarning(msg)343536