Skip to content

Commit 2dd75ca

Browse files
authored
TST: Ensure tm.network has pytest.mark.network (#45732)
1 parent f385fc0 commit 2dd75ca

13 files changed

+2757
-25
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, 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
@@ -985,18 +985,16 @@ def test_misc_example(self):
985985
expected = DataFrame([[1, 2], [1, 2]], columns=["a", "b"])
986986
tm.assert_frame_equal(result, expected)
987987

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

996+
@pytest.mark.network
998997
@tm.network
999-
@pytest.mark.single
1000998
@pytest.mark.parametrize(
1001999
"field,dtype",
10021000
[

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
@@ -23,17 +23,13 @@
2323

2424

2525
@pytest.mark.network
26+
@tm.network
2627
@pytest.mark.parametrize("mode", ["explicit", "infer"])
2728
@pytest.mark.parametrize("engine", ["python", "c"])
2829
def test_compressed_urls(salaries_table, mode, engine, compression_only):
29-
extension = icom._compression_to_extension[compression_only]
30-
check_compressed_urls(salaries_table, compression_only, extension, mode, engine)
31-
32-
33-
@tm.network
34-
def check_compressed_urls(salaries_table, compression, extension, mode, engine):
3530
# test reading compressed urls with various engines and
3631
# extension inference
32+
extension = icom._compression_to_extension[compression_only]
3733
base_url = (
3834
"https://github.com/pandas-dev/pandas/raw/main/"
3935
"pandas/tests/io/parser/data/salaries.csv"
@@ -42,13 +38,14 @@ def check_compressed_urls(salaries_table, compression, extension, mode, engine):
4238
url = base_url + extension
4339

4440
if mode != "explicit":
45-
compression = mode
41+
compression_only = mode
4642

47-
url_table = read_csv(url, sep="\t", compression=compression, engine=engine)
43+
url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine)
4844
tm.assert_frame_equal(url_table, salaries_table)
4945

5046

51-
@tm.network("https://raw.githubusercontent.com/", check_before_test=True)
47+
@pytest.mark.network
48+
@tm.network
5249
def test_url_encoding_csv():
5350
"""
5451
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
@@ -134,6 +134,7 @@ def test_to_html_compat(self):
134134
res = self.read_html(out, attrs={"class": "dataframe"}, index_col=0)[0]
135135
tm.assert_frame_equal(res, df)
136136

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

154155
assert_framelist_equal(df1, df2)
155156

157+
@pytest.mark.network
156158
@tm.network
157159
def test_banklist_url(self):
158160
url = "http://www.fdic.gov/resources/resolutions/bank-failures/failed-bank-list/index.html" # noqa E501
@@ -169,6 +171,7 @@ def test_banklist_url(self):
169171

170172
assert_framelist_equal(df1, df2)
171173

174+
@pytest.mark.network
172175
@tm.network
173176
def test_spam_url(self):
174177
url = (
@@ -313,13 +316,15 @@ def test_file_like(self, spam_data):
313316

314317
assert_framelist_equal(df1, df2)
315318

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

321-
@tm.network
322325
@pytest.mark.slow
326+
@pytest.mark.network
327+
@tm.network
323328
def test_invalid_url(self):
324329
msg = (
325330
"Name or service not known|Temporary failure in name resolution|"
@@ -402,12 +407,14 @@ def test_negative_skiprows(self, spam_data):
402407
with pytest.raises(ValueError, match=msg):
403408
self.read_html(spam_data, match="Water", skiprows=-1)
404409

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

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

pandas/tests/io/test_parquet.py

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

383+
@pytest.mark.network
383384
@tm.network
384385
def test_parquet_read_from_url(self, df_compat, engine):
385386
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(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

+8-3
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,10 @@ 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+
@tm.network
260261
def test_parser_consistency_url():
261262
url = (
262263
"https://data.cityofchicago.org/api/views/"
@@ -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,13 +1103,14 @@ def test_unsuported_compression(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")
11051109
@pytest.mark.skipif(
11061110
os.environ.get("PANDAS_CI", "0") == "1",
11071111
reason="2022.1.17: Hanging on the CI min versions build.",
11081112
)
1113+
@tm.network
11091114
def test_s3_parser_consistency():
11101115
# Python Software Foundation (2019 IRS-990 RETURN)
11111116
s3 = "s3://irs-form-990/201923199349319487_public.xml"

pandas/tests/test_downstream.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def test_oo_optimized_datetime_index_unpickle():
124124
)
125125

126126

127+
@pytest.mark.network
127128
@tm.network
128129
# Cython import warning
129130
@pytest.mark.filterwarnings("ignore:pandas.util.testing is deprecated")
@@ -164,6 +165,7 @@ def test_scikit_learn():
164165

165166

166167
# Cython import warning and traitlets
168+
@pytest.mark.network
167169
@tm.network
168170
@pytest.mark.filterwarnings("ignore")
169171
def test_seaborn():
@@ -178,12 +180,13 @@ def test_pandas_gbq():
178180
pandas_gbq = import_module("pandas_gbq") # noqa:F841
179181

180182

183+
@pytest.mark.network
184+
@tm.network
181185
@pytest.mark.xfail(
182186
raises=ValueError,
183187
reason="The Quandl API key must be provided either through the api_key "
184188
"variable or through the environmental variable QUANDL_API_KEY",
185189
)
186-
@tm.network
187190
def test_pandas_datareader():
188191

189192
pandas_datareader = import_module("pandas_datareader")

0 commit comments

Comments
 (0)