Skip to content

Commit fcb1297

Browse files
Removing PY36 compatibility from tests
1 parent 7ce9c79 commit fcb1297

File tree

15 files changed

+21
-140
lines changed

15 files changed

+21
-140
lines changed

pandas/tests/extension/json/test_json.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
import pytest
55

6-
from pandas.compat import PY36
7-
86
import pandas as pd
97
from pandas.tests.extension import base
108
import pandas.util.testing as tm
@@ -180,9 +178,6 @@ def test_fillna_frame(self):
180178

181179

182180
unhashable = pytest.mark.skip(reason="Unhashable")
183-
unstable = pytest.mark.skipif(
184-
not PY36, reason="Dictionary order unstable" # 3.6 or higher
185-
)
186181

187182

188183
class TestReduce(base.BaseNoReduceTests):
@@ -199,20 +194,16 @@ def test_sort_values_frame(self):
199194
# TODO (EA.factorize): see if _values_for_factorize allows this.
200195
pass
201196

202-
@unstable
203197
def test_argsort(self, data_for_sorting):
204198
super().test_argsort(data_for_sorting)
205199

206-
@unstable
207200
def test_argsort_missing(self, data_missing_for_sorting):
208201
super().test_argsort_missing(data_missing_for_sorting)
209202

210-
@unstable
211203
@pytest.mark.parametrize("ascending", [True, False])
212204
def test_sort_values(self, data_for_sorting, ascending):
213205
super().test_sort_values(data_for_sorting, ascending)
214206

215-
@unstable
216207
@pytest.mark.parametrize("ascending", [True, False])
217208
def test_sort_values_missing(self, data_missing_for_sorting, ascending):
218209
super().test_sort_values_missing(data_missing_for_sorting, ascending)
@@ -280,7 +271,6 @@ def test_groupby_extension_apply(self):
280271
we'll be able to dispatch unique.
281272
"""
282273

283-
@unstable
284274
@pytest.mark.parametrize("as_index", [True, False])
285275
def test_groupby_extension_agg(self, as_index, data_for_grouping):
286276
super().test_groupby_extension_agg(as_index, data_for_grouping)

pandas/tests/frame/test_constructors.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import numpy.ma.mrecords as mrecords
99
import pytest
1010

11-
from pandas.compat import PY36, is_platform_little_endian
11+
from pandas.compat import is_platform_little_endian
1212

1313
from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
1414
from pandas.core.dtypes.common import is_integer_dtype
@@ -387,7 +387,6 @@ def test_constructor_dict_nan_tuple_key(self, value):
387387
result = DataFrame(data, index=idx, columns=cols)
388388
tm.assert_frame_equal(result, expected)
389389

390-
@pytest.mark.skipif(not PY36, reason="Insertion order for Python>=3.6")
391390
def test_constructor_dict_order_insertion(self):
392391
datetime_series = tm.makeTimeSeries(nper=30)
393392
datetime_series_short = tm.makeTimeSeries(nper=25)
@@ -399,18 +398,6 @@ def test_constructor_dict_order_insertion(self):
399398
expected = DataFrame(data=d, columns=list("ba"))
400399
tm.assert_frame_equal(frame, expected)
401400

402-
@pytest.mark.skipif(PY36, reason="order by value for Python<3.6")
403-
def test_constructor_dict_order_by_values(self):
404-
datetime_series = tm.makeTimeSeries(nper=30)
405-
datetime_series_short = tm.makeTimeSeries(nper=25)
406-
407-
# GH19018
408-
# initialization ordering: by value if python<3.6
409-
d = {"b": datetime_series_short, "a": datetime_series}
410-
frame = DataFrame(data=d)
411-
expected = DataFrame(data=d, columns=list("ab"))
412-
tm.assert_frame_equal(frame, expected)
413-
414401
def test_constructor_multi_index(self):
415402
# GH 4078
416403
# construction error with mi and all-nan frame
@@ -1373,7 +1360,7 @@ def test_constructor_list_of_dict_order(self):
13731360
}
13741361
)
13751362
result = DataFrame(data)
1376-
tm.assert_frame_equal(result, expected, check_like=not PY36)
1363+
tm.assert_frame_equal(result, expected, check_like=False)
13771364

13781365
def test_constructor_orient(self, float_string_frame):
13791366
data_dict = float_string_frame.T._series

pandas/tests/frame/test_mutate_columns.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import numpy as np
44
import pytest
55

6-
from pandas.compat import PY36
7-
86
from pandas import DataFrame, Index, MultiIndex, Series
97
import pandas.util.testing as tm
108

@@ -60,10 +58,7 @@ def test_assign_order(self):
6058
df = DataFrame([[1, 2], [3, 4]], columns=["A", "B"])
6159
result = df.assign(D=df.A + df.B, C=df.A - df.B)
6260

63-
if PY36:
64-
expected = DataFrame([[1, 2, 3, -1], [3, 4, 7, -1]], columns=list("ABDC"))
65-
else:
66-
expected = DataFrame([[1, 2, -1, 3], [3, 4, -1, 7]], columns=list("ABCD"))
61+
expected = DataFrame([[1, 2, 3, -1], [3, 4, 7, -1]], columns=list("ABDC"))
6762
tm.assert_frame_equal(result, expected)
6863
result = df.assign(C=df.A - df.B, D=df.A + df.B)
6964

@@ -80,25 +75,6 @@ def test_assign_bad(self):
8075
with pytest.raises(AttributeError):
8176
df.assign(C=df.A, D=df.A + df.C)
8277

83-
@pytest.mark.skipif(
84-
PY36,
85-
reason="""Issue #14207: valid for python
86-
3.6 and above""",
87-
)
88-
def test_assign_dependent_old_python(self):
89-
df = DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
90-
91-
# Key C does not exist at definition time of df
92-
with pytest.raises(KeyError, match="^'C'$"):
93-
df.assign(C=lambda df: df.A, D=lambda df: df["A"] + df["C"])
94-
with pytest.raises(KeyError, match="^'C'$"):
95-
df.assign(C=df.A, D=lambda x: x["A"] + x["C"])
96-
97-
@pytest.mark.skipif(
98-
not PY36,
99-
reason="""Issue #14207: not valid for
100-
python 3.5 and below""",
101-
)
10278
def test_assign_dependent(self):
10379
df = DataFrame({"A": [1, 2], "B": [3, 4]})
10480

pandas/tests/groupby/aggregate/test_aggregate.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pytest
99

1010
import pandas as pd
11-
from pandas import DataFrame, Index, MultiIndex, Series, compat, concat
11+
from pandas import DataFrame, Index, MultiIndex, Series, concat
1212
from pandas.core.base import SpecificationError
1313
from pandas.core.groupby.generic import _make_unique, _maybe_mangle_lambdas
1414
from pandas.core.groupby.grouper import Grouping
@@ -361,9 +361,7 @@ def test_series_named_agg(self):
361361
tm.assert_frame_equal(result, expected)
362362

363363
result = gr.agg(b="min", a="sum")
364-
# sort for 35 and earlier
365-
if compat.PY36:
366-
expected = expected[["b", "a"]]
364+
expected = expected[["b", "a"]]
367365
tm.assert_frame_equal(result, expected)
368366

369367
def test_no_args_raises(self):
@@ -425,8 +423,6 @@ def test_agg_relabel(self):
425423
index=pd.Index(["a", "b"], name="group"),
426424
columns=["b_min", "a_min", "a_mean", "a_max", "b_max", "a_98"],
427425
)
428-
if not compat.PY36:
429-
expected = expected[["a_98", "a_max", "a_mean", "a_min", "b_max", "b_min"]]
430426
tm.assert_frame_equal(result, expected)
431427

432428
def test_agg_relabel_non_identifier(self):

pandas/tests/indexes/test_base.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import pandas._config.config as cf
1212

1313
from pandas._libs.tslib import Timestamp
14-
from pandas.compat import PY36
1514
from pandas.compat.numpy import np_datetime64_compat
1615

1716
from pandas.core.dtypes.common import is_unsigned_integer_dtype
@@ -1616,11 +1615,7 @@ def test_get_loc(self, method):
16161615
def test_get_loc_raises_bad_label(self, method):
16171616
index = pd.Index([0, 1, 2])
16181617
if method:
1619-
# Messages vary across versions
1620-
if PY36:
1621-
msg = "not supported between"
1622-
else:
1623-
msg = "unorderable types"
1618+
msg = "not supported between"
16241619
else:
16251620
msg = "invalid key"
16261621

@@ -2444,21 +2439,13 @@ def create_index(self):
24442439

24452440
def test_argsort(self):
24462441
index = self.create_index()
2447-
if PY36:
2448-
with pytest.raises(TypeError, match="'>|<' not supported"):
2449-
index.argsort()
2450-
else:
2451-
with pytest.raises(TypeError, match="unorderable types"):
2452-
index.argsort()
2442+
with pytest.raises(TypeError, match="'>|<' not supported"):
2443+
index.argsort()
24532444

24542445
def test_numpy_argsort(self):
24552446
index = self.create_index()
2456-
if PY36:
2457-
with pytest.raises(TypeError, match="'>|<' not supported"):
2458-
np.argsort(index)
2459-
else:
2460-
with pytest.raises(TypeError, match="unorderable types"):
2461-
np.argsort(index)
2447+
with pytest.raises(TypeError, match="'>|<' not supported"):
2448+
np.argsort(index)
24622449

24632450
def test_copy_name(self):
24642451
# Check that "name" argument passed at initialization is honoured

pandas/tests/indexing/test_indexing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import numpy as np
88
import pytest
99

10-
from pandas.compat import PY36
1110
from pandas.errors import AbstractMethodError
1211

1312
from pandas.core.dtypes.common import is_float_dtype, is_integer_dtype
@@ -222,7 +221,7 @@ def test_setitem_dtype_upcast(self):
222221
expected = DataFrame(
223222
[{"a": 1, "b": np.nan, "c": "foo"}, {"a": 3, "b": 2, "c": np.nan}]
224223
)
225-
tm.assert_frame_equal(df, expected, check_like=not PY36)
224+
tm.assert_frame_equal(df, expected, check_like=False)
226225

227226
# GH10280
228227
df = DataFrame(

pandas/tests/internals/test_internals.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
from collections import OrderedDict
22
from datetime import date, datetime
3-
from distutils.version import LooseVersion
43
import itertools
54
import operator
65
import re
7-
import sys
86

97
import numpy as np
108
import pytest
@@ -26,9 +24,6 @@
2624
from pandas.core.internals import BlockManager, SingleBlockManager, make_block
2725
import pandas.util.testing as tm
2826

29-
# in 3.6.1 a c-api slicing function changed, see src/compat_helper.h
30-
PY361 = LooseVersion(sys.version) >= LooseVersion("3.6.1")
31-
3227

3328
@pytest.fixture
3429
def mgr():
@@ -1096,10 +1091,6 @@ def assert_as_slice_equals(arr, slc):
10961091

10971092
assert_as_slice_equals([2, 1], slice(2, 0, -1))
10981093

1099-
if not PY361:
1100-
assert_as_slice_equals([2, 1, 0], slice(2, None, -1))
1101-
assert_as_slice_equals([100, 0], slice(100, None, -100))
1102-
11031094
def test_not_slice_like_arrays(self):
11041095
def assert_not_slice_like(arr):
11051096
assert not BlockPlacement(arr).is_slice_like
@@ -1119,10 +1110,6 @@ def test_slice_iter(self):
11191110
assert list(BlockPlacement(slice(0, 0))) == []
11201111
assert list(BlockPlacement(slice(3, 0))) == []
11211112

1122-
if not PY361:
1123-
assert list(BlockPlacement(slice(3, 0, -1))) == [3, 2, 1]
1124-
assert list(BlockPlacement(slice(3, None, -1))) == [3, 2, 1, 0]
1125-
11261113
def test_slice_to_array_conversion(self):
11271114
def assert_as_array_equals(slc, asarray):
11281115
tm.assert_numpy_array_equal(
@@ -1135,10 +1122,6 @@ def assert_as_array_equals(slc, asarray):
11351122

11361123
assert_as_array_equals(slice(3, 0, -1), [3, 2, 1])
11371124

1138-
if not PY361:
1139-
assert_as_array_equals(slice(3, None, -1), [3, 2, 1, 0])
1140-
assert_as_array_equals(slice(31, None, -10), [31, 21, 11, 1])
1141-
11421125
def test_blockplacement_add(self):
11431126
bpl = BlockPlacement(slice(0, 5))
11441127
assert bpl.add(1).as_slice == slice(1, 6, 1)
@@ -1168,14 +1151,6 @@ def assert_add_equals(val, inc, result):
11681151
with pytest.raises(ValueError):
11691152
BlockPlacement([1, 2, 4]).add(-10)
11701153

1171-
if not PY361:
1172-
assert_add_equals(slice(3, 0, -1), -1, [2, 1, 0])
1173-
assert_add_equals(slice(2, None, -1), 0, [2, 1, 0])
1174-
assert_add_equals(slice(2, None, -1), 10, [12, 11, 10])
1175-
1176-
with pytest.raises(ValueError):
1177-
BlockPlacement(slice(2, None, -1)).add(-1)
1178-
11791154

11801155
class DummyElement:
11811156
def __init__(self, value, dtype):

pandas/tests/io/excel/test_writers.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import numpy as np
77
import pytest
88

9-
from pandas.compat import PY36
109
import pandas.util._test_decorators as td
1110

1211
import pandas as pd
@@ -1262,7 +1261,6 @@ def check_called(func):
12621261

12631262
@td.skip_if_no("xlrd")
12641263
@td.skip_if_no("openpyxl")
1265-
@pytest.mark.skipif(not PY36, reason="requires fspath")
12661264
class TestFSPath:
12671265
def test_excelfile_fspath(self):
12681266
with tm.ensure_clean("foo.xlsx") as path:

pandas/tests/io/formats/test_format.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import pytest
1919
import pytz
2020

21-
from pandas.compat import PY36, is_platform_32bit, is_platform_windows
21+
from pandas.compat import is_platform_32bit, is_platform_windows
2222

2323
import pandas as pd
2424
from pandas import (
@@ -62,10 +62,7 @@ def filepath_or_buffer(filepath_or_buffer_id, tmp_path):
6262
yield buf
6363
assert not buf.closed
6464
else:
65-
if PY36:
66-
assert isinstance(tmp_path, Path)
67-
else:
68-
assert hasattr(tmp_path, "__fspath__")
65+
assert isinstance(tmp_path, Path)
6966
if filepath_or_buffer_id == "pathlike":
7067
yield tmp_path / "foo"
7168
else:

pandas/tests/io/json/test_normalize.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import numpy as np
44
import pytest
55

6-
from pandas.compat import PY36
7-
86
from pandas import DataFrame, Index
97
import pandas.util.testing as tm
108

@@ -382,7 +380,7 @@ def test_missing_field(self, author_missing_data):
382380
},
383381
]
384382
expected = DataFrame(ex_data)
385-
tm.assert_frame_equal(result, expected, check_like=not PY36)
383+
tm.assert_frame_equal(result, expected, check_like=False)
386384

387385
@pytest.mark.parametrize(
388386
"max_level,expected",
@@ -524,7 +522,7 @@ def test_missing_meta(self, missing_metadata):
524522
columns = ["city", "number", "state", "street", "zip", "name"]
525523
columns = ["number", "street", "city", "state", "zip", "name"]
526524
expected = DataFrame(ex_data, columns=columns)
527-
tm.assert_frame_equal(result, expected, check_like=not PY36)
525+
tm.assert_frame_equal(result, expected, check_like=False)
528526

529527
def test_donot_drop_nonevalues(self):
530528
# GH21356

pandas/tests/io/parser/test_common.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,10 +2160,6 @@ def test_suppress_error_output(all_parsers, capsys):
21602160
assert captured.err == ""
21612161

21622162

2163-
@pytest.mark.skipif(
2164-
compat.is_platform_windows() and not compat.PY36,
2165-
reason="On Python < 3.6 won't pass on Windows",
2166-
)
21672163
@pytest.mark.parametrize("filename", ["sé-es-vé.csv", "ru-sй.csv", "中文文件名.csv"])
21682164
def test_filename_with_special_chars(all_parsers, filename):
21692165
# see gh-15086.

pandas/tests/io/pytables/test_store.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import numpy as np
1010
import pytest
1111

12-
from pandas.compat import PY36, is_platform_little_endian, is_platform_windows
12+
from pandas.compat import is_platform_little_endian, is_platform_windows
1313
import pandas.util._test_decorators as td
1414

1515
from pandas.core.dtypes.common import is_categorical_dtype
@@ -4711,7 +4711,6 @@ def test_read_hdf_series_mode_r(self, format, setup_path):
47114711
result = pd.read_hdf(path, key="data", mode="r")
47124712
tm.assert_series_equal(result, series)
47134713

4714-
@pytest.mark.skipif(not PY36, reason="Need python 3.6")
47154714
def test_fspath(self):
47164715
with tm.ensure_clean("foo.h5") as path:
47174716
with pd.HDFStore(path) as store:

0 commit comments

Comments
 (0)