Changeset 76 for trunk/tests/bar.py

Show
Ignore:
Timestamp:
03/20/08 05:52:06 (4 years ago)
Author:
lgs
Message:

Make bar charts more robust by allowing datasets with just one point. Patch by jae_AT_zhar.net that fixes #9

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/tests/bar.py

    r73 r76  
    4040        self.assertEqual(ch.bars, []) 
    4141        self.assertEqual(ch.minxdelta, 0) 
     42 
     43    def test_updateChart(self): 
     44        surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 500, 500) 
     45        # An evil dataset with just one point. See bug #9 
     46        dataset = ( 
     47            ('dataset1', ([0, 0],)), 
     48        ) 
     49        ch = pycha.bar.BarChart(surface) 
     50        ch.addDataset(dataset) 
     51        ch._updateXY() 
     52        ch._updateChart() 
     53 
     54        self.assertEqual(ch.xscale, 1.0) 
     55        self.assertEqual(ch.minxval, 0) 
     56        self.assertAlmostEqual(ch.barWidthForSet, 0.75, 4) 
     57        self.assertAlmostEqual(ch.barMargin, 0.125, 4) 
    4258 
    4359class VerticalBarTests(unittest.TestCase):