Skip to content

Commit 37525a2

Browse files
committed
Add test
Signed-off-by: liamhuber <[email protected]>
1 parent e9bd269 commit 37525a2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/unit/test_deprecate.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
from pyiron_snippets.deprecate import deprecate, deprecate_soon
55

66

7+
class ToGiveAQualname:
8+
content = "this is the string"
9+
10+
@staticmethod
11+
@deprecate(bar=f"Instead of {content}, we want to see a string")
12+
def foo(bar=None, baz=None):
13+
pass
14+
15+
716
class TestDeprecator(unittest.TestCase):
817
def test_deprecate(self):
918
"""Function decorated with `deprecate` should raise a warning."""
@@ -125,6 +134,15 @@ def food(bar=None, baz=None):
125134
food(baz=True)
126135
self.assertEqual(len(w), 2, "Not all warnings preserved.")
127136

137+
def test_warning_reference(self):
138+
with warnings.catch_warnings(record=True) as w:
139+
ToGiveAQualname.foo(bar=True)
140+
self.assertIn(
141+
f"{ToGiveAQualname.foo.__module__}.{ToGiveAQualname.foo.__qualname__}",
142+
str(w[0].message),
143+
msg="Ensure full reference to function appears in warning.",
144+
)
145+
128146

129147
if __name__ == "__main__":
130148
unittest.main()

0 commit comments

Comments
 (0)