Changeset 79 for trunk/tests/chart.py

Show
Ignore:
Timestamp:
03/21/08 12:44:24 (4 years ago)
Author:
lgs
Message:

Fix the y ticks when given explicitily. Fix #7, patch by jae_AT_zhar.net

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/tests/chart.py

    r61 r79  
    189189            self.assertAlmostEqual(ch.yticks[i][1], yticks[i][1], 4) 
    190190 
     191    def test_updateExplicitTicks(self): 
     192        """Test for bug #7""" 
     193        surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 500, 500) 
     194        yticks = [dict(v=i, label=str(i)) for i in range(0, 3)] 
     195        opt = {'axis': {'y': {'ticks': yticks}}} 
     196        dataset = ( 
     197            ('dataset1', ([0, 1], [1, 1], [2, 3])), 
     198            ) 
     199        ch = pycha.chart.Chart(surface, opt) 
     200        ch.addDataset(dataset) 
     201        ch._updateXY() 
     202        ch._updateTicks() 
     203        self.assertAlmostEqual(ch.yticks[0][0], 1.0, 4) 
     204        self.assertAlmostEqual(ch.yticks[1][0], 2/3.0, 4) 
     205        self.assertAlmostEqual(ch.yticks[2][0], 1/3.0, 4) 
     206         
    191207    def test_abstractChart(self): 
    192208        ch = pycha.chart.Chart(None)