Skip to content

Commit 4904bc8

Browse files
mroeschkemeeseeksmachine
authored andcommitted
Backport PR pandas-dev#56595: TST/CLN: Inline seldom used fixture
1 parent d4c8d82 commit 4904bc8

File tree

8 files changed

+13
-30
lines changed

8 files changed

+13
-30
lines changed

pandas/tests/arrays/categorical/conftest.py

-9
This file was deleted.

pandas/tests/arrays/categorical/test_api.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ def test_remove_unused_categories(self):
385385

386386

387387
class TestCategoricalAPIWithFactor:
388-
def test_describe(self, factor):
388+
def test_describe(self):
389+
factor = Categorical(["a", "b", "b", "a", "a", "c", "c", "c"], ordered=True)
389390
# string type
390391
desc = factor.describe()
391392
assert factor.ordered

pandas/tests/arrays/categorical/test_indexing.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121

2222

2323
class TestCategoricalIndexingWithFactor:
24-
def test_getitem(self, factor):
24+
def test_getitem(self):
25+
factor = Categorical(["a", "b", "b", "a", "a", "c", "c", "c"], ordered=True)
2526
assert factor[0] == "a"
2627
assert factor[-1] == "c"
2728

@@ -31,7 +32,8 @@ def test_getitem(self, factor):
3132
subf = factor[np.asarray(factor) == "c"]
3233
tm.assert_numpy_array_equal(subf._codes, np.array([2, 2, 2], dtype=np.int8))
3334

34-
def test_setitem(self, factor):
35+
def test_setitem(self):
36+
factor = Categorical(["a", "b", "b", "a", "a", "c", "c", "c"], ordered=True)
3537
# int/positional
3638
c = factor.copy()
3739
c[0] = "b"

pandas/tests/arrays/categorical/test_operators.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def test_categories_none_comparisons(self):
1717
factor = Categorical(["a", "b", "b", "a", "a", "c", "c", "c"], ordered=True)
1818
tm.assert_categorical_equal(factor, factor)
1919

20-
def test_comparisons(self, factor):
20+
def test_comparisons(self):
21+
factor = Categorical(["a", "b", "b", "a", "a", "c", "c", "c"], ordered=True)
2122
result = factor[factor == "a"]
2223
expected = factor[np.asarray(factor) == "a"]
2324
tm.assert_categorical_equal(result, expected)

pandas/tests/arrays/categorical/test_repr.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818

1919
class TestCategoricalReprWithFactor:
20-
def test_print(self, factor, using_infer_string):
20+
def test_print(self, using_infer_string):
21+
factor = Categorical(["a", "b", "b", "a", "a", "c", "c", "c"], ordered=True)
2122
if using_infer_string:
2223
expected = [
2324
"['a', 'b', 'b', 'a', 'a', 'c', 'c', 'c']",

pandas/tests/indexes/datetimes/test_ops.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
)
1111
import pandas._testing as tm
1212

13-
START, END = datetime(2009, 1, 1), datetime(2010, 1, 1)
14-
1513

1614
class TestDatetimeIndexOps:
1715
def test_infer_freq(self, freq_sample):
@@ -26,6 +24,7 @@ def test_infer_freq(self, freq_sample):
2624
class TestBusinessDatetimeIndex:
2725
@pytest.fixture
2826
def rng(self, freq):
27+
START, END = datetime(2009, 1, 1), datetime(2010, 1, 1)
2928
return bdate_range(START, END, freq=freq)
3029

3130
def test_comparison(self, rng):

pandas/tests/tseries/offsets/conftest.py

-13
This file was deleted.

pandas/tests/tseries/offsets/test_common.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ def test_sub(date, offset_box, offset2):
250250
[BusinessHour, BusinessHour()],
251251
],
252252
)
253-
def test_Mult1(offset_box, offset1, dt):
253+
def test_Mult1(offset_box, offset1):
254+
dt = Timestamp(2008, 1, 2)
254255
assert dt + 10 * offset1 == dt + offset_box(10)
255256
assert dt + 5 * offset1 == dt + offset_box(5)
256257

0 commit comments

Comments
 (0)