Skip to content

Commit 4a6864f

Browse files
committed
Improve tests
1 parent 0490dee commit 4a6864f

File tree

2 files changed

+11
-51
lines changed

2 files changed

+11
-51
lines changed

pandas/tests/frame/test_arithmetic.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import numpy as np
1212
import pytest
1313

14-
import pandas.util._test_decorators as td
15-
1614
import pandas as pd
1715
from pandas import (
1816
DataFrame,
@@ -2183,28 +2181,14 @@ def test_enum_column_equality():
21832181
tm.assert_series_equal(result, expected)
21842182

21852183

2186-
@pytest.mark.parametrize(
2187-
"dtype",
2188-
[
2189-
"string[python]",
2190-
pytest.param(
2191-
"string[pyarrow]",
2192-
marks=td.skip_if_no("pyarrow"),
2193-
),
2194-
pytest.param(
2195-
"str",
2196-
marks=td.skip_if_no("pyarrow"),
2197-
),
2198-
],
2199-
)
2200-
def test_mixed_col_index_dtype(dtype):
2184+
def test_mixed_col_index_dtype(string_dtype_no_object):
22012185
# GH 47382
22022186
df1 = DataFrame(columns=list("abc"), data=1.0, index=[0])
22032187
df2 = DataFrame(columns=list("abc"), data=0.0, index=[0])
2204-
df1.columns = df2.columns.astype(dtype)
2188+
df1.columns = df2.columns.astype(string_dtype_no_object)
22052189
result = df1 + df2
22062190
expected = DataFrame(columns=list("abc"), data=1.0, index=[0])
22072191

2208-
expected.columns = expected.columns.astype(dtype)
2192+
expected.columns = expected.columns.astype(string_dtype_no_object)
22092193

22102194
tm.assert_frame_equal(result, expected)

pandas/tests/indexes/test_base.py

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,49 +1720,25 @@ def test_is_monotonic_pyarrow_list_type():
17201720
assert not idx.is_monotonic_decreasing
17211721

17221722

1723-
@pytest.mark.parametrize(
1724-
"dtype",
1725-
[
1726-
"string[python]",
1727-
pytest.param(
1728-
"string[pyarrow]",
1729-
marks=td.skip_if_no("pyarrow"),
1730-
),
1731-
pytest.param(
1732-
"str",
1733-
marks=td.skip_if_no("pyarrow"),
1734-
),
1735-
],
1736-
)
1737-
def test_index_equals_different_string_dtype(dtype):
1723+
def test_index_equals_different_string_dtype(string_dtype_no_object):
17381724
# GH 61099
17391725
idx_obj = Index(["a", "b", "c"])
1740-
idx_str = Index(["a", "b", "c"], dtype=dtype)
1726+
idx_str = Index(["a", "b", "c"], dtype=string_dtype_no_object)
17411727

17421728
assert idx_obj.equals(idx_str)
17431729
assert idx_str.equals(idx_obj)
17441730

17451731

1746-
@pytest.mark.parametrize(
1747-
"dtype",
1748-
[
1749-
"string[python]",
1750-
pytest.param(
1751-
"string[pyarrow]",
1752-
marks=td.skip_if_no("pyarrow"),
1753-
),
1754-
pytest.param(
1755-
"str",
1756-
marks=td.skip_if_no("pyarrow"),
1757-
),
1758-
],
1759-
)
1760-
def test_index_comparison_different_string_dtype(dtype):
1732+
def test_index_comparison_different_string_dtype(string_dtype_no_object):
17611733
# GH 61099
17621734
idx = Index(["a", "b", "c"])
17631735
s_obj = Series([1, 2, 3], index=idx)
1764-
s_str = Series([4, 5, 6], index=idx.astype(dtype))
1736+
s_str = Series([4, 5, 6], index=idx.astype(string_dtype_no_object))
17651737

17661738
expected = Series([True, True, True], index=["a", "b", "c"])
17671739
result = s_obj < s_str
17681740
assert_series_equal(result, expected)
1741+
1742+
result = s_str > s_obj
1743+
expected.index = idx.astype(string_dtype_no_object)
1744+
assert_series_equal(result, expected)

0 commit comments

Comments
 (0)