Skip to content

Commit 057f2fa

Browse files
committed
CLN: Unify string storage fixture usage (pandas-dev#50290)
* CLN: Unify string storage fixture usage * Remove skips
1 parent a0595b1 commit 057f2fa

File tree

6 files changed

+23
-37
lines changed

6 files changed

+23
-37
lines changed

pandas/conftest.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -1271,9 +1271,7 @@ def string_dtype(request):
12711271
@pytest.fixture(
12721272
params=[
12731273
"string[python]",
1274-
pytest.param(
1275-
"string[pyarrow]", marks=td.skip_if_no("pyarrow", min_version="1.0.0")
1276-
),
1274+
pytest.param("string[pyarrow]", marks=td.skip_if_no("pyarrow")),
12771275
]
12781276
)
12791277
def nullable_string_dtype(request):
@@ -1289,7 +1287,7 @@ def nullable_string_dtype(request):
12891287
@pytest.fixture(
12901288
params=[
12911289
"python",
1292-
pytest.param("pyarrow", marks=td.skip_if_no("pyarrow", min_version="1.0.0")),
1290+
pytest.param("pyarrow", marks=td.skip_if_no("pyarrow")),
12931291
]
12941292
)
12951293
def string_storage(request):
@@ -1332,9 +1330,7 @@ def object_dtype(request):
13321330
params=[
13331331
"object",
13341332
"string[python]",
1335-
pytest.param(
1336-
"string[pyarrow]", marks=td.skip_if_no("pyarrow", min_version="1.0.0")
1337-
),
1333+
pytest.param("string[pyarrow]", marks=td.skip_if_no("pyarrow")),
13381334
]
13391335
)
13401336
def any_string_dtype(request):

pandas/tests/io/excel/test_readers.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -600,15 +600,14 @@ def test_use_nullabla_dtypes_and_dtype(self, read_ext):
600600
tm.assert_frame_equal(result, df)
601601

602602
@td.skip_if_no("pyarrow")
603-
@pytest.mark.parametrize("storage", ["pyarrow", "python"])
604-
def test_use_nullable_dtypes_string(self, read_ext, storage):
603+
def test_use_nullable_dtypes_string(self, read_ext, string_storage):
605604
# GH#36712
606605
if read_ext in (".xlsb", ".xls"):
607606
pytest.skip(f"No engine for filetype: '{read_ext}'")
608607

609608
import pyarrow as pa
610609

611-
with pd.option_context("mode.string_storage", storage):
610+
with pd.option_context("mode.string_storage", string_storage):
612611

613612
df = DataFrame(
614613
{
@@ -622,7 +621,7 @@ def test_use_nullable_dtypes_string(self, read_ext, storage):
622621
file_path, sheet_name="test", use_nullable_dtypes=True
623622
)
624623

625-
if storage == "python":
624+
if string_storage == "python":
626625
expected = DataFrame(
627626
{
628627
"a": StringArray(np.array(["a", "b"], dtype=np.object_)),

pandas/tests/io/parser/dtypes/test_dtypes_basic.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -446,12 +446,11 @@ def test_use_nullabla_dtypes_and_dtype(all_parsers):
446446

447447

448448
@pytest.mark.usefixtures("pyarrow_xfail")
449-
@pytest.mark.parametrize("storage", ["pyarrow", "python"])
450-
def test_use_nullable_dtypes_string(all_parsers, storage):
449+
def test_use_nullable_dtypes_string(all_parsers, string_storage):
451450
# GH#36712
452451
pa = pytest.importorskip("pyarrow")
453452

454-
with pd.option_context("mode.string_storage", storage):
453+
with pd.option_context("mode.string_storage", string_storage):
455454

456455
parser = all_parsers
457456

@@ -461,7 +460,7 @@ def test_use_nullable_dtypes_string(all_parsers, storage):
461460
"""
462461
result = parser.read_csv(StringIO(data), use_nullable_dtypes=True)
463462

464-
if storage == "python":
463+
if string_storage == "python":
465464
expected = DataFrame(
466465
{
467466
"a": StringArray(np.array(["a", "b"], dtype=np.object_)),

pandas/tests/io/parser/test_upcast.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,16 @@ def test_maybe_upcaste_all_nan():
8989

9090

9191
@td.skip_if_no("pyarrow")
92-
@pytest.mark.parametrize("storage", ["pyarrow", "python"])
9392
@pytest.mark.parametrize("val", [na_values[np.object_], "c"])
94-
def test_maybe_upcast_object(val, storage):
93+
def test_maybe_upcast_object(val, string_storage):
9594
# GH#36712
9695
import pyarrow as pa
9796

98-
with pd.option_context("mode.string_storage", storage):
97+
with pd.option_context("mode.string_storage", string_storage):
9998
arr = np.array(["a", "b", val], dtype=np.object_)
10099
result = _maybe_upcast(arr, use_nullable_dtypes=True)
101100

102-
if storage == "python":
101+
if string_storage == "python":
103102
exp_val = "c" if val == "c" else NA
104103
expected = StringArray(np.array(["a", "b", exp_val], dtype=np.object_))
105104
else:

pandas/tests/io/test_sql.py

+11-14
Original file line numberDiff line numberDiff line change
@@ -2277,52 +2277,50 @@ def test_get_engine_auto_error_message(self):
22772277
# TODO(GH#36893) fill this in when we add more engines
22782278

22792279
@pytest.mark.parametrize("func", ["read_sql", "read_sql_query"])
2280-
@pytest.mark.parametrize("storage", ["pyarrow", "python"])
2281-
def test_read_sql_nullable_dtypes(self, storage, func):
2280+
def test_read_sql_nullable_dtypes(self, string_storage, func):
22822281
# GH#50048
22832282
table = "test"
22842283
df = self.nullable_data()
22852284
df.to_sql(table, self.conn, index=False, if_exists="replace")
22862285

2287-
with pd.option_context("mode.string_storage", storage):
2286+
with pd.option_context("mode.string_storage", string_storage):
22882287
result = getattr(pd, func)(
22892288
f"Select * from {table}", self.conn, use_nullable_dtypes=True
22902289
)
2291-
expected = self.nullable_expected(storage)
2290+
expected = self.nullable_expected(string_storage)
22922291
tm.assert_frame_equal(result, expected)
22932292

2294-
with pd.option_context("mode.string_storage", storage):
2293+
with pd.option_context("mode.string_storage", string_storage):
22952294
iterator = getattr(pd, func)(
22962295
f"Select * from {table}",
22972296
self.conn,
22982297
use_nullable_dtypes=True,
22992298
chunksize=3,
23002299
)
2301-
expected = self.nullable_expected(storage)
2300+
expected = self.nullable_expected(string_storage)
23022301
for result in iterator:
23032302
tm.assert_frame_equal(result, expected)
23042303

23052304
@pytest.mark.parametrize("func", ["read_sql", "read_sql_table"])
2306-
@pytest.mark.parametrize("storage", ["pyarrow", "python"])
2307-
def test_read_sql_nullable_dtypes_table(self, storage, func):
2305+
def test_read_sql_nullable_dtypes_table(self, string_storage, func):
23082306
# GH#50048
23092307
table = "test"
23102308
df = self.nullable_data()
23112309
df.to_sql(table, self.conn, index=False, if_exists="replace")
23122310

2313-
with pd.option_context("mode.string_storage", storage):
2311+
with pd.option_context("mode.string_storage", string_storage):
23142312
result = getattr(pd, func)(table, self.conn, use_nullable_dtypes=True)
2315-
expected = self.nullable_expected(storage)
2313+
expected = self.nullable_expected(string_storage)
23162314
tm.assert_frame_equal(result, expected)
23172315

2318-
with pd.option_context("mode.string_storage", storage):
2316+
with pd.option_context("mode.string_storage", string_storage):
23192317
iterator = getattr(pd, func)(
23202318
table,
23212319
self.conn,
23222320
use_nullable_dtypes=True,
23232321
chunksize=3,
23242322
)
2325-
expected = self.nullable_expected(storage)
2323+
expected = self.nullable_expected(string_storage)
23262324
for result in iterator:
23272325
tm.assert_frame_equal(result, expected)
23282326

@@ -2453,8 +2451,7 @@ def nullable_expected(self, storage) -> DataFrame:
24532451
return super().nullable_expected(storage).astype({"e": "Int64", "f": "Int64"})
24542452

24552453
@pytest.mark.parametrize("func", ["read_sql", "read_sql_table"])
2456-
@pytest.mark.parametrize("storage", ["pyarrow", "python"])
2457-
def test_read_sql_nullable_dtypes_table(self, storage, func):
2454+
def test_read_sql_nullable_dtypes_table(self, string_storage, func):
24582455
# GH#50048 Not supported for sqlite
24592456
pass
24602457

pandas/tests/plotting/test_converter.py

-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
import pandas._config.config as cf
1212

13-
import pandas.util._test_decorators as td
14-
1513
from pandas import (
1614
Index,
1715
Period,
@@ -76,7 +74,6 @@ def test_dont_register_by_default(self):
7674
call = [sys.executable, "-c", code]
7775
assert subprocess.check_call(call) == 0
7876

79-
@td.skip_if_no("matplotlib", min_version="3.1.3")
8077
def test_registering_no_warning(self):
8178
plt = pytest.importorskip("matplotlib.pyplot")
8279
s = Series(range(12), index=date_range("2017", periods=12))
@@ -111,7 +108,6 @@ def test_matplotlib_formatters(self):
111108
assert Timestamp not in units.registry
112109
assert Timestamp in units.registry
113110

114-
@td.skip_if_no("matplotlib", min_version="3.1.3")
115111
def test_option_no_warning(self):
116112
pytest.importorskip("matplotlib.pyplot")
117113
ctx = cf.option_context("plotting.matplotlib.register_converters", False)

0 commit comments

Comments
 (0)