Skip to content

Commit cd29b25

Browse files
committed
fixed broken pytest usage and a failing test
we should use raise(match=) instead of raise(message=)
1 parent 8568cf8 commit cd29b25

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

larray/tests/test_array.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -608,29 +608,29 @@ def test_getitem_guess_axis(array):
608608
assert_array_equal(array[g], raw[..., [0, 4, 8]])
609609

610610
# key with duplicate axes
611-
with pytest.raises(ValueError, message="key has several values for axis: age"):
611+
with pytest.raises(ValueError, match="key has several values for axis: age"):
612612
array[[1, 2], [3, 4]]
613613

614614
# key with invalid label (ie label not found on any axis)
615-
with pytest.raises(ValueError, message="999 is not a valid label for any axis"):
615+
with pytest.raises(ValueError, match="999 is not a valid label for any axis"):
616616
array[[1, 2], 999]
617617

618618
# key with invalid label list (ie list of labels not found on any axis)
619-
with pytest.raises(ValueError, message=r"\[998, 999\] is not a valid label for any axis"):
619+
with pytest.raises(ValueError, match=r"\[998, 999\] is not a valid label for any axis"):
620620
array[[1, 2], [998, 999]]
621621

622622
# key with partial invalid list (ie list containing a label not found
623623
# on any axis)
624624
# FIXME: the message should be the same as for 999, 4 (ie it should NOT mention age).
625-
with pytest.raises(ValueError, message=r"age\[3, 999\] is not a valid label for any axis"):
625+
with pytest.raises(ValueError, match=r"age\[3, 999\] is not a valid label for any axis"):
626626
array[[1, 2], [3, 999]]
627627

628-
with pytest.raises(ValueError, message=r"\[999, 4\] is not a valid label for any axis"):
628+
with pytest.raises(ValueError, match=r"\[999, 4\] is not a valid label for any axis"):
629629
array[[1, 2], [999, 4]]
630630

631631
# ambiguous key
632632
arr = ndtest("a=l0,l1;b=l1,l2")
633-
with pytest.raises(ValueError, message=r"l1 is ambiguous \(valid in a, b\)"):
633+
with pytest.raises(ValueError, match=r"l1 is ambiguous \(valid in a, b\)"):
634634
arr['l1']
635635

636636
# ambiguous key disambiguated via string
@@ -671,7 +671,7 @@ def test_getitem_positional_group(array):
671671
assert_array_equal(array[..., lipro159], raw[..., [0, 4, 8]])
672672

673673
# key with duplicate axes
674-
with pytest.raises(ValueError, message="key has several values for axis: age"):
674+
with pytest.raises(ValueError, match="key has several values for axis: age"):
675675
array[age.i[1, 2], age.i[3, 4]]
676676

677677

@@ -716,7 +716,7 @@ def test_getitem_abstract_positional(array):
716716
assert_array_equal(array[..., lipro159], raw[..., [0, 4, 8]])
717717

718718
# key with duplicate axes
719-
with pytest.raises(ValueError, message="key has several values for axis: age"):
719+
with pytest.raises(ValueError, match="key has several values for axis: age"):
720720
array[X.age.i[2, 3], X.age.i[1, 5]]
721721

722722

@@ -2319,7 +2319,7 @@ def test_sum_with_groups_from_other_axis(small_array):
23192319
# use a group (from another axis) which is incompatible with the axis of
23202320
# the same name in the array
23212321
lipro4 = Axis('lipro=P01,P03,P16')
2322-
with pytest.raises(ValueError, message=r"lipro\['P01', 'P16'\] is not a valid label for any axis"):
2322+
with pytest.raises(ValueError, match=r"lipro\['P01', 'P16'\] is not a valid label for any axis"):
23232323
small_array.sum(lipro4['P01,P16'])
23242324

23252325

@@ -3237,8 +3237,8 @@ def test_read_excel_xlwings():
32373237
# invalid keyword argument #
32383238
##############################
32393239

3240-
with pytest.raises(TypeError, message="'dtype' is an invalid keyword argument for this function "
3241-
"when using the xlwings backend"):
3240+
with pytest.raises(TypeError, match="'dtype' is an invalid keyword argument for this function "
3241+
"when using the xlwings backend"):
32423242
read_excel(inputpath('test.xlsx'), engine='xlwings', dtype=float)
32433243

32443244
#################
@@ -4064,7 +4064,7 @@ def test_to_excel_xlwings(tmpdir):
40644064
# sheet name of 31 characters (= maximum authorized length)
40654065
a3.to_excel(fpath, "sheetname_of_exactly_31_chars__", engine='xlwings')
40664066
# sheet name longer than 31 characters
4067-
with pytest.raises(ValueError, message="Sheet names cannot exceed 31 characters"):
4067+
with pytest.raises(ValueError, match="Sheet names cannot exceed 31 characters"):
40684068
a3.to_excel(fpath, "sheetname_longer_than_31_characters", engine='xlwings')
40694069

40704070

larray/tests/test_axis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def test_h5_io(tmpdir):
403403
lipro2 = read_hdf(fpath, key=lipro.name)
404404
assert lipro.equals(lipro2)
405405
# anonymous axis
406-
with pytest.raises(ValueError, message="Argument key must be provided explicitly in case of anonymous axis"):
406+
with pytest.raises(ValueError, match="Argument key must be provided explicitly in case of anonymous axis"):
407407
anonymous.to_hdf(fpath)
408408
# wildcard axis
409409
wildcard.to_hdf(fpath)

larray/tests/test_group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def test_h5_io_lgroup(tmpdir):
199199
named2 = read_hdf(fpath, key=named.name)
200200
assert all(named == named2)
201201
# anonymous group
202-
with pytest.raises(ValueError, message="Argument key must be provided explicitly in case of anonymous axis"):
202+
with pytest.raises(ValueError, match="Argument key must be provided explicitly in case of anonymous group"):
203203
anonymous.to_hdf(fpath)
204204
# wildcard group
205205
wildcard.to_hdf(fpath)
@@ -434,7 +434,7 @@ def test_h5_io_igroup(tmpdir):
434434
named2 = read_hdf(fpath, key=named.name)
435435
assert all(named == named2)
436436
# anonymous group
437-
with pytest.raises(ValueError, message="Argument key must be provided explicitly in case of anonymous axis"):
437+
with pytest.raises(ValueError, match="Argument key must be provided explicitly in case of anonymous group"):
438438
anonymous.to_hdf(fpath)
439439
# wildcard group
440440
wildcard.to_hdf(fpath)

larray/tests/test_ipfp.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,38 +27,38 @@ def test_ipfp():
2727
[1.1538461538461537, 0.8461538461538463]])
2828

2929
# inverted target sums
30-
with pytest.raises(ValueError, message=r"axes of target sum along a \(axis 0\) do not match corresponding "
31-
r"array axes: got {a} but expected {b}. Are the target sums in the "
32-
r"correct order\?"):
30+
with pytest.raises(ValueError, match=r"axes of target sum along a \(axis 0\) do not match corresponding "
31+
r"array axes: got {a} but expected {b}. Are the target sums in the "
32+
r"correct order\?"):
3333
ipfp([along_b, along_a], initial)
3434

3535
# different target sums totals
3636
along_a = LArray([2, 1], b)
3737
along_b = LArray([1, 3], a)
38-
with pytest.raises(ValueError, message=r"target sum along b \(axis 1\) is different than target sum along "
39-
r"a \(axis 0\): 4 vs 3"):
38+
with pytest.raises(ValueError, match=r"target sum along b \(axis 1\) is different than target sum along "
39+
r"a \(axis 0\): 4 vs 3"):
4040
ipfp([along_a, along_b], initial)
4141

4242
# all zero values
4343
initial = LArray([[0, 0], [1, 2]], [a, b])
4444
along_a = LArray([2, 1], b)
4545
along_b = LArray([1, 2], a)
46-
with pytest.raises(ValueError, message="found all zero values sum along b \\(axis 1\\) but non zero target "
47-
"sum:\na0: 1"):
46+
with pytest.raises(ValueError, match="found all zero values sum along b \\(axis 1\\) but non zero target "
47+
"sum:\na0: 1"):
4848
ipfp([along_a, along_b], initial)
4949

5050
# zero target sum
5151
initial = LArray([[2, 1], [1, 2]], [a, b])
5252
along_a = LArray([0, 1], b)
5353
along_b = LArray([1, 0], a)
54-
with pytest.raises(ValueError, message="found Non Zero Values but Zero target Sum \\(nzvzs\\) along a "
55-
"\\(axis 0\\), use nzvzs='warn' or 'fix' to set them to zero "
56-
"automatically:\nb0: 3"):
54+
with pytest.raises(ValueError, match="found Non Zero Values but Zero target Sum \\(nzvzs\\) along a "
55+
"\\(axis 0\\), use nzvzs='warn' or 'fix' to set them to zero "
56+
"automatically:\nb0: 3"):
5757
ipfp([along_a, along_b], initial)
5858

5959
# negative initial values
6060
initial = LArray([[2, -1], [1, 2]], [a, b])
61-
with pytest.raises(ValueError, message="negative value\\(s\\) found:\na0_b1: -1"):
61+
with pytest.raises(ValueError, match="negative value\\(s\\) found:\na0_b1: -1"):
6262
ipfp([along_a, along_b], initial)
6363

6464
# def test_ipfp_big():

0 commit comments

Comments
 (0)