Skip to content

Commit 87802e2

Browse files
committed
Add test for deprecated decorator
1 parent a92e72b commit 87802e2

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import warnings
2+
3+
import pytest
4+
5+
from blueapi.utils import deprecated
6+
7+
8+
def test_deprecated_annotation():
9+
@deprecated("bar")
10+
def foo():
11+
return 1
12+
13+
with pytest.warns(DeprecationWarning, match="Function foo is deprecated - use bar"):
14+
assert foo() == 1
15+
16+
# The second time a function is called, the warning should not be raised
17+
with warnings.catch_warnings():
18+
warnings.simplefilter("error")
19+
assert foo() == 1

0 commit comments

Comments
 (0)