Skip to content

TST: Ensure tm.network has pytest.mark.network #45732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/tests/io/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def s3_base(worker_id):
proc.terminate()


@pytest.fixture()
@pytest.fixture
def s3_resource(s3_base, tips_file, jsonl_file, feather_file):
"""
Sets up S3 bucket with contents
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/io/excel/test_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ def test_corrupt_bytes_raises(self, engine):
with pytest.raises(error, match=msg):
pd.read_excel(bad_stream)

@pytest.mark.network
@tm.network
def test_read_from_http_url(self, read_ext):
url = (
Expand Down
2,716 changes: 2,716 additions & 0 deletions pandas/tests/io/json/data/teams.csv

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions pandas/tests/io/json/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,18 +985,16 @@ def test_misc_example(self):
expected = DataFrame([[1, 2], [1, 2]], columns=["a", "b"])
tm.assert_frame_equal(result, expected)

@tm.network
@pytest.mark.single
def test_round_trip_exception_(self):
def test_round_trip_exception_(self, datapath):
# GH 3867
csv = "https://raw.github.com/hayd/lahman2012/master/csvs/Teams.csv"
df = pd.read_csv(csv)
path = datapath("io", "json", "data", "teams.csv")
df = pd.read_csv(path)
s = df.to_json()
result = read_json(s)
tm.assert_frame_equal(result.reindex(index=df.index, columns=df.columns), df)

@pytest.mark.network
@tm.network
@pytest.mark.single
@pytest.mark.parametrize(
"field,dtype",
[
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/io/parser/common/test_file_buffer_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
pytestmark = pytest.mark.usefixtures("pyarrow_skip")


@pytest.mark.network
@tm.network
def test_url(all_parsers, csv_dir_path):
parser = all_parsers
Expand Down
15 changes: 6 additions & 9 deletions pandas/tests/io/parser/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,13 @@


@pytest.mark.network
@tm.network
@pytest.mark.parametrize("mode", ["explicit", "infer"])
@pytest.mark.parametrize("engine", ["python", "c"])
def test_compressed_urls(salaries_table, mode, engine, compression_only):
extension = icom._compression_to_extension[compression_only]
check_compressed_urls(salaries_table, compression_only, extension, mode, engine)


@tm.network
def check_compressed_urls(salaries_table, compression, extension, mode, engine):
# test reading compressed urls with various engines and
# extension inference
extension = icom._compression_to_extension[compression_only]
base_url = (
"https://github.com/pandas-dev/pandas/raw/main/"
"pandas/tests/io/parser/data/salaries.csv"
Expand All @@ -42,13 +38,14 @@ def check_compressed_urls(salaries_table, compression, extension, mode, engine):
url = base_url + extension

if mode != "explicit":
compression = mode
compression_only = mode

url_table = read_csv(url, sep="\t", compression=compression, engine=engine)
url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine)
tm.assert_frame_equal(url_table, salaries_table)


@tm.network("https://raw.githubusercontent.com/", check_before_test=True)
@pytest.mark.network
@tm.network
def test_url_encoding_csv():
"""
read_csv should honor the requested encoding for URLs.
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/io/test_feather.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def test_passthrough_keywords(self):
df = tm.makeDataFrame().reset_index()
self.check_round_trip(df, write_kwargs={"version": 1})

@pytest.mark.network
@tm.network
def test_http_path(self, feather_file):
# GH 29055
Expand Down
9 changes: 8 additions & 1 deletion pandas/tests/io/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def test_to_html_compat(self):
res = self.read_html(out, attrs={"class": "dataframe"}, index_col=0)[0]
tm.assert_frame_equal(res, df)

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

assert_framelist_equal(df1, df2)

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

assert_framelist_equal(df1, df2)

@pytest.mark.network
@tm.network
def test_spam_url(self):
url = (
Expand Down Expand Up @@ -313,13 +316,15 @@ def test_file_like(self, spam_data):

assert_framelist_equal(df1, df2)

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

@tm.network
@pytest.mark.slow
@pytest.mark.network
@tm.network
def test_invalid_url(self):
msg = (
"Name or service not known|Temporary failure in name resolution|"
Expand Down Expand Up @@ -402,12 +407,14 @@ def test_negative_skiprows(self, spam_data):
with pytest.raises(ValueError, match=msg):
self.read_html(spam_data, match="Water", skiprows=-1)

@pytest.mark.network
@tm.network
def test_multiple_matches(self):
url = "https://docs.python.org/2/"
dfs = self.read_html(url, match="Python")
assert len(dfs) > 1

@pytest.mark.network
@tm.network
def test_python_docs_table(self):
url = "https://docs.python.org/2/"
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/io/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ def check_external_error_on_write(self, df, engine, exc):
with tm.external_error_raised(exc):
to_parquet(df, path, engine, compression=None)

@pytest.mark.network
@tm.network
def test_parquet_read_from_url(self, df_compat, engine):
if engine != "auto":
Expand Down
6 changes: 4 additions & 2 deletions pandas/tests/io/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ def test_streaming_s3_objects():
read_csv(body)


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


@tm.network
@td.skip_if_no("s3fs")
@pytest.mark.network
@tm.network
def test_read_with_creds_from_pub_bucket():
# Ensure we can read from a public bucket with credentials
# GH 34626
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/io/xml/test_to_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1331,10 +1331,10 @@ def test_unsuported_compression(parser):
# STORAGE OPTIONS


@tm.network
@td.skip_if_no("s3fs")
@td.skip_if_no("lxml")
def test_s3_permission_output(parser):
def test_s3_permission_output(parser, s3_resource):
# s3_resource hosts pandas-test
import s3fs

with pytest.raises(PermissionError, match="Access Denied"):
Expand Down
11 changes: 8 additions & 3 deletions pandas/tests/io/xml/test_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,10 @@ def test_parser_consistency_file(datapath):
tm.assert_frame_equal(df_file_lxml, df_file_etree)


@tm.network
@pytest.mark.network
@pytest.mark.slow
@td.skip_if_no("lxml")
@tm.network
def test_parser_consistency_url():
url = (
"https://data.cityofchicago.org/api/views/"
Expand Down Expand Up @@ -401,6 +402,7 @@ def test_wrong_file_path_etree():
read_xml(filename, parser="etree")


@pytest.mark.network
@tm.network
@td.skip_if_no("lxml")
def test_url():
Expand All @@ -421,6 +423,7 @@ def test_url():
tm.assert_frame_equal(df_url, df_expected)


@pytest.mark.network
@tm.network
def test_wrong_url(parser):
with pytest.raises(HTTPError, match=("HTTP Error 404: Not Found")):
Expand Down Expand Up @@ -1016,8 +1019,9 @@ def test_empty_stylesheet(val):
read_xml(kml, stylesheet=val)


@tm.network
@pytest.mark.network
@td.skip_if_no("lxml")
@tm.network
def test_online_stylesheet():
xml = "https://www.w3schools.com/xml/cdcatalog_with_xsl.xml"
xsl = "https://www.w3schools.com/xml/cdcatalog.xsl"
Expand Down Expand Up @@ -1099,13 +1103,14 @@ def test_unsuported_compression(parser):
# STORAGE OPTIONS


@tm.network
@pytest.mark.network
@td.skip_if_no("s3fs")
@td.skip_if_no("lxml")
@pytest.mark.skipif(
os.environ.get("PANDAS_CI", "0") == "1",
reason="2022.1.17: Hanging on the CI min versions build.",
)
@tm.network
def test_s3_parser_consistency():
# Python Software Foundation (2019 IRS-990 RETURN)
s3 = "s3://irs-form-990/201923199349319487_public.xml"
Expand Down
5 changes: 4 additions & 1 deletion pandas/tests/test_downstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def test_oo_optimized_datetime_index_unpickle():
)


@pytest.mark.network
@tm.network
# Cython import warning
@pytest.mark.filterwarnings("ignore:pandas.util.testing is deprecated")
Expand Down Expand Up @@ -164,6 +165,7 @@ def test_scikit_learn():


# Cython import warning and traitlets
@pytest.mark.network
@tm.network
@pytest.mark.filterwarnings("ignore")
def test_seaborn():
Expand All @@ -178,12 +180,13 @@ def test_pandas_gbq():
pandas_gbq = import_module("pandas_gbq") # noqa:F841


@pytest.mark.network
@tm.network
@pytest.mark.xfail(
raises=ValueError,
reason="The Quandl API key must be provided either through the api_key "
"variable or through the environmental variable QUANDL_API_KEY",
)
@tm.network
def test_pandas_datareader():

pandas_datareader = import_module("pandas_datareader")
Expand Down