Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop old Python checks #7316

Merged
merged 2 commits into from
Oct 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/compat/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from __future__ import print_function
import os
import sys
if os.name == 'posix' and sys.version_info[:2] < (3, 2):
if os.name == 'posix' and sys.version_info[0] < 3:
# work around for https://github.com/matplotlib/matplotlib/issues/5314
try:
import subprocess32 as subprocess
Expand Down
5 changes: 0 additions & 5 deletions lib/matplotlib/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
unicode_literals)

import six
import sys
import io
import os

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

from xml.etree import ElementTree

np.random.seed(0)
Expand Down
10 changes: 0 additions & 10 deletions lib/matplotlib/tests/test_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import matplotlib.pyplot as plt
from matplotlib.testing.decorators import cleanup, image_comparison

import sys


@cleanup
def test_invisible_Line_rendering():
Expand Down Expand Up @@ -112,10 +110,6 @@ def test_linestyle_variants():

@cleanup
def test_valid_linestyles():
if sys.version_info[:2] < (2, 7):
raise nose.SkipTest("assert_raises as context manager "
"not supported with Python < 2.7")

line = mlines.Line2D([], [])
with assert_raises(ValueError):
line.set_linestyle('aardvark')
Expand All @@ -135,10 +129,6 @@ def test_drawstyle_variants():

@cleanup
def test_valid_drawstyles():
if sys.version_info[:2] < (2, 7):
raise nose.SkipTest("assert_raises as context manager "
"not supported with Python < 2.7")

line = mlines.Line2D([], [])
with assert_raises(ValueError):
line.set_drawstyle('foobar')
Expand Down
25 changes: 1 addition & 24 deletions lib/matplotlib/tests/test_rcparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import io
import os
import sys
import warnings
from collections import OrderedDict

from cycler import cycler, Cycler

Expand All @@ -16,7 +16,6 @@
from matplotlib.testing.decorators import cleanup, knownfailureif
import matplotlib.colors as mcolors
from nose.tools import assert_true, assert_raises, assert_equal
from nose.plugins.skip import SkipTest
import nose
from itertools import chain
import numpy as np
Expand Down Expand Up @@ -115,9 +114,6 @@ def test_RcParams_class():


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


def test_rcparams_init():
if sys.version_info[:2] < (2, 7):
raise nose.SkipTest("assert_raises as context manager "
"not supported with Python < 2.7")
with assert_raises(ValueError):
with warnings.catch_warnings():
warnings.filterwarnings('ignore',
Expand Down Expand Up @@ -172,14 +165,6 @@ def test_Bug_2543():
mpl.rcParams['svg.embed_char_paths'] = False
assert_true(mpl.rcParams['svg.fonttype'] == "none")


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


def _validation_fail_helper(validator, arg, exception_type):
if sys.version_info[:2] < (2, 7):
raise nose.SkipTest("assert_raises as context manager not "
"supported with Python < 2.7")
with assert_raises(exception_type):
validator(arg)

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

if sys.version_info[:2] >= (2, 7):
from collections import OrderedDict
else:
raise SkipTest("Test can only be run in Python >= 2.7 as it requires OrderedDict")

with mpl.rc_context(rc={'text.usetex': False}):

assert mpl.rcParams['text.usetex'] is False
Expand Down
9 changes: 1 addition & 8 deletions lib/matplotlib/tests/test_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
unicode_literals)

import os
import sys
import shutil
import tempfile
from collections import OrderedDict
from contextlib import contextmanager

from nose import SkipTest
from nose.tools import assert_raises
from nose.plugins.attrib import attr

Expand Down Expand Up @@ -121,12 +120,6 @@ def test_context_with_union_of_dict_and_namedstyle():


def test_context_with_badparam():
if sys.version_info[:2] >= (2, 7):
from collections import OrderedDict
else:
m = "Test can only be run in Python >= 2.7 as it requires OrderedDict"
raise SkipTest(m)

original_value = 'gray'
other_value = 'blue'
d = OrderedDict([(PARAM, original_value), ('badparam', None)])
Expand Down
5 changes: 0 additions & 5 deletions lib/matplotlib/tests/test_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import numpy as np
from numpy.testing import assert_almost_equal
from nose.tools import eq_, assert_raises
from nose.plugins.skip import SkipTest

from matplotlib.transforms import Bbox
import matplotlib
Expand Down Expand Up @@ -287,10 +286,6 @@ def test_get_rotation_int():

def test_get_rotation_raises():
from matplotlib import text
import sys
if sys.version_info[:2] < (2, 7):
raise SkipTest("assert_raises as context manager "
"not supported with Python < 2.7")
with assert_raises(ValueError):
text.get_rotation('hozirontal')

Expand Down
5 changes: 0 additions & 5 deletions lib/mpl_toolkits/tests/test_mplot3d.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import sys
import nose
from nose.tools import assert_raises
from mpl_toolkits.mplot3d import Axes3D, axes3d
from matplotlib import cm
Expand Down Expand Up @@ -218,9 +216,6 @@ def test_wireframe3dzerorstride():

@cleanup
def test_wireframe3dzerostrideraises():
if sys.version_info[:2] < (2, 7):
raise nose.SkipTest("assert_raises as context manager "
"not supported with Python < 2.7")
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
X, Y, Z = axes3d.get_test_data(0.05)
Expand Down
31 changes: 11 additions & 20 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


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


def _get_home():
Expand Down Expand Up @@ -90,7 +89,7 @@ def _get_xdg_cache_dir():

setup_cfg = os.environ.get('MPLSETUPCFG', 'setup.cfg')
if os.path.exists(setup_cfg):
if PY32min:
if PY3min:
config = configparser.ConfigParser()
else:
config = configparser.SafeConfigParser()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not six.moves.configparser.SafeConfigParser?

Expand Down Expand Up @@ -724,7 +723,7 @@ def check(self):
except ImportError:
msgs += [bad_nose]

if sys.version_info >= (3, 3):
if PY3min:
msgs += ['using unittest.mock']
else:
try:
Expand Down Expand Up @@ -849,7 +848,7 @@ class Numpy(SetupPackage):

@staticmethod
def include_dirs_hook():
if sys.version_info[0] >= 3:
if PY3min:
import builtins
if hasattr(builtins, '__NUMPY_SETUP__'):
del builtins.__NUMPY_SETUP__
Expand Down Expand Up @@ -1047,11 +1046,11 @@ def do_custom_build(self):
pass

if not os.path.isfile(tarball_path):

if sys.version_info[0] == 2:
from urllib import urlretrieve
else:
if PY3min:
from urllib.request import urlretrieve
else:
from urllib import urlretrieve
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not six.moves.urllib.request.urlretrieve?


if not os.path.exists('build'):
os.makedirs('build')

Expand Down Expand Up @@ -1370,14 +1369,6 @@ def check(self):
try:
import dateutil
except ImportError:
# dateutil 2.1 has a file encoding bug that breaks installation on
# python 3.3
# https://github.com/matplotlib/matplotlib/issues/2373
# hack around the problem by installing the (working) v2.0
major, minor1, _, _, _ = sys.version_info
if self.version is None and (major, minor1) == (3, 3):
self.version = '!=2.1'

return (
"dateutil was not found. It is required for date axis "
"support. pip/easy_install may attempt to install it "
Expand All @@ -1396,7 +1387,7 @@ class FuncTools32(SetupPackage):
name = "functools32"

def check(self):
if sys.version_info[:2] < (3, 2):
if not PY3min:
try:
import functools32
except ImportError:
Expand All @@ -1409,7 +1400,7 @@ def check(self):
return "Not required"

def get_install_requires(self):
if sys.version_info[:2] < (3, 2):
if not PY3min:
return ['functools32']
else:
return []
Expand All @@ -1419,7 +1410,7 @@ class Subprocess32(SetupPackage):
name = "subprocess32"

def check(self):
if sys.version_info[:2] < (3, 2):
if not PY3min:
try:
import subprocess32
except ImportError:
Expand All @@ -1433,7 +1424,7 @@ def check(self):
return "Not required"

def get_install_requires(self):
if sys.version_info[:2] < (3, 2) and os.name == 'posix':
if not PY3min and os.name == 'posix':
return ['subprocess32']
else:
return []
Expand Down