Skip to content

Commit 56c1b20

Browse files
TST: Get tests to run and fix them to pass (pandas-dev#50636)
* updated tests * updated assert_metadata_equivalent * updated assert_metadata_equivalent and deleted exclude in YAML check-test-naming * added comment * move comment Co-authored-by: Marco Edward Gorelli <[email protected]>
1 parent d1b7244 commit 56c1b20

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

.pre-commit-config.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,3 @@ repos:
443443
types: [python]
444444
files: ^pandas/tests
445445
language: python
446-
exclude: |
447-
(?x)
448-
^pandas/tests/generic/test_generic.py # GH50380

pandas/_testing/asserters.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,9 @@ def assert_indexing_slices_equivalent(ser: Series, l_slc: slice, i_slc: slice) -
13411341
assert_series_equal(ser[l_slc], expected)
13421342

13431343

1344-
def assert_metadata_equivalent(left, right) -> None:
1344+
def assert_metadata_equivalent(
1345+
left: DataFrame | Series, right: DataFrame | Series | None = None
1346+
) -> None:
13451347
"""
13461348
Check that ._metadata attributes are equivalent.
13471349
"""

pandas/tests/generic/test_generic.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def construct(box, shape, value=None, dtype=None, **kwargs):
5050
return box(arr, dtype=dtype, **kwargs)
5151

5252

53-
class Generic:
53+
class TestGeneric:
5454
@pytest.mark.parametrize(
5555
"func",
5656
[
@@ -66,7 +66,7 @@ def test_rename(self, frame_or_series, func):
6666

6767
for axis in frame_or_series._AXIS_ORDERS:
6868
kwargs = {axis: idx}
69-
obj = construct(4, **kwargs)
69+
obj = construct(frame_or_series, 4, **kwargs)
7070

7171
# rename a single axis
7272
result = obj.rename(**{axis: func})
@@ -83,21 +83,22 @@ def test_get_numeric_data(self, frame_or_series):
8383
}
8484

8585
# get the numeric data
86-
o = construct(n, **kwargs)
86+
o = construct(frame_or_series, n, **kwargs)
8787
result = o._get_numeric_data()
8888
tm.assert_equal(result, o)
8989

9090
# non-inclusion
9191
result = o._get_bool_data()
92-
expected = construct(n, value="empty", **kwargs)
92+
expected = construct(frame_or_series, n, value="empty", **kwargs)
9393
if isinstance(o, DataFrame):
9494
# preserve columns dtype
9595
expected.columns = o.columns[:0]
96-
tm.assert_equal(result, expected)
96+
# https://github.com/pandas-dev/pandas/issues/50862
97+
tm.assert_equal(result.reset_index(drop=True), expected)
9798

9899
# get the bool data
99100
arr = np.array([True, True, False, True])
100-
o = construct(n, value=arr, **kwargs)
101+
o = construct(frame_or_series, n, value=arr, **kwargs)
101102
result = o._get_numeric_data()
102103
tm.assert_equal(result, o)
103104

@@ -160,7 +161,7 @@ def f(dtype):
160161

161162
msg = (
162163
"compound dtypes are not implemented "
163-
f"in the {frame_or_series.__name__} frame_or_series"
164+
f"in the {frame_or_series.__name__} constructor"
164165
)
165166

166167
with pytest.raises(NotImplementedError, match=msg):
@@ -257,7 +258,7 @@ def test_api_compat(self, func, frame_or_series):
257258
# GH 12021
258259
# compat for __name__, __qualname__
259260

260-
obj = (frame_or_series, 5)
261+
obj = construct(frame_or_series, 5)
261262
f = getattr(obj, func)
262263
assert f.__name__ == func
263264
assert f.__qualname__.endswith(func)

0 commit comments

Comments
 (0)