Skip to content

Commit ea98cb5

Browse files
authored
Merge pull request #7316 from QuLogic/drop-old-python-checks
Drop old Python checks
2 parents 0f7dbfc + 6d6098a commit ea98cb5

File tree

8 files changed

+14
-78
lines changed

8 files changed

+14
-78
lines changed

lib/matplotlib/compat/subprocess.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from __future__ import print_function
1818
import os
1919
import sys
20-
if os.name == 'posix' and sys.version_info[:2] < (3, 2):
20+
if os.name == 'posix' and sys.version_info[0] < 3:
2121
# work around for https://github.com/matplotlib/matplotlib/issues/5314
2222
try:
2323
import subprocess32 as subprocess

lib/matplotlib/tests/test_image.py

-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
unicode_literals)
33

44
import six
5-
import sys
65
import io
76
import os
87

@@ -573,10 +572,6 @@ def test_minimized_rasterized():
573572
# in Postscript, the best way to detect it is to generate SVG
574573
# and then parse the output to make sure the two colorbar images
575574
# are the same size.
576-
if sys.version_info[:2] < (2, 7):
577-
raise nose.SkipTest("xml.etree.ElementTree.Element.iter "
578-
"added in py 2.7")
579-
580575
from xml.etree import ElementTree
581576

582577
np.random.seed(0)

lib/matplotlib/tests/test_lines.py

-10
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import matplotlib.pyplot as plt
1818
from matplotlib.testing.decorators import cleanup, image_comparison
1919

20-
import sys
21-
2220

2321
@cleanup
2422
def test_invisible_Line_rendering():
@@ -112,10 +110,6 @@ def test_linestyle_variants():
112110

113111
@cleanup
114112
def test_valid_linestyles():
115-
if sys.version_info[:2] < (2, 7):
116-
raise nose.SkipTest("assert_raises as context manager "
117-
"not supported with Python < 2.7")
118-
119113
line = mlines.Line2D([], [])
120114
with assert_raises(ValueError):
121115
line.set_linestyle('aardvark')
@@ -135,10 +129,6 @@ def test_drawstyle_variants():
135129

136130
@cleanup
137131
def test_valid_drawstyles():
138-
if sys.version_info[:2] < (2, 7):
139-
raise nose.SkipTest("assert_raises as context manager "
140-
"not supported with Python < 2.7")
141-
142132
line = mlines.Line2D([], [])
143133
with assert_raises(ValueError):
144134
line.set_drawstyle('foobar')

lib/matplotlib/tests/test_rcparams.py

+1-24
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
import io
77
import os
8-
import sys
98
import warnings
9+
from collections import OrderedDict
1010

1111
from cycler import cycler, Cycler
1212

@@ -16,7 +16,6 @@
1616
from matplotlib.testing.decorators import cleanup, knownfailureif
1717
import matplotlib.colors as mcolors
1818
from nose.tools import assert_true, assert_raises, assert_equal
19-
from nose.plugins.skip import SkipTest
2019
import nose
2120
from itertools import chain
2221
import numpy as np
@@ -115,9 +114,6 @@ def test_RcParams_class():
115114

116115

117116
def test_rcparams_update():
118-
if sys.version_info[:2] < (2, 7):
119-
raise nose.SkipTest("assert_raises as context manager "
120-
"not supported with Python < 2.7")
121117
rc = mpl.RcParams({'figure.figsize': (3.5, 42)})
122118
bad_dict = {'figure.figsize': (3.5, 42, 1)}
123119
# make sure validation happens on input
@@ -131,9 +127,6 @@ def test_rcparams_update():
131127

132128

133129
def test_rcparams_init():
134-
if sys.version_info[:2] < (2, 7):
135-
raise nose.SkipTest("assert_raises as context manager "
136-
"not supported with Python < 2.7")
137130
with assert_raises(ValueError):
138131
with warnings.catch_warnings():
139132
warnings.filterwarnings('ignore',
@@ -172,14 +165,6 @@ def test_Bug_2543():
172165
mpl.rcParams['svg.embed_char_paths'] = False
173166
assert_true(mpl.rcParams['svg.fonttype'] == "none")
174167

175-
176-
@cleanup
177-
def test_Bug_2543_newer_python():
178-
# only split from above because of the usage of assert_raises
179-
# as a context manager, which only works in 2.7 and above
180-
if sys.version_info[:2] < (2, 7):
181-
raise nose.SkipTest("assert_raises as context manager not supported with Python < 2.7")
182-
from matplotlib.rcsetup import validate_bool_maybe_none, validate_bool
183168
with assert_raises(ValueError):
184169
validate_bool_maybe_none("blah")
185170
with assert_raises(ValueError):
@@ -249,9 +234,6 @@ def _validation_test_helper(validator, arg, target):
249234

250235

251236
def _validation_fail_helper(validator, arg, exception_type):
252-
if sys.version_info[:2] < (2, 7):
253-
raise nose.SkipTest("assert_raises as context manager not "
254-
"supported with Python < 2.7")
255237
with assert_raises(exception_type):
256238
validator(arg)
257239

@@ -395,11 +377,6 @@ def test_rcparams_reset_after_fail():
395377
# raised an exception due to issues in the supplied rc parameters, the
396378
# global rc parameters were left in a modified state.
397379

398-
if sys.version_info[:2] >= (2, 7):
399-
from collections import OrderedDict
400-
else:
401-
raise SkipTest("Test can only be run in Python >= 2.7 as it requires OrderedDict")
402-
403380
with mpl.rc_context(rc={'text.usetex': False}):
404381

405382
assert mpl.rcParams['text.usetex'] is False

lib/matplotlib/tests/test_style.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
unicode_literals)
33

44
import os
5-
import sys
65
import shutil
76
import tempfile
7+
from collections import OrderedDict
88
from contextlib import contextmanager
99

10-
from nose import SkipTest
1110
from nose.tools import assert_raises
1211
from nose.plugins.attrib import attr
1312

@@ -121,12 +120,6 @@ def test_context_with_union_of_dict_and_namedstyle():
121120

122121

123122
def test_context_with_badparam():
124-
if sys.version_info[:2] >= (2, 7):
125-
from collections import OrderedDict
126-
else:
127-
m = "Test can only be run in Python >= 2.7 as it requires OrderedDict"
128-
raise SkipTest(m)
129-
130123
original_value = 'gray'
131124
other_value = 'blue'
132125
d = OrderedDict([(PARAM, original_value), ('badparam', None)])

lib/matplotlib/tests/test_text.py

-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import numpy as np
88
from numpy.testing import assert_almost_equal
99
from nose.tools import eq_, assert_raises
10-
from nose.plugins.skip import SkipTest
1110

1211
from matplotlib.transforms import Bbox
1312
import matplotlib
@@ -287,10 +286,6 @@ def test_get_rotation_int():
287286

288287
def test_get_rotation_raises():
289288
from matplotlib import text
290-
import sys
291-
if sys.version_info[:2] < (2, 7):
292-
raise SkipTest("assert_raises as context manager "
293-
"not supported with Python < 2.7")
294289
with assert_raises(ValueError):
295290
text.get_rotation('hozirontal')
296291

lib/mpl_toolkits/tests/test_mplot3d.py

-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import sys
2-
import nose
31
from nose.tools import assert_raises
42
from mpl_toolkits.mplot3d import Axes3D, axes3d
53
from matplotlib import cm
@@ -218,9 +216,6 @@ def test_wireframe3dzerorstride():
218216

219217
@cleanup
220218
def test_wireframe3dzerostrideraises():
221-
if sys.version_info[:2] < (2, 7):
222-
raise nose.SkipTest("assert_raises as context manager "
223-
"not supported with Python < 2.7")
224219
fig = plt.figure()
225220
ax = fig.add_subplot(111, projection='3d')
226221
X, Y, Z = axes3d.get_test_data(0.05)

setupext.py

+11-20
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818

1919
PY3min = (sys.version_info[0] >= 3)
20-
PY32min = (PY3min and sys.version_info[1] >= 2 or sys.version_info[0] > 3)
2120

2221

2322
def _get_home():
@@ -90,7 +89,7 @@ def _get_xdg_cache_dir():
9089

9190
setup_cfg = os.environ.get('MPLSETUPCFG', 'setup.cfg')
9291
if os.path.exists(setup_cfg):
93-
if PY32min:
92+
if PY3min:
9493
config = configparser.ConfigParser()
9594
else:
9695
config = configparser.SafeConfigParser()
@@ -724,7 +723,7 @@ def check(self):
724723
except ImportError:
725724
msgs += [bad_nose]
726725

727-
if sys.version_info >= (3, 3):
726+
if PY3min:
728727
msgs += ['using unittest.mock']
729728
else:
730729
try:
@@ -849,7 +848,7 @@ class Numpy(SetupPackage):
849848

850849
@staticmethod
851850
def include_dirs_hook():
852-
if sys.version_info[0] >= 3:
851+
if PY3min:
853852
import builtins
854853
if hasattr(builtins, '__NUMPY_SETUP__'):
855854
del builtins.__NUMPY_SETUP__
@@ -1047,11 +1046,11 @@ def do_custom_build(self):
10471046
pass
10481047

10491048
if not os.path.isfile(tarball_path):
1050-
1051-
if sys.version_info[0] == 2:
1052-
from urllib import urlretrieve
1053-
else:
1049+
if PY3min:
10541050
from urllib.request import urlretrieve
1051+
else:
1052+
from urllib import urlretrieve
1053+
10551054
if not os.path.exists('build'):
10561055
os.makedirs('build')
10571056

@@ -1370,14 +1369,6 @@ def check(self):
13701369
try:
13711370
import dateutil
13721371
except ImportError:
1373-
# dateutil 2.1 has a file encoding bug that breaks installation on
1374-
# python 3.3
1375-
# https://github.com/matplotlib/matplotlib/issues/2373
1376-
# hack around the problem by installing the (working) v2.0
1377-
major, minor1, _, _, _ = sys.version_info
1378-
if self.version is None and (major, minor1) == (3, 3):
1379-
self.version = '!=2.1'
1380-
13811372
return (
13821373
"dateutil was not found. It is required for date axis "
13831374
"support. pip/easy_install may attempt to install it "
@@ -1396,7 +1387,7 @@ class FuncTools32(SetupPackage):
13961387
name = "functools32"
13971388

13981389
def check(self):
1399-
if sys.version_info[:2] < (3, 2):
1390+
if not PY3min:
14001391
try:
14011392
import functools32
14021393
except ImportError:
@@ -1409,7 +1400,7 @@ def check(self):
14091400
return "Not required"
14101401

14111402
def get_install_requires(self):
1412-
if sys.version_info[:2] < (3, 2):
1403+
if not PY3min:
14131404
return ['functools32']
14141405
else:
14151406
return []
@@ -1419,7 +1410,7 @@ class Subprocess32(SetupPackage):
14191410
name = "subprocess32"
14201411

14211412
def check(self):
1422-
if sys.version_info[:2] < (3, 2):
1413+
if not PY3min:
14231414
try:
14241415
import subprocess32
14251416
except ImportError:
@@ -1433,7 +1424,7 @@ def check(self):
14331424
return "Not required"
14341425

14351426
def get_install_requires(self):
1436-
if sys.version_info[:2] < (3, 2) and os.name == 'posix':
1427+
if not PY3min and os.name == 'posix':
14371428
return ['subprocess32']
14381429
else:
14391430
return []

0 commit comments

Comments
 (0)