|
8 | 8 | from matplotlib.testing.decorators import image_comparison, knownfailureif, cleanup
|
9 | 9 | import matplotlib.pyplot as plt
|
10 | 10 | import warnings
|
11 |
| -from nose.tools import with_setup |
| 11 | +from nose import SkipTest |
| 12 | +from nose.tools import with_setup, assert_raises |
12 | 13 |
|
13 | 14 |
|
14 | 15 | @image_comparison(baseline_images=['font_styles'])
|
@@ -236,3 +237,37 @@ def test_set_position():
|
236 | 237 |
|
237 | 238 | for a, b in zip(init_pos.min, post_pos.min):
|
238 | 239 | assert a + shift_val == b
|
| 240 | + |
| 241 | + |
| 242 | +def test_get_rotation_string(): |
| 243 | + from matplotlib import text |
| 244 | + assert text.get_rotation('horizontal') == 0. |
| 245 | + assert text.get_rotation('vertical') == 90. |
| 246 | + assert text.get_rotation('15.') == 15. |
| 247 | + |
| 248 | + |
| 249 | +def test_get_rotation_float(): |
| 250 | + from matplotlib import text |
| 251 | + for i in [15., 16.70, 77.4]: |
| 252 | + assert text.get_rotation(i) == i |
| 253 | + |
| 254 | + |
| 255 | +def test_get_rotation_int(): |
| 256 | + from matplotlib import text |
| 257 | + for i in [67, 16, 41]: |
| 258 | + assert text.get_rotation(i) == float(i) |
| 259 | + |
| 260 | + |
| 261 | +def test_get_rotation_raises(): |
| 262 | + from matplotlib import text |
| 263 | + import sys |
| 264 | + if sys.version_info[:2] < (2, 7): |
| 265 | + raise SkipTest("assert_raises as context manager " |
| 266 | + "not supported with Python < 2.7") |
| 267 | + with assert_raises(ValueError): |
| 268 | + text.get_rotation('hozirontal') |
| 269 | + |
| 270 | + |
| 271 | +def test_get_rotation_none(): |
| 272 | + from matplotlib import text |
| 273 | + assert text.get_rotation(None) == 0.0 |
0 commit comments