Skip to content

Commit e413b91

Browse files
authored
CLN: Unify string storage fixture usage (#50290)
* CLN: Unify string storage fixture usage * Remove skips
1 parent e1dd15b commit e413b91

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
@@ -2276,51 +2276,49 @@ def test_get_engine_auto_error_message(self):
22762276
pass
22772277
# TODO(GH#36893) fill this in when we add more engines
22782278

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

2286-
with pd.option_context("mode.string_storage", storage):
2285+
with pd.option_context("mode.string_storage", string_storage):
22872286
result = pd.read_sql(
22882287
f"Select * from {table}", self.conn, use_nullable_dtypes=True
22892288
)
2290-
expected = self.nullable_expected(storage)
2289+
expected = self.nullable_expected(string_storage)
22912290
tm.assert_frame_equal(result, expected)
22922291

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

2304-
@pytest.mark.parametrize("storage", ["pyarrow", "python"])
2305-
def test_read_sql_nullable_dtypes_table(self, storage):
2303+
def test_read_sql_nullable_dtypes_table(self, string_storage):
23062304
# GH#50048
23072305
table = "test"
23082306
df = self.nullable_data()
23092307
df.to_sql(table, self.conn, index=False, if_exists="replace")
23102308

2311-
with pd.option_context("mode.string_storage", storage):
2309+
with pd.option_context("mode.string_storage", string_storage):
23122310
result = pd.read_sql(table, self.conn, use_nullable_dtypes=True)
2313-
expected = self.nullable_expected(storage)
2311+
expected = self.nullable_expected(string_storage)
23142312
tm.assert_frame_equal(result, expected)
23152313

2316-
with pd.option_context("mode.string_storage", storage):
2314+
with pd.option_context("mode.string_storage", string_storage):
23172315
iterator = pd.read_sql(
23182316
f"Select * from {table}",
23192317
self.conn,
23202318
use_nullable_dtypes=True,
23212319
chunksize=3,
23222320
)
2323-
expected = self.nullable_expected(storage)
2321+
expected = self.nullable_expected(string_storage)
23242322
for result in iterator:
23252323
tm.assert_frame_equal(result, expected)
23262324

@@ -2450,8 +2448,7 @@ class Test(BaseModel):
24502448
def nullable_expected(self, storage) -> DataFrame:
24512449
return super().nullable_expected(storage).astype({"e": "Int64", "f": "Int64"})
24522450

2453-
@pytest.mark.parametrize("storage", ["pyarrow", "python"])
2454-
def test_read_sql_nullable_dtypes_table(self, storage):
2451+
def test_read_sql_nullable_dtypes_table(self, string_storage):
24552452
# GH#50048 Not supported for sqlite
24562453
pass
24572454

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)