@@ -157,15 +157,14 @@ class MetaPathFinderDefaultsTests(ABCTestHarness):
157157
158158 def test_find_module (self ):
159159 # 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 )
161163
162164 def test_invalidate_caches (self ):
163165 # Calling the method is a no-op.
164166 self .ins .invalidate_caches ()
165167
166- def test_find_module_warns (self ):
167- with self .assertWarns (DeprecationWarning ):
168- self .ins .find_module ('something' , None )
169168
170169(Frozen_MPFDefaultTests ,
171170 Source_MPFDefaultTests
@@ -183,7 +182,9 @@ class PathEntryFinderDefaultsTests(ABCTestHarness):
183182 SPLIT = make_abc_subclasses (PathEntryFinder )
184183
185184 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 , []))
187188
188189 def find_module (self ):
189190 self .assertEqual (None , self .ins .find_module ('something' ))
@@ -192,9 +193,6 @@ def test_invalidate_caches(self):
192193 # Should be a no-op.
193194 self .ins .invalidate_caches ()
194195
195- def test_find_loader_warns (self ):
196- with self .assertWarns (DeprecationWarning ):
197- self .ins .find_loader ('something' )
198196
199197(Frozen_PEFDefaultTests ,
200198 Source_PEFDefaultTests
@@ -324,7 +322,8 @@ def test_no_spec(self):
324322 finder = self .finder (None )
325323 path = ['a' , 'b' , 'c' ]
326324 name = 'blah'
327- found = finder .find_module (name , path )
325+ with self .assertWarns (DeprecationWarning ):
326+ found = finder .find_module (name , path )
328327 self .assertIsNone (found )
329328 self .assertEqual (name , finder .called_for [0 ])
330329 self .assertEqual (path , finder .called_for [1 ])
@@ -333,7 +332,8 @@ def test_spec(self):
333332 loader = object ()
334333 spec = self .util .spec_from_loader ('blah' , loader )
335334 finder = self .finder (spec )
336- found = finder .find_module ('blah' , None )
335+ with self .assertWarns (DeprecationWarning ):
336+ found = finder .find_module ('blah' , None )
337337 self .assertIs (found , spec .loader )
338338
339339
@@ -358,7 +358,8 @@ def find_spec(self, fullname, target=None):
358358 def test_no_spec (self ):
359359 finder = self .finder (None )
360360 name = 'blah'
361- found = finder .find_loader (name )
361+ with self .assertWarns (DeprecationWarning ):
362+ found = finder .find_loader (name )
362363 self .assertIsNone (found [0 ])
363364 self .assertEqual ([], found [1 ])
364365 self .assertEqual (name , finder .called_for )
@@ -367,15 +368,17 @@ def test_spec_with_loader(self):
367368 loader = object ()
368369 spec = self .util .spec_from_loader ('blah' , loader )
369370 finder = self .finder (spec )
370- found = finder .find_loader ('blah' )
371+ with self .assertWarns (DeprecationWarning ):
372+ found = finder .find_loader ('blah' )
371373 self .assertIs (found [0 ], spec .loader )
372374
373375 def test_spec_with_portions (self ):
374376 spec = self .machinery .ModuleSpec ('blah' , None )
375377 paths = ['a' , 'b' , 'c' ]
376378 spec .submodule_search_locations = paths
377379 finder = self .finder (spec )
378- found = finder .find_loader ('blah' )
380+ with self .assertWarns (DeprecationWarning ):
381+ found = finder .find_loader ('blah' )
379382 self .assertIsNone (found [0 ])
380383 self .assertEqual (paths , found [1 ])
381384
0 commit comments