File: test_deprecation.py

package info (click to toggle)
python-altair 5.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,952 kB
  • sloc: python: 25,649; sh: 14; makefile: 5
file content (24 lines) | stat: -rw-r--r-- 690 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pytest

import altair as alt
from altair.utils import AltairDeprecationWarning
from altair.utils.deprecation import _deprecate, deprecated


def test_deprecated_class():
    OldChart = _deprecate(alt.Chart, "OldChart")
    with pytest.warns(AltairDeprecationWarning) as record:
        OldChart()
    assert "alt.OldChart" in record[0].message.args[0]
    assert "alt.Chart" in record[0].message.args[0]


def test_deprecation_decorator():
    @deprecated(message="func is deprecated")
    def func(x):
        return x + 1

    with pytest.warns(AltairDeprecationWarning) as record:
        y = func(1)
    assert y == 2
    assert record[0].message.args[0] == "func is deprecated"