Skip to content

Commit db131b6

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

File tree

13 files changed

+2762
-26
lines changed

13 files changed

+2762
-26
lines changed

pandas/tests/io/conftest.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2716 additions & 0 deletions
Large diffs are not rendered by default.

pandas/tests/io/json/test_pandas.py

Lines changed: 4 additions & 6 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 6 additions & 9 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 8 additions & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 4 additions & 2 deletions
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

0 commit comments

Comments
 (0)