Changeset 174

Show
Ignore:
Timestamp:
03/21/09 05:06:35 (3 years ago)
Author:
lgs
Message:

Add a test for the interval option. Closes #28

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/tests/chart.py

    r169 r174  
    228228        self.assertAlmostEqual(ch.yscale, 0.1111, 4) 
    229229 
     230    def test_interval(self): 
     231        surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 500, 500) 
     232        opt = {'axis': {'y': {'interval': 2.5}}} 
     233        ch = pycha.chart.Chart(surface, opt) 
     234        dataset = ( 
     235            ('dataset1', ([0, 1], [1, 4], [2, 10])), 
     236            ) 
     237        ch.addDataset(dataset) 
     238        ch._updateXY() 
     239        ch._updateTicks() 
     240        yticks = ((0.75, 2.5), (0.5, 5.0), 
     241                  (0.25, 7.5), (0.0, 10.0)) 
     242 
     243        self.assertEqual(len(yticks), len(ch.yticks)) 
     244        for i, (pos, label) in enumerate(yticks): 
     245            tick = ch.yticks[i] 
     246            self.assertAlmostEqual(tick[0], pos, 2) 
     247            self.assertAlmostEqual(tick[1], label, 2) 
     248 
    230249 
    231250def test_suite():