1
- from ..exporter import Exporter
2
- from ..renderers import FakeRenderer , FullFakeRenderer
1
+ # TODO: matplotlib-build-wip
2
+ from nose .plugins .attrib import attr
3
+ from plotly .tools import _matplotlylib_imported
3
4
4
- import matplotlib
5
- matplotlib . use ( 'Agg' )
6
- import matplotlib . pyplot as plt
5
+ if _matplotlylib_imported :
6
+ from .. exporter import Exporter
7
+ from .. renderers import FakeRenderer , FullFakeRenderer
7
8
8
- import numpy as np
9
- from numpy .testing import assert_warns
9
+ import matplotlib
10
+ matplotlib .use ('Agg' )
11
+ import matplotlib .pyplot as plt
10
12
13
+ import numpy as np
14
+ from numpy .testing import assert_warns
11
15
16
+
17
+ @attr ('matplotlib' )
12
18
def fake_renderer_output (fig , Renderer ):
13
19
renderer = Renderer ()
14
20
exporter = Exporter (renderer )
15
21
exporter .run (fig )
16
22
return renderer .output
17
23
18
24
25
+ @attr ('matplotlib' )
19
26
def _assert_output_equal (text1 , text2 ):
20
27
for line1 , line2 in zip (text1 .strip ().split (), text2 .strip ().split ()):
21
28
assert line1 == line2
22
29
23
30
31
+ @attr ('matplotlib' )
24
32
def test_lines ():
25
33
fig , ax = plt .subplots ()
26
34
ax .plot (range (20 ), '-k' )
@@ -44,6 +52,7 @@ def test_lines():
44
52
""" )
45
53
46
54
55
+ @attr ('matplotlib' )
47
56
def test_markers ():
48
57
fig , ax = plt .subplots ()
49
58
ax .plot (range (2 ), 'ok' )
@@ -68,6 +77,7 @@ def test_markers():
68
77
""" )
69
78
70
79
80
+ @attr ('matplotlib' )
71
81
def test_path_collection ():
72
82
fig , ax = plt .subplots ()
73
83
ax .scatter (range (3 ), range (3 ))
@@ -93,6 +103,7 @@ def test_path_collection():
93
103
""" )
94
104
95
105
106
+ @attr ('matplotlib' )
96
107
def test_text ():
97
108
fig , ax = plt .subplots ()
98
109
ax .set_xlabel ("my x label" )
@@ -113,6 +124,7 @@ def test_text():
113
124
""" )
114
125
115
126
127
+ @attr ('matplotlib' )
116
128
def test_path ():
117
129
fig , ax = plt .subplots ()
118
130
ax .add_patch (plt .Circle ((0 , 0 ), 1 ))
@@ -129,6 +141,7 @@ def test_path():
129
141
""" )
130
142
131
143
144
+ @attr ('matplotlib' )
132
145
def test_multiaxes ():
133
146
fig , ax = plt .subplots (2 )
134
147
ax [0 ].plot (range (4 ))
@@ -147,6 +160,7 @@ def test_multiaxes():
147
160
""" )
148
161
149
162
163
+ @attr ('matplotlib' )
150
164
def test_image ():
151
165
np .random .seed (0 ) # image size depends on the seed
152
166
fig , ax = plt .subplots ()
@@ -163,6 +177,7 @@ def test_image():
163
177
""" )
164
178
165
179
180
+ @attr ('matplotlib' )
166
181
def test_legend ():
167
182
fig , ax = plt .subplots ()
168
183
ax .plot ([1 ,2 ,3 ], label = 'label' )
@@ -178,6 +193,8 @@ def test_legend():
178
193
closing figure
179
194
""" )
180
195
196
+
197
+ @attr ('matplotlib' )
181
198
def test_legend_dots ():
182
199
fig , ax = plt .subplots ()
183
200
ax .plot ([1 ,2 ,3 ], label = 'label' )
@@ -200,8 +217,9 @@ def test_legend_dots():
200
217
closing figure
201
218
""" )
202
219
220
+
221
+ @attr ('matplotlib' )
203
222
def test_blended ():
204
223
fig , ax = plt .subplots ()
205
224
ax .axvline (0 )
206
225
assert_warns (UserWarning , fake_renderer_output , fig , FakeRenderer )
207
-
0 commit comments