Skip to content

Commit ad6e9bc

Browse files
authored
Update test_deprecate_nonkeyword_arguments.py
Use assert_produces_warning(None) context to check whether no warnings are produced.
1 parent 0922d6d commit ad6e9bc

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

pandas/tests/util/test_deprecate_nonkeyword_arguments.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ def f(a, b=0, c=0, d=0):
1616
return a + b + c + d
1717

1818

19-
def test_one_arguments():
19+
def test_one_argument():
2020
"""
2121
Check whether no future warning is produced if one
2222
positional argument given.
2323
"""
24-
assert f(19) == 19
24+
with tm.assert_produces_warning(None):
25+
assert f(19) == 19
2526

2627

2728
def test_one_and_one_arguments():
@@ -30,15 +31,17 @@ def test_one_and_one_arguments():
3031
positional argument and one keyword argument are
3132
given.
3233
"""
33-
assert f(19, d=6) == 25
34+
with tm.assert_produces_warning(None):
35+
assert f(19, d=6) == 25
3436

3537

3638
def test_two_arguments():
3739
"""
3840
Check whether no future warning is produced if two
3941
positional arguments given.
4042
"""
41-
assert f(1, 5) == 6
43+
with tm.assert_produces_warning(None):
44+
assert f(1, 5) == 6
4245

4346

4447
def test_two_and_two_arguments():
@@ -47,7 +50,8 @@ def test_two_and_two_arguments():
4750
positional arguments and two keyword arguments are
4851
given.
4952
"""
50-
assert f(1, 3, c=3, d=5) == 12
53+
with tm.assert_produces_warning(None):
54+
assert f(1, 3, c=3, d=5) == 12
5155

5256

5357
def test_three_arguments():
@@ -74,7 +78,8 @@ def g(a, b=0, c=0, d=0):
7478
Sum of one to four numbers, but three of them have default
7579
values, so may be given as keyword arguments only.
7680
"""
77-
return a + b + c + d
81+
with tm.assert_produces_warning(None):
82+
return a + b + c + d
7883

7984

8085
def test_one_and_three_arguments_default_allowed_args():
@@ -85,7 +90,8 @@ def test_one_and_three_arguments_default_allowed_args():
8590
option, meaning that all arguments with default value
8691
are keyword-only.
8792
"""
88-
assert g(1, b=3, c=3, d=5) == 12
93+
with tm.assert_produces_warning(None):
94+
assert g(1, b=3, c=3, d=5) == 12
8995

9096

9197
def test_three_arguments_default_allowed_args():

0 commit comments

Comments
 (0)