Skip to content

Commit db131b6

Browse files
authored
Backport PR pandas-dev#45732: TST: Ensure tm.network has pytest.mark.network (pandas-dev#45741)
1 parent 8a0fb40 commit db131b6

13 files changed

+2762
-26
lines changed

pandas/tests/io/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def s3_base(worker_id):
114114
proc.terminate()
115115

116116

117-
@pytest.fixture()
117+
@pytest.fixture
118118
def s3_resource(s3_base, tips_file, jsonl_file, feather_file):
119119
"""
120120
Sets up S3 bucket with contents

pandas/tests/io/excel/test_readers.py

+1
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ def test_corrupt_bytes_raises(self, read_ext, engine):
763763
with pytest.raises(error, match=msg):
764764
pd.read_excel(bad_stream)
765765

766+
@pytest.mark.network
766767
@tm.network
767768
def test_read_from_http_url(self, read_ext):
768769
url = (

pandas/tests/io/json/data/teams.csv

+2,716
Large diffs are not rendered by default.

pandas/tests/io/json/test_pandas.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -987,18 +987,16 @@ def test_misc_example(self):
987987
expected = DataFrame([[1, 2], [1, 2]], columns=["a", "b"])
988988
tm.assert_frame_equal(result, expected)
989989

990-
@tm.network
991-
@pytest.mark.single
992-
def test_round_trip_exception_(self):
990+
def test_round_trip_exception_(self, datapath):
993991
# GH 3867
994-
csv = "https://raw.github.com/hayd/lahman2012/master/csvs/Teams.csv"
995-
df = pd.read_csv(csv)
992+
path = datapath("io", "json", "data", "teams.csv")
993+
df = pd.read_csv(path)
996994
s = df.to_json()
997995
result = read_json(s)
998996
tm.assert_frame_equal(result.reindex(index=df.index, columns=df.columns), df)
999997

998+
@pytest.mark.network
1000999
@tm.network
1001-
@pytest.mark.single
10021000
@pytest.mark.parametrize(
10031001
"field,dtype",
10041002
[

pandas/tests/io/parser/common/test_file_buffer_url.py

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
pytestmark = pytest.mark.usefixtures("pyarrow_skip")
2727

2828

29+
@pytest.mark.network
2930
@tm.network
3031
def test_url(all_parsers, csv_dir_path):
3132
parser = all_parsers

pandas/tests/io/parser/test_network.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,13 @@
2222

2323

2424
@pytest.mark.network
25+
@tm.network
2526
@pytest.mark.parametrize("mode", ["explicit", "infer"])
2627
@pytest.mark.parametrize("engine", ["python", "c"])
2728
def test_compressed_urls(salaries_table, mode, engine, compression_only):
28-
extension = icom._compression_to_extension[compression_only]
29-
check_compressed_urls(salaries_table, compression_only, extension, mode, engine)
30-
31-
32-
@tm.network
33-
def check_compressed_urls(salaries_table, compression, extension, mode, engine):
3429
# test reading compressed urls with various engines and
3530
# extension inference
31+
extension = icom._compression_to_extension[compression_only]
3632
base_url = (
3733
"https://github.com/pandas-dev/pandas/raw/main/"
3834
"pandas/tests/io/parser/data/salaries.csv"
@@ -41,13 +37,14 @@ def check_compressed_urls(salaries_table, compression, extension, mode, engine):
4137
url = base_url + extension
4238

4339
if mode != "explicit":
44-
compression = mode
40+
compression_only = mode
4541

46-
url_table = read_csv(url, sep="\t", compression=compression, engine=engine)
42+
url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine)
4743
tm.assert_frame_equal(url_table, salaries_table)
4844

4945

50-
@tm.network("https://raw.githubusercontent.com/", check_before_test=True)
46+
@pytest.mark.network
47+
@tm.network
5148
def test_url_encoding_csv():
5249
"""
5350
read_csv should honor the requested encoding for URLs.

pandas/tests/io/test_feather.py

+1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ def test_passthrough_keywords(self):
181181
df = tm.makeDataFrame().reset_index()
182182
self.check_round_trip(df, write_kwargs={"version": 1})
183183

184+
@pytest.mark.network
184185
@tm.network
185186
def test_http_path(self, feather_file):
186187
# GH 29055

pandas/tests/io/test_html.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def test_to_html_compat(self):
133133
res = self.read_html(out, attrs={"class": "dataframe"}, index_col=0)[0]
134134
tm.assert_frame_equal(res, df)
135135

136+
@pytest.mark.network
136137
@tm.network
137138
def test_banklist_url_positional_match(self):
138139
url = "http://www.fdic.gov/resources/resolutions/bank-failures/failed-bank-list/index.html" # noqa E501
@@ -152,6 +153,7 @@ def test_banklist_url_positional_match(self):
152153

153154
assert_framelist_equal(df1, df2)
154155

156+
@pytest.mark.network
155157
@tm.network
156158
def test_banklist_url(self):
157159
url = "http://www.fdic.gov/resources/resolutions/bank-failures/failed-bank-list/index.html" # noqa E501
@@ -168,6 +170,7 @@ def test_banklist_url(self):
168170

169171
assert_framelist_equal(df1, df2)
170172

173+
@pytest.mark.network
171174
@tm.network
172175
def test_spam_url(self):
173176
url = (
@@ -316,13 +319,15 @@ def test_file_like(self):
316319

317320
assert_framelist_equal(df1, df2)
318321

322+
@pytest.mark.network
319323
@tm.network
320324
def test_bad_url_protocol(self):
321325
with pytest.raises(URLError, match="urlopen error unknown url type: git"):
322326
self.read_html("git://github.com", match=".*Water.*")
323327

324-
@tm.network
325328
@pytest.mark.slow
329+
@pytest.mark.network
330+
@tm.network
326331
def test_invalid_url(self):
327332
msg = (
328333
"Name or service not known|Temporary failure in name resolution|"
@@ -403,12 +408,14 @@ def test_negative_skiprows(self):
403408
with pytest.raises(ValueError, match=msg):
404409
self.read_html(self.spam_data, match="Water", skiprows=-1)
405410

411+
@pytest.mark.network
406412
@tm.network
407413
def test_multiple_matches(self):
408414
url = "https://docs.python.org/2/"
409415
dfs = self.read_html(url, match="Python")
410416
assert len(dfs) > 1
411417

418+
@pytest.mark.network
412419
@tm.network
413420
def test_python_docs_table(self):
414421
url = "https://docs.python.org/2/"

pandas/tests/io/test_parquet.py

+1
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ def check_external_error_on_write(self, df, engine, exc):
379379
with tm.external_error_raised(exc):
380380
to_parquet(df, path, engine, compression=None)
381381

382+
@pytest.mark.network
382383
@tm.network
383384
def test_parquet_read_from_url(self, df_compat, engine):
384385
if engine != "auto":

pandas/tests/io/test_s3.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,19 @@ def test_streaming_s3_objects():
2121
read_csv(body)
2222

2323

24-
@tm.network
2524
@td.skip_if_no("s3fs")
25+
@pytest.mark.network
26+
@tm.network
2627
def test_read_without_creds_from_pub_bucket():
2728
# GH 34626
2829
# Use Amazon Open Data Registry - https://registry.opendata.aws/gdelt
2930
result = read_csv("s3://gdelt-open-data/events/1981.csv", nrows=3)
3031
assert len(result) == 3
3132

3233

33-
@tm.network
3434
@td.skip_if_no("s3fs")
35+
@pytest.mark.network
36+
@tm.network
3537
def test_read_with_creds_from_pub_bucket():
3638
# Ensure we can read from a public bucket with credentials
3739
# GH 34626

pandas/tests/io/xml/test_to_xml.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1331,10 +1331,10 @@ def test_unsuported_compression(datapath, parser):
13311331
# STORAGE OPTIONS
13321332

13331333

1334-
@tm.network
13351334
@td.skip_if_no("s3fs")
13361335
@td.skip_if_no("lxml")
1337-
def test_s3_permission_output(parser):
1336+
def test_s3_permission_output(parser, s3_resource):
1337+
# s3_resource hosts pandas-test
13381338
import s3fs
13391339

13401340
with pytest.raises(PermissionError, match="Access Denied"):

pandas/tests/io/xml/test_xml.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,11 @@ def test_parser_consistency_file(datapath):
254254
tm.assert_frame_equal(df_file_lxml, df_file_etree)
255255

256256

257-
@tm.network
257+
@pytest.mark.network
258258
@pytest.mark.slow
259259
@td.skip_if_no("lxml")
260-
def test_parser_consistency_url(datapath):
260+
@tm.network
261+
def test_parser_consistency_url():
261262
url = (
262263
"https://data.cityofchicago.org/api/views/"
263264
"8pix-ypme/rows.xml?accessType=DOWNLOAD"
@@ -401,6 +402,7 @@ def test_wrong_file_path_etree():
401402
read_xml(filename, parser="etree")
402403

403404

405+
@pytest.mark.network
404406
@tm.network
405407
@td.skip_if_no("lxml")
406408
def test_url():
@@ -421,6 +423,7 @@ def test_url():
421423
tm.assert_frame_equal(df_url, df_expected)
422424

423425

426+
@pytest.mark.network
424427
@tm.network
425428
def test_wrong_url(parser):
426429
with pytest.raises(HTTPError, match=("HTTP Error 404: Not Found")):
@@ -1016,8 +1019,9 @@ def test_empty_stylesheet(val):
10161019
read_xml(kml, stylesheet=val)
10171020

10181021

1019-
@tm.network
1022+
@pytest.mark.network
10201023
@td.skip_if_no("lxml")
1024+
@tm.network
10211025
def test_online_stylesheet():
10221026
xml = "https://www.w3schools.com/xml/cdcatalog_with_xsl.xml"
10231027
xsl = "https://www.w3schools.com/xml/cdcatalog.xsl"
@@ -1099,9 +1103,14 @@ def test_unsuported_compression(datapath, parser):
10991103
# STORAGE OPTIONS
11001104

11011105

1102-
@tm.network
1106+
@pytest.mark.network
11031107
@td.skip_if_no("s3fs")
11041108
@td.skip_if_no("lxml")
1109+
@pytest.mark.skipif(
1110+
os.environ.get("PANDAS_CI", "0") == "1",
1111+
reason="2022.1.17: Hanging on the CI min versions build.",
1112+
)
1113+
@tm.network
11051114
def test_s3_parser_consistency():
11061115
# Python Software Foundation (2019 IRS-990 RETURN)
11071116
s3 = "s3://irs-form-990/201923199349319487_public.xml"

pandas/tests/test_downstream.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def test_oo_optimized_datetime_index_unpickle():
118118
)
119119

120120

121+
@pytest.mark.network
121122
@tm.network
122123
# Cython import warning
123124
@pytest.mark.filterwarnings("ignore:pandas.util.testing is deprecated")
@@ -158,6 +159,7 @@ def test_scikit_learn(df):
158159

159160

160161
# Cython import warning and traitlets
162+
@pytest.mark.network
161163
@tm.network
162164
@pytest.mark.filterwarnings("ignore")
163165
def test_seaborn():
@@ -172,12 +174,13 @@ def test_pandas_gbq(df):
172174
pandas_gbq = import_module("pandas_gbq") # noqa:F841
173175

174176

177+
@pytest.mark.network
178+
@tm.network
175179
@pytest.mark.xfail(
176180
raises=ValueError,
177181
reason="The Quandl API key must be provided either through the api_key "
178182
"variable or through the environmental variable QUANDL_API_KEY",
179183
)
180-
@tm.network
181184
def test_pandas_datareader():
182185

183186
pandas_datareader = import_module("pandas_datareader")

0 commit comments

Comments
 (0)