Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0efe877

Browse files
committed
test conversion: move old-style test to new-style test
svn path=/trunk/matplotlib/; revision=7682
1 parent 8d00db9 commit 0efe877

3 files changed

Lines changed: 30 additions & 27 deletions

File tree

test/test_matplotlib/baseline/TestTickers/RRuleLocator_bounds.png renamed to lib/matplotlib/tests/baseline_images/test_dates/RRuleLocator_bounds.png

File renamed without changes.

lib/matplotlib/tests/test_dates.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,36 @@ def test_too_many_date_ticks():
8383
ax.xaxis.set_major_locator(DayLocator())
8484
assert_raises(RuntimeError, fig.savefig, 'junk.png')
8585

86+
@image_comparison(baseline_images=['RRuleLocator_bounds'])
87+
def test_RRuleLocator():
88+
import pylab
89+
import matplotlib.dates as mpldates
90+
import matplotlib.testing.jpl_units as units
91+
from datetime import datetime
92+
import dateutil
93+
units.register()
94+
95+
# This will cause the RRuleLocator to go out of bounds when it tries
96+
# to add padding to the limits, so we make sure it caps at the correct
97+
# boundary values.
98+
t0 = datetime( 1000, 1, 1 )
99+
tf = datetime( 6000, 1, 1 )
100+
101+
fig = pylab.figure()
102+
ax = pylab.subplot( 111 )
103+
ax.set_autoscale_on( True )
104+
ax.plot( [t0, tf], [0.0, 1.0], marker='o' )
105+
106+
rrule = mpldates.rrulewrapper( dateutil.rrule.YEARLY, interval=500 )
107+
locator = mpldates.RRuleLocator( rrule )
108+
ax.xaxis.set_major_locator( locator )
109+
ax.xaxis.set_major_formatter( mpldates.AutoDateFormatter(locator) )
110+
111+
ax.autoscale_view()
112+
fig.autofmt_xdate()
113+
114+
fig.savefig( 'RRuleLocator_bounds' )
115+
86116
if __name__=='__main__':
87117
import nose
88118
nose.runmodule(argv=['-s','--with-doctest'], exit=False)

test/test_matplotlib/TestTickers.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,33 +45,6 @@ def tearDown( self ):
4545
"""Clean-up any generated files here."""
4646
pass
4747

48-
#--------------------------------------------------------------------
49-
def test_RRuleLocator( self ):
50-
"""Test RRuleLocator"""
51-
fname = self.outFile( "RRuleLocator_bounds.png" )
52-
53-
# This will cause the RRuleLocator to go out of bounds when it tries
54-
# to add padding to the limits, so we make sure it caps at the correct
55-
# boundary values.
56-
t0 = datetime( 1000, 1, 1 )
57-
tf = datetime( 6000, 1, 1 )
58-
59-
fig = pylab.figure()
60-
ax = pylab.subplot( 111 )
61-
ax.set_autoscale_on( True )
62-
ax.plot( [t0, tf], [0.0, 1.0], marker='o' )
63-
64-
rrule = mpldates.rrulewrapper( dateutil.rrule.YEARLY, interval=500 )
65-
locator = mpldates.RRuleLocator( rrule )
66-
ax.xaxis.set_major_locator( locator )
67-
ax.xaxis.set_major_formatter( mpldates.AutoDateFormatter(locator) )
68-
69-
ax.autoscale_view()
70-
fig.autofmt_xdate()
71-
72-
fig.savefig( fname )
73-
self.checkImage( fname )
74-
7548
#--------------------------------------------------------------------
7649
def test_DateFormatter( self ):
7750
"""Test DateFormatter"""

0 commit comments

Comments
 (0)