Skip to content

Commit 5c12679

Browse files
committed
Add unitteses for get_rotation
1 parent 98fea36 commit 5c12679

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

lib/matplotlib/tests/test_text.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from matplotlib.testing.decorators import image_comparison, knownfailureif, cleanup
99
import matplotlib.pyplot as plt
1010
import warnings
11-
from nose.tools import with_setup
11+
from nose import SkipTest
12+
from nose.tools import with_setup, assert_raises
1213

1314

1415
@image_comparison(baseline_images=['font_styles'])
@@ -236,3 +237,37 @@ def test_set_position():
236237

237238
for a, b in zip(init_pos.min, post_pos.min):
238239
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

Comments
 (0)