Skip to content

Commit be1e2e1

Browse files
committed
move fixture to conftest
1 parent 64b0c08 commit be1e2e1

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

pandas/tests/indexes/conftest.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import pytest
22
import numpy as np
3+
import pandas as pd
34

45
import pandas.util.testing as tm
56
from pandas.core.indexes.api import Index, MultiIndex
6-
from pandas.compat import lzip
7+
from pandas.compat import lzip, long
78

89

910
@pytest.fixture(params=[tm.makeUnicodeIndex(100),
@@ -29,3 +30,18 @@ def indices(request):
2930
def one(request):
3031
# zero-dim integer array behaves like an integer
3132
return request.param
33+
34+
35+
zeros = [box([0] * 5, dtype=dtype)
36+
for box in [pd.Index, np.array]
37+
for dtype in [np.int64, np.uint64, np.float64]]
38+
zeros.extend([np.array(0, dtype=dtype)
39+
for dtype in [np.int64, np.uint64, np.float64]])
40+
zeros.extend([0, 0.0, long(0)])
41+
42+
43+
@pytest.fixture(params=zeros)
44+
def zero(request):
45+
# For testing division by (or of) zero for Index with length 5, this
46+
# gives several scalar-zeros and length-5 vector-zeros
47+
return request.param

pandas/tests/indexes/test_numeric.py

+1-15
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44

55
from datetime import datetime
6-
from pandas.compat import range, PY3, long
6+
from pandas.compat import range, PY3
77

88
import numpy as np
99

@@ -18,16 +18,6 @@
1818
from pandas.tests.indexes.common import Base
1919

2020

21-
# For testing division by (or of) zero for Series with length 5, this
22-
# gives several scalar-zeros and length-5 vector-zeros
23-
zeros = [box([0] * 5, dtype=dtype)
24-
for box in [pd.Index, np.array]
25-
for dtype in [np.int64, np.uint64, np.float64]]
26-
zeros.extend([np.array(0, dtype=dtype)
27-
for dtype in [np.int64, np.uint64, np.float64]])
28-
zeros.extend([0, 0.0, long(0)])
29-
30-
3121
def full_like(array, value):
3222
"""Compatibility for numpy<1.8.0
3323
"""
@@ -167,7 +157,6 @@ def test_divmod_series(self):
167157
for r, e in zip(result, expected):
168158
tm.assert_series_equal(r, e)
169159

170-
@pytest.mark.parametrize('zero', zeros)
171160
def test_div_zero(self, zero):
172161
idx = self.create_index()
173162

@@ -178,7 +167,6 @@ def test_div_zero(self, zero):
178167
ser_compat = Series(idx).astype('i8') / np.array(zero).astype('i8')
179168
tm.assert_series_equal(ser_compat, Series(result))
180169

181-
@pytest.mark.parametrize('zero', zeros)
182170
def test_floordiv_zero(self, zero):
183171
idx = self.create_index()
184172
expected = Index([np.nan, np.inf, np.inf, np.inf, np.inf],
@@ -189,7 +177,6 @@ def test_floordiv_zero(self, zero):
189177
ser_compat = Series(idx).astype('i8') // np.array(zero).astype('i8')
190178
tm.assert_series_equal(ser_compat, Series(result))
191179

192-
@pytest.mark.parametrize('zero', zeros)
193180
def test_mod_zero(self, zero):
194181
idx = self.create_index()
195182

@@ -200,7 +187,6 @@ def test_mod_zero(self, zero):
200187
ser_compat = Series(idx).astype('i8') % np.array(zero).astype('i8')
201188
tm.assert_series_equal(ser_compat, Series(result))
202189

203-
@pytest.mark.parametrize('zero', zeros)
204190
def test_divmod_zero(self, zero):
205191
idx = self.create_index()
206192

0 commit comments

Comments
 (0)