Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/py-polars/tests/unit/test_exceptions.py
6939 views
1
import pytest
2
3
from polars.exceptions import (
4
CategoricalRemappingWarning,
5
ComputeError,
6
CustomUFuncWarning,
7
MapWithoutReturnDtypeWarning,
8
OutOfBoundsError,
9
PerformanceWarning,
10
PolarsError,
11
PolarsInefficientMapWarning,
12
PolarsWarning,
13
)
14
15
16
def test_polars_error_base_class() -> None:
17
msg = "msg"
18
assert isinstance(ComputeError(msg), PolarsError)
19
with pytest.raises(PolarsError, match=msg):
20
raise OutOfBoundsError(msg)
21
22
23
def test_polars_warning_base_class() -> None:
24
msg = "msg"
25
assert isinstance(MapWithoutReturnDtypeWarning(msg), PolarsWarning)
26
with pytest.raises(PolarsWarning, match=msg):
27
raise CustomUFuncWarning(msg)
28
29
30
def test_performance_warning_base_class() -> None:
31
msg = "msg"
32
assert isinstance(PolarsInefficientMapWarning(msg), PerformanceWarning)
33
with pytest.raises(PerformanceWarning, match=msg):
34
raise CategoricalRemappingWarning(msg)
35
36