1
+ import warnings
1
2
import pytest
2
3
from scipy .linalg import eigh , pinvh
3
4
from collections import namedtuple
@@ -353,7 +354,7 @@ def test_check_tuples_valid_tuple_size(tuple_size):
353
354
checks that checking the number of tuples (pairs, quadruplets, etc) raises
354
355
no warning if there is the right number of points in a tuple.
355
356
"""
356
- with pytest . warns ( None ) as record :
357
+ with warnings . catch_warnings ( record = True ) as record :
357
358
check_input (tuples_prep (), type_of_inputs = 'tuples' ,
358
359
preprocessor = mock_preprocessor , tuple_size = tuple_size )
359
360
check_input (tuples_no_prep (), type_of_inputs = 'tuples' , preprocessor = None ,
@@ -378,7 +379,7 @@ def test_check_tuples_valid_tuple_size(tuple_size):
378
379
[[2.6 , 2.3 ], [3.4 , 5.0 ]]])])
379
380
def test_check_tuples_valid_with_preprocessor (tuples ):
380
381
"""Test that valid inputs when using a preprocessor raises no warning"""
381
- with pytest . warns ( None ) as record :
382
+ with warnings . catch_warnings ( record = True ) as record :
382
383
check_input (tuples , type_of_inputs = 'tuples' ,
383
384
preprocessor = mock_preprocessor )
384
385
assert len (record ) == 0
@@ -399,7 +400,7 @@ def test_check_tuples_valid_with_preprocessor(tuples):
399
400
((3 , 1 ), (4 , 4 ), (29 , 4 )))])
400
401
def test_check_tuples_valid_without_preprocessor (tuples ):
401
402
"""Test that valid inputs when using no preprocessor raises no warning"""
402
- with pytest . warns ( None ) as record :
403
+ with warnings . catch_warnings ( record = True ) as record :
403
404
check_input (tuples , type_of_inputs = 'tuples' , preprocessor = None )
404
405
assert len (record ) == 0
405
406
@@ -408,12 +409,12 @@ def test_check_tuples_behaviour_auto_dtype():
408
409
"""Checks that check_tuples allows by default every type if using a
409
410
preprocessor, and numeric types if using no preprocessor"""
410
411
tuples_prep = [['img1.png' , 'img2.png' ], ['img3.png' , 'img5.png' ]]
411
- with pytest . warns ( None ) as record :
412
+ with warnings . catch_warnings ( record = True ) as record :
412
413
check_input (tuples_prep , type_of_inputs = 'tuples' ,
413
414
preprocessor = mock_preprocessor )
414
415
assert len (record ) == 0
415
416
416
- with pytest . warns ( None ) as record :
417
+ with warnings . catch_warnings ( record = True ) as record :
417
418
check_input (tuples_no_prep (), type_of_inputs = 'tuples' ) # numeric type
418
419
assert len (record ) == 0
419
420
@@ -549,7 +550,7 @@ def test_check_classic_invalid_dtype_not_convertible(preprocessor, points):
549
550
[2.6 , 2.3 ]])])
550
551
def test_check_classic_valid_with_preprocessor (points ):
551
552
"""Test that valid inputs when using a preprocessor raises no warning"""
552
- with pytest . warns ( None ) as record :
553
+ with warnings . catch_warnings ( record = True ) as record :
553
554
check_input (points , type_of_inputs = 'classic' ,
554
555
preprocessor = mock_preprocessor )
555
556
assert len (record ) == 0
@@ -570,7 +571,7 @@ def test_check_classic_valid_with_preprocessor(points):
570
571
(3 , 1 , 4 , 4 , 29 , 4 ))])
571
572
def test_check_classic_valid_without_preprocessor (points ):
572
573
"""Test that valid inputs when using no preprocessor raises no warning"""
573
- with pytest . warns ( None ) as record :
574
+ with warnings . catch_warnings ( record = True ) as record :
574
575
check_input (points , type_of_inputs = 'classic' , preprocessor = None )
575
576
assert len (record ) == 0
576
577
@@ -585,12 +586,12 @@ def test_check_classic_behaviour_auto_dtype():
585
586
"""Checks that check_input (for points) allows by default every type if
586
587
using a preprocessor, and numeric types if using no preprocessor"""
587
588
points_prep = ['img1.png' , 'img2.png' , 'img3.png' , 'img5.png' ]
588
- with pytest . warns ( None ) as record :
589
+ with warnings . catch_warnings ( record = True ) as record :
589
590
check_input (points_prep , type_of_inputs = 'classic' ,
590
591
preprocessor = mock_preprocessor )
591
592
assert len (record ) == 0
592
593
593
- with pytest . warns ( None ) as record :
594
+ with warnings . catch_warnings ( record = True ) as record :
594
595
check_input (points_no_prep (), type_of_inputs = 'classic' ) # numeric type
595
596
assert len (record ) == 0
596
597
0 commit comments