@@ -106,7 +106,8 @@ def test_caching_twice_same_instance(self, example_class):
106106 getattr (example , action_name )(2 )
107107 assert example .result_1_ == 5 * multiplier
108108
109- with pytest .warns (None ) as w :
109+ with warnings .catch_warnings (record = True ) as w :
110+ warnings .simplefilter ("always" )
110111 getattr (example , action_name )(3 )
111112 assert example .result_1_ == 6 * multiplier
112113 assert not w
@@ -126,7 +127,8 @@ def test_caching_twice_new_instance(self, example_class):
126127 assert example .result_1_ == 5 * multiplier
127128
128129 example = example_class (1 , 2 )
129- with pytest .warns (None ) as w :
130+ with warnings .catch_warnings (record = True ) as w :
131+ warnings .simplefilter ("always" )
130132 getattr (example , action_name )(3 )
131133 assert example .result_1_ == 6 * multiplier
132134 assert not w
@@ -165,7 +167,8 @@ def test_cache_only(self, example_class):
165167 example = example .clone ()
166168
167169 # Now in the cached version
168- with pytest .warns (None ) as w :
170+ with warnings .catch_warnings (record = True ) as w :
171+ warnings .simplefilter ("always" )
169172 getattr (example , action_name )(2 )
170173 assert not w
171174 assert example .result_1_ == 5 * multiplier
@@ -197,7 +200,8 @@ def worker_func(pipe):
197200 if self .cache_method_name == "disk" and restore_in_parallel_process is True :
198201 # Disk cache can work across processes. This means, already on the first call in the new process,
199202 # we should get the cached result.
200- with pytest .warns (None ) as w :
203+ with warnings .catch_warnings (record = True ) as w :
204+ warnings .simplefilter ("always" )
201205 pipe .action (1 )
202206 assert not w
203207 else :
@@ -207,7 +211,8 @@ def worker_func(pipe):
207211
208212 if restore_in_parallel_process is True :
209213 # Id we set the restore option to True, the second call should be correctly cached
210- with pytest .warns (None ) as w :
214+ with warnings .catch_warnings (record = True ) as w :
215+ warnings .simplefilter ("always" )
211216 pipe .action (1 )
212217 assert not w
213218 else :
@@ -255,7 +260,8 @@ def test_joblib_only(self, joblib_cache, hybrid_cache_clear):
255260
256261 assert r == 3
257262
258- with pytest .warns (None ) as w :
263+ with warnings .catch_warnings (record = True ) as w :
264+ warnings .simplefilter ("always" )
259265 r = cached_func (1 , 2 )
260266
261267 assert r == 3
@@ -269,7 +275,8 @@ def test_lru_only(self, hybrid_cache_clear):
269275
270276 assert r == 3
271277
272- with pytest .warns (None ) as w :
278+ with warnings .catch_warnings (record = True ) as w :
279+ warnings .simplefilter ("always" )
273280 r = cached_func (1 , 2 )
274281
275282 assert r == 3
@@ -288,7 +295,8 @@ def test_staggered_cache(self, joblib_cache_verbose, hybrid_cache_clear, capfd):
288295
289296 assert r == 3
290297
291- with pytest .warns (None ) as w :
298+ with warnings .catch_warnings (record = True ) as w :
299+ warnings .simplefilter ("always" )
292300 r = cached_func (1 , 2 )
293301
294302 # This should not hit the joblib cache, as the lru cache should have been used
@@ -317,7 +325,8 @@ def test_joblib_cache_survives_clear(self, joblib_cache_verbose, hybrid_cache_cl
317325
318326 cached_func_new = hybrid_cache (joblib_cache_verbose , 2 )(example_func )
319327
320- with pytest .warns (None ) as w :
328+ with warnings .catch_warnings (record = True ) as w :
329+ warnings .simplefilter ("always" )
321330 r = cached_func_new (1 , 2 )
322331
323332 # This time this should hit the joblib cache, as the lru cache should have been cleared
@@ -330,7 +339,8 @@ def test_joblib_cache_survives_clear(self, joblib_cache_verbose, hybrid_cache_cl
330339 assert not w
331340
332341 # And now the lru cache should be used again
333- with pytest .warns (None ) as w :
342+ with warnings .catch_warnings (record = True ) as w :
343+ warnings .simplefilter ("always" )
334344 r = cached_func_new (1 , 2 )
335345
336346 # This time this should hit the joblib cache, as the lru cache should have been cleared
0 commit comments