Skip to content

Commit d960a52

Browse files
committed
FIX assert_raises cannot be called with with
- Fixed 5 tests failing - PEP8 compliance
1 parent 1d3faee commit d960a52

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

lib/matplotlib/tests/test_figure.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import matplotlib
21
from nose.tools import assert_equal, assert_is, assert_is_not
32
from matplotlib.testing.decorators import image_comparison, cleanup
43
import matplotlib.pyplot as plt

lib/matplotlib/tests/test_subplots.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ def test_shared():
9696

9797
def test_exceptions():
9898
# TODO should this test more options?
99-
with assert_raises(ValueError):
100-
plt.subplots(2, 2, sharex='blah')
101-
plt.subplots(2, 2, sharey='blah')
99+
assert_raises(ValueError, plt.subplots, 2, 2, sharex='blah')
100+
assert_raises(ValueError, plt.subplots, 2, 2, sharey='blah')
102101

103102

104103
def test_subplots():
@@ -108,3 +107,8 @@ def test_subplots():
108107
test_shared()
109108
# - are exceptions thrown correctly
110109
test_exceptions()
110+
111+
112+
if __name__ == "__main__":
113+
import nose
114+
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_ticker.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import print_function
2-
from nose.tools import assert_equal, assert_raises
2+
from nose.tools import assert_raises
33
from numpy.testing import assert_almost_equal
44
import numpy as np
55

@@ -8,10 +8,10 @@
88

99
def test_MaxNLocator():
1010
loc = mticker.MaxNLocator(nbins=5)
11-
test_value = np.array([ 20., 40., 60., 80., 100.])
11+
test_value = np.array([20., 40., 60., 80., 100.])
1212
assert_almost_equal(loc.tick_values(20, 100), test_value)
1313

14-
test_value = np.array([ 0., 0.0002, 0.0004, 0.0006, 0.0008, 0.001])
14+
test_value = np.array([0., 0.0002, 0.0004, 0.0006, 0.0008, 0.001])
1515
assert_almost_equal(loc.tick_values(0.001, 0.0001), test_value)
1616

1717
test_value = np.array([-1.0e+15, -5.0e+14, 0e+00, 5e+14, 1.0e+15])
@@ -33,9 +33,7 @@ def test_MultipleLocator():
3333
def test_LogLocator():
3434
loc = mticker.LogLocator(numticks=5)
3535

36-
# make sure the 0 case is covered with an exception
37-
with assert_raises(ValueError):
38-
loc.tick_values(0, 1000)
36+
assert_raises(ValueError, loc.tick_values, 0, 1000)
3937

4038
test_value = np.array([1.00000000e-03, 1.00000000e-01, 1.00000000e+01,
4139
1.00000000e+03, 1.00000000e+05, 1.00000000e+07])
@@ -46,6 +44,6 @@ def test_LogLocator():
4644
assert_almost_equal(loc.tick_values(1, 100), test_value)
4745

4846

49-
if __name__=='__main__':
47+
if __name__ == '__main__':
5048
import nose
51-
nose.runmodule(argv=['-s','--with-doctest'], exit=False)
49+
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
 (0)