@@ -167,14 +167,15 @@ def test_owners_getter(self):
167
167
assert policy .owners == expected
168
168
169
169
def test_owners_setter (self ):
170
- import warnings
171
170
from google .api_core .iam import OWNER_ROLE
172
171
173
172
MEMBER = "user:phred@example.com"
174
173
expected = set ([MEMBER ])
175
174
policy = self ._make_one ()
176
175
177
- with warnings .catch_warnings (record = True ) as warned :
176
+ with pytest .warns (
177
+ DeprecationWarning , match = "Assigning to 'owners' is deprecated."
178
+ ) as warned :
178
179
policy .owners = [MEMBER ]
179
180
180
181
(warning ,) = warned
@@ -191,14 +192,15 @@ def test_editors_getter(self):
191
192
assert policy .editors == expected
192
193
193
194
def test_editors_setter (self ):
194
- import warnings
195
195
from google .api_core .iam import EDITOR_ROLE
196
196
197
197
MEMBER = "user:phred@example.com"
198
198
expected = set ([MEMBER ])
199
199
policy = self ._make_one ()
200
200
201
- with warnings .catch_warnings (record = True ) as warned :
201
+ with pytest .warns (
202
+ DeprecationWarning , match = "Assigning to 'editors' is deprecated."
203
+ ) as warned :
202
204
policy .editors = [MEMBER ]
203
205
204
206
(warning ,) = warned
@@ -215,14 +217,15 @@ def test_viewers_getter(self):
215
217
assert policy .viewers == expected
216
218
217
219
def test_viewers_setter (self ):
218
- import warnings
219
220
from google .api_core .iam import VIEWER_ROLE
220
221
221
222
MEMBER = "user:phred@example.com"
222
223
expected = set ([MEMBER ])
223
224
policy = self ._make_one ()
224
225
225
- with warnings .catch_warnings (record = True ) as warned :
226
+ with pytest .warns (
227
+ DeprecationWarning , match = "Assigning to 'viewers' is deprecated."
228
+ ) as warned :
226
229
policy .viewers = [MEMBER ]
227
230
228
231
(warning ,) = warned
@@ -337,12 +340,13 @@ def test_to_api_repr_binding_wo_members(self):
337
340
assert policy .to_api_repr () == {}
338
341
339
342
def test_to_api_repr_binding_w_duplicates (self ):
340
- import warnings
341
343
from google .api_core .iam import OWNER_ROLE
342
344
343
345
OWNER = "group:cloud-logs@google.com"
344
346
policy = self ._make_one ()
345
- with warnings .catch_warnings (record = True ):
347
+ with pytest .warns (
348
+ DeprecationWarning , match = "Assigning to 'owners' is deprecated."
349
+ ):
346
350
policy .owners = [OWNER , OWNER ]
347
351
assert policy .to_api_repr () == {
348
352
"bindings" : [{"role" : OWNER_ROLE , "members" : [OWNER ]}]
0 commit comments