24
24
removed_kwargs ,
25
25
renamed_kwargs ,
26
26
deprecation_warning ,
27
+ deprecated ,
27
28
)
28
29
29
30
@@ -69,26 +70,30 @@ def sample_function():
69
70
with pytest .warns (DeprecationWarning ) as w :
70
71
output = sample_function ()
71
72
assert output == "xxxx...."
72
- msg = "sample_function will be deprecated on date.message in sagemaker>=2.\n " \
73
- "See: https://sagemaker.readthedocs.io/en/stable/v2.html for details."
73
+ msg = (
74
+ "sample_function will be deprecated on date.message in sagemaker>=2.\n "
75
+ "See: https://sagemaker.readthedocs.io/en/stable/v2.html for details."
76
+ )
74
77
assert str (w [- 1 ].message ) == msg
75
78
76
79
77
80
def test_deprecation_warning_for_class ():
78
81
@deprecation_warning (msg = "message" , date = "date" )
79
- class SampleClass () :
82
+ class SampleClass :
80
83
def __init__ (self ):
81
84
pass
82
85
83
86
with pytest .warns (DeprecationWarning ) as w :
84
87
SampleClass ()
85
- msg = "SampleClass will be deprecated on date.message in sagemaker>=2.\n " \
86
- "See: https://sagemaker.readthedocs.io/en/stable/v2.html for details."
88
+ msg = (
89
+ "SampleClass will be deprecated on date.message in sagemaker>=2.\n "
90
+ "See: https://sagemaker.readthedocs.io/en/stable/v2.html for details."
91
+ )
87
92
assert str (w [- 1 ].message ) == msg
88
93
89
94
90
95
def test_deprecation_warning_for_class_method ():
91
- class SampleClass () :
96
+ class SampleClass :
92
97
def __init__ (self ):
93
98
pass
94
99
@@ -100,8 +105,60 @@ def sample_method(self):
100
105
with pytest .warns (DeprecationWarning ) as w :
101
106
output = s .sample_method ()
102
107
assert output == "xxxx...."
103
- msg = "sample_method will be deprecated on date.message in sagemaker>=2.\n " \
104
- "See: https://sagemaker.readthedocs.io/en/stable/v2.html for details."
108
+ msg = (
109
+ "sample_method will be deprecated on date.message in sagemaker>=2.\n "
110
+ "See: https://sagemaker.readthedocs.io/en/stable/v2.html for details."
111
+ )
112
+ assert str (w [- 1 ].message ) == msg
113
+
114
+
115
+ def test_deprecated_for_function ():
116
+ @deprecated
117
+ def sample_function ():
118
+ return "xxxx...."
119
+
120
+ with pytest .warns (DeprecationWarning ) as w :
121
+ output = sample_function ()
122
+ assert output == "xxxx...."
123
+ msg = (
124
+ "sample_function is a no-op in sagemaker>=2.\n "
125
+ "See: https://sagemaker.readthedocs.io/en/stable/v2.html for details."
126
+ )
127
+ assert str (w [- 1 ].message ) == msg
128
+
129
+
130
+ def test_deprecated_for_class ():
131
+ @deprecated
132
+ class SampleClass :
133
+ def __init__ (self ):
134
+ pass
135
+
136
+ with pytest .warns (DeprecationWarning ) as w :
137
+ SampleClass ()
138
+ msg = (
139
+ "SampleClass is a no-op in sagemaker>=2.\n "
140
+ "See: https://sagemaker.readthedocs.io/en/stable/v2.html for details."
141
+ )
142
+ assert str (w [- 1 ].message ) == msg
143
+
144
+
145
+ def test_deprecated_for_class_method ():
146
+ class SampleClass :
147
+ def __init__ (self ):
148
+ pass
149
+
150
+ @deprecated
151
+ def sample_method (self ):
152
+ return "xxxx...."
153
+
154
+ s = SampleClass ()
155
+ with pytest .warns (DeprecationWarning ) as w :
156
+ output = s .sample_method ()
157
+ assert output == "xxxx...."
158
+ msg = (
159
+ "sample_method is a no-op in sagemaker>=2.\n "
160
+ "See: https://sagemaker.readthedocs.io/en/stable/v2.html for details."
161
+ )
105
162
assert str (w [- 1 ].message ) == msg
106
163
107
164
0 commit comments