Path: blob/main/py-polars/tests/unit/utils/test_unstable.py
8414 views
from __future__ import annotations12from typing import TYPE_CHECKING34import pytest56from polars._utils.unstable import issue_unstable_warning, unstable7from polars.exceptions import UnstableWarning89if TYPE_CHECKING:10from tests.conftest import PlMonkeyPatch111213def test_issue_unstable_warning(plmonkeypatch: PlMonkeyPatch) -> None:14plmonkeypatch.setenv("POLARS_WARN_UNSTABLE", "1")1516msg = "`func` is considered unstable."17expected = (18msg19+ " It may be changed at any point without it being considered a breaking change."20)21with pytest.warns(UnstableWarning, match=expected):22issue_unstable_warning(msg)232425def test_issue_unstable_warning_default(plmonkeypatch: PlMonkeyPatch) -> None:26plmonkeypatch.setenv("POLARS_WARN_UNSTABLE", "1")2728msg = "this functionality is considered unstable."29with pytest.warns(UnstableWarning, match=msg):30issue_unstable_warning()313233def test_issue_unstable_warning_setting_disabled(34recwarn: pytest.WarningsRecorder,35) -> None:36issue_unstable_warning()37assert len(recwarn) == 0383940def test_unstable_decorator(plmonkeypatch: PlMonkeyPatch) -> None:41plmonkeypatch.setenv("POLARS_WARN_UNSTABLE", "1")4243@unstable()44def hello() -> None: ...4546msg = "`hello` is considered unstable."47with pytest.warns(UnstableWarning, match=msg):48hello()495051def test_unstable_decorator_setting_disabled(recwarn: pytest.WarningsRecorder) -> None:52@unstable()53def hello() -> None: ...5455hello()56assert len(recwarn) == 0575859