[go: up one dir, main page]

File: test_deprecated.py

package info (click to toggle)
iminuit 2.30.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,660 kB
  • sloc: cpp: 14,591; python: 11,177; makefile: 11; sh: 5
file content (55 lines) | stat: -rw-r--r-- 1,156 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from iminuit._deprecated import deprecated, deprecated_parameter
import pytest


def test_deprecated_func_1():
    @deprecated("bla")
    def func(x):
        pass

    with pytest.warns(
        FutureWarning,
        match="func is deprecated: bla",
    ):
        func(1)


def test_deprecated_func_2():
    @deprecated("bla", removal="1.0")
    def func(x):
        pass

    with pytest.warns(
        DeprecationWarning,
        match="func is deprecated and will be removed in version 1.0: bla",
    ):
        func(1)


def test_deprecated_func_3():
    @deprecated("bla", removal="1000.0")
    def func(x):
        pass

    with pytest.warns(
        FutureWarning,
        match="func is deprecated and will be removed in version 1000.0: bla",
    ):
        func(1)


def test_deprecated_parameter():
    @deprecated_parameter(foo="bar")
    def some_function(x, y, foo):
        pass

    some_function(1, 2, foo=3)

    with pytest.warns(
        FutureWarning,
        match="keyword 'bar' is deprecated, please use 'foo'",
    ):
        some_function(1, 2, bar=3)

    with pytest.raises(TypeError):
        some_function(x=1, baz=3, y=2)