Skip to content

Commit cd5d658

Browse files
committed
Update whatsnew entry, modify tests for read_html to expect FutureWarning.
1 parent 56a4128 commit cd5d658

File tree

5 files changed

+59
-22
lines changed

5 files changed

+59
-22
lines changed

doc/source/whatsnew/v0.25.1.rst

-12
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@
77
What's new in 0.25.1 (July XX, 2019)
88
------------------------------------
99

10-
.. warning::
11-
12-
Starting with the version 0.25.1, :func:`read_html` function
13-
should get all its arguments but `io` and `match` as keyword
14-
keyword only.
15-
16-
.. warning::
17-
18-
Starting with the version 0.25.1, :func:`read_json` function
19-
should get all its arguments but `path_or_buf` as keyword
20-
arguments only.
21-
2210
Enhancements
2311
~~~~~~~~~~~~
2412

doc/source/whatsnew/v1.0.0.rst

+7-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,13 @@ Other API changes
5353
Deprecations
5454
~~~~~~~~~~~~
5555

56-
-
57-
-
56+
- Passing any arguments but `io` to :func:`read_html` as positional
57+
arguments is deprecated since version 1.0. All other arguments should
58+
be given as keyword arguments (:issue:`27573`).
59+
60+
- Passing any arguments but `path_or_buf` to :func:`read_json` as positional
61+
arguments is deprecated since version 1.0. All other arguments should
62+
be given as keyword arguments (:issue:`27573`).
5863

5964
.. _whatsnew_1000.prior_deprecations:
6065

pandas/io/html.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ def _parse(flavor, io, match, attrs, encoding, displayed_only, **kwargs):
921921
return ret
922922

923923

924-
@deprecate_nonkeyword_arguments(version="1.0", allowed_args=["io", "match"])
924+
@deprecate_nonkeyword_arguments(version="1.1", allowed_args=["io"])
925925
def read_html(
926926
io,
927927
match=".+",

pandas/io/json/_json.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def _write(
332332
return serialized
333333

334334

335-
@deprecate_nonkeyword_arguments(version="1.0", allowed_args=["path_or_buf"])
335+
@deprecate_nonkeyword_arguments(version="1.1", allowed_args=["path_or_buf"])
336336
def read_json(
337337
path_or_buf=None,
338338
orient=None,

pandas/tests/io/test_html.py

+50-6
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,65 @@ def test_spam_url(self):
137137
"http://ndb.nal.usda.gov/ndb/foods/show/300772?fg=&man=&"
138138
"lfacet=&format=&count=&max=25&offset=&sort=&qlookup=spam"
139139
)
140-
df1 = self.read_html(url, ".*Water.*")
141-
df2 = self.read_html(url, "Unit")
140+
# This test gives match to read_html as a positional
141+
# argument that is now deprecated, so expect FutureWarning
142+
with tm.assert_produces_warning(FutureWarning):
143+
df1 = self.read_html(url, ".*Water.*")
144+
with tm.assert_produces_warning(FutureWarning):
145+
df2 = self.read_html(url, "Unit")
146+
147+
assert_framelist_equal(df1, df2)
148+
149+
@network
150+
def test_spam_url_match_kwarg(self):
151+
url = (
152+
"http://ndb.nal.usda.gov/ndb/foods/show/300772?fg=&man=&"
153+
"lfacet=&format=&count=&max=25&offset=&sort=&qlookup=spam"
154+
)
155+
# Just like test_spam_url, but passes match as a keyword argument,
156+
# so expect no FutureWarning.
157+
df1 = self.read_html(url, match=".*Water.*")
158+
df2 = self.read_html(url, match="Unit")
142159

143160
assert_framelist_equal(df1, df2)
144161

145162
@pytest.mark.slow
146163
def test_banklist(self):
147-
df1 = self.read_html(self.banklist_data, ".*Florida.*", attrs={"id": "table"})
148-
df2 = self.read_html(self.banklist_data, "Metcalf Bank", attrs={"id": "table"})
164+
# This test gives match to read_html as a positional
165+
# argument that is now deprecated, so expect FutureWarning
166+
with tm.assert_produces_warning(FutureWarning):
167+
df1 = self.read_html(self.banklist_data, ".*Florida.*", attrs={"id": "table"})
168+
with tm.assert_produces_warning(FutureWarning):
169+
df2 = self.read_html(self.banklist_data, "Metcalf Bank", attrs={"id": "table"})
170+
171+
assert_framelist_equal(df1, df2)
172+
173+
@pytest.mark.slow
174+
def test_banklist_match_kwarg(self):
175+
# Just like test_banklist, but passes match as a keyword argument,
176+
# so expect no FutureWarning.
177+
df1 = self.read_html(self.banklist_data, match=".*Florida.*", attrs={"id": "table"})
178+
df2 = self.read_html(self.banklist_data, match="Metcalf Bank", attrs={"id": "table"})
149179

150180
assert_framelist_equal(df1, df2)
151181

152182
def test_spam(self):
153-
df1 = self.read_html(self.spam_data, ".*Water.*")
154-
df2 = self.read_html(self.spam_data, "Unit")
183+
# This test gives match to read_html as a positional
184+
# argument that is now deprecated, so expect FutureWarning
185+
with tm.assert_produces_warning(FutureWarning):
186+
df1 = self.read_html(self.spam_data, ".*Water.*")
187+
with tm.assert_produces_warning(FutureWarning):
188+
df2 = self.read_html(self.spam_data, "Unit")
189+
assert_framelist_equal(df1, df2)
190+
191+
assert df1[0].iloc[0, 0] == "Proximates"
192+
assert df1[0].columns[0] == "Nutrient"
193+
194+
def test_spam_match_kwarg(self):
195+
# Just like test_spam, but passes match as a keyword argument,
196+
# so expect no FutureWarning.
197+
df1 = self.read_html(self.spam_data, match=".*Water.*")
198+
df2 = self.read_html(self.spam_data, match="Unit")
155199
assert_framelist_equal(df1, df2)
156200

157201
assert df1[0].iloc[0, 0] == "Proximates"

0 commit comments

Comments
 (0)