@@ -157,15 +157,14 @@ class MetaPathFinderDefaultsTests(ABCTestHarness):
157
157
158
158
def test_find_module (self ):
159
159
# Default should return None.
160
- self .assertIsNone (self .ins .find_module ('something' , None ))
160
+ with self .assertWarns (DeprecationWarning ):
161
+ found = self .ins .find_module ('something' , None )
162
+ self .assertIsNone (found )
161
163
162
164
def test_invalidate_caches (self ):
163
165
# Calling the method is a no-op.
164
166
self .ins .invalidate_caches ()
165
167
166
- def test_find_module_warns (self ):
167
- with self .assertWarns (DeprecationWarning ):
168
- self .ins .find_module ('something' , None )
169
168
170
169
(Frozen_MPFDefaultTests ,
171
170
Source_MPFDefaultTests
@@ -183,7 +182,9 @@ class PathEntryFinderDefaultsTests(ABCTestHarness):
183
182
SPLIT = make_abc_subclasses (PathEntryFinder )
184
183
185
184
def test_find_loader (self ):
186
- self .assertEqual ((None , []), self .ins .find_loader ('something' ))
185
+ with self .assertWarns (DeprecationWarning ):
186
+ found = self .ins .find_loader ('something' )
187
+ self .assertEqual (found , (None , []))
187
188
188
189
def find_module (self ):
189
190
self .assertEqual (None , self .ins .find_module ('something' ))
@@ -192,9 +193,6 @@ def test_invalidate_caches(self):
192
193
# Should be a no-op.
193
194
self .ins .invalidate_caches ()
194
195
195
- def test_find_loader_warns (self ):
196
- with self .assertWarns (DeprecationWarning ):
197
- self .ins .find_loader ('something' )
198
196
199
197
(Frozen_PEFDefaultTests ,
200
198
Source_PEFDefaultTests
@@ -324,7 +322,8 @@ def test_no_spec(self):
324
322
finder = self .finder (None )
325
323
path = ['a' , 'b' , 'c' ]
326
324
name = 'blah'
327
- found = finder .find_module (name , path )
325
+ with self .assertWarns (DeprecationWarning ):
326
+ found = finder .find_module (name , path )
328
327
self .assertIsNone (found )
329
328
self .assertEqual (name , finder .called_for [0 ])
330
329
self .assertEqual (path , finder .called_for [1 ])
@@ -333,7 +332,8 @@ def test_spec(self):
333
332
loader = object ()
334
333
spec = self .util .spec_from_loader ('blah' , loader )
335
334
finder = self .finder (spec )
336
- found = finder .find_module ('blah' , None )
335
+ with self .assertWarns (DeprecationWarning ):
336
+ found = finder .find_module ('blah' , None )
337
337
self .assertIs (found , spec .loader )
338
338
339
339
@@ -358,7 +358,8 @@ def find_spec(self, fullname, target=None):
358
358
def test_no_spec (self ):
359
359
finder = self .finder (None )
360
360
name = 'blah'
361
- found = finder .find_loader (name )
361
+ with self .assertWarns (DeprecationWarning ):
362
+ found = finder .find_loader (name )
362
363
self .assertIsNone (found [0 ])
363
364
self .assertEqual ([], found [1 ])
364
365
self .assertEqual (name , finder .called_for )
@@ -367,15 +368,17 @@ def test_spec_with_loader(self):
367
368
loader = object ()
368
369
spec = self .util .spec_from_loader ('blah' , loader )
369
370
finder = self .finder (spec )
370
- found = finder .find_loader ('blah' )
371
+ with self .assertWarns (DeprecationWarning ):
372
+ found = finder .find_loader ('blah' )
371
373
self .assertIs (found [0 ], spec .loader )
372
374
373
375
def test_spec_with_portions (self ):
374
376
spec = self .machinery .ModuleSpec ('blah' , None )
375
377
paths = ['a' , 'b' , 'c' ]
376
378
spec .submodule_search_locations = paths
377
379
finder = self .finder (spec )
378
- found = finder .find_loader ('blah' )
380
+ with self .assertWarns (DeprecationWarning ):
381
+ found = finder .find_loader ('blah' )
379
382
self .assertIsNone (found [0 ])
380
383
self .assertEqual (paths , found [1 ])
381
384
0 commit comments