|
1 | | -from nose.tools import assert_equal, assert_is, assert_is_not |
| 1 | +from nose.tools import assert_equal, assert_true |
2 | 2 | from matplotlib.testing.decorators import image_comparison, cleanup |
3 | 3 | import matplotlib.pyplot as plt |
4 | 4 |
|
5 | 5 |
|
6 | 6 | @cleanup |
7 | 7 | def test_figure_label(): |
8 | | - # pyplot figure creation, selection and closing with figure label and number |
| 8 | + # pyplot figure creation, selection and closing with figure label and |
| 9 | + # number |
9 | 10 | plt.close('all') |
10 | 11 | plt.figure('today') |
11 | 12 | plt.figure(3) |
@@ -33,34 +34,37 @@ def test_figure(): |
33 | 34 | ax.plot(range(5)) |
34 | 35 | # plot red line in a different figure. |
35 | 36 | plt.figure('tomorrow') |
36 | | - plt.plot([0, 1], [1,0], 'r') |
| 37 | + plt.plot([0, 1], [1, 0], 'r') |
37 | 38 | # Return to the original; make sure the red line is not there. |
38 | 39 | plt.figure('today') |
39 | 40 | plt.close('tomorrow') |
40 | | - |
41 | | - |
| 41 | + |
| 42 | + |
42 | 43 | @cleanup |
43 | 44 | def test_gca(): |
44 | 45 | fig = plt.figure() |
45 | 46 |
|
46 | 47 | ax1 = fig.add_axes([0, 0, 1, 1]) |
47 | | - assert_is(fig.gca(projection='rectilinear'), ax1) |
48 | | - assert_is(fig.gca(), ax1) |
49 | | - |
| 48 | + assert_true(fig.gca(projection='rectilinear') is ax1) |
| 49 | + assert_true(fig.gca() is ax1) |
| 50 | + |
50 | 51 | ax2 = fig.add_subplot(121, projection='polar') |
51 | | - assert_is(fig.gca(), ax2) |
52 | | - assert_is(fig.gca(polar=True), ax2) |
53 | | - |
| 52 | + assert_true(fig.gca() is ax2) |
| 53 | + assert_true(fig.gca(polar=True)is ax2) |
| 54 | + |
54 | 55 | ax3 = fig.add_subplot(122) |
55 | | - assert_is(fig.gca(), ax3) |
| 56 | + assert_true(fig.gca() is ax3) |
56 | 57 |
|
57 | 58 | # the final request for a polar axes will end up creating one |
58 | 59 | # with a spec of 111. |
59 | | - assert_is_not(fig.gca(polar=True), ax3) |
60 | | - assert_is_not(fig.gca(polar=True), ax2) |
| 60 | + assert_true(fig.gca(polar=True) is not ax3) |
| 61 | + assert_true(fig.gca(polar=True) is not ax2) |
61 | 62 | assert_equal(fig.gca().get_geometry(), (1, 1, 1)) |
62 | | - |
| 63 | + |
63 | 64 | fig.sca(ax1) |
64 | | - assert_is(fig.gca(projection='rectilinear'), ax1) |
65 | | - assert_is(fig.gca(), ax1) |
66 | | - |
| 65 | + assert_true(fig.gca(projection='rectilinear') is ax1) |
| 66 | + assert_true(fig.gca() is ax1) |
| 67 | + |
| 68 | +if __name__ == "__main__": |
| 69 | + import nose |
| 70 | + nose.runmodule(argv=['-s', '--with-doctest'], exit=False) |
0 commit comments