示例#1
0
 def testNegativeSegmentSizes(self):
     self.assertRaises(AssertionError, pie_chart.PieChart, [-5, 10],
                       ['Negative', 'Positive'])
     chart = pie_chart.PieChart()
     self.assertRaises(AssertionError, pie_chart.Segment, -5, 'Dummy',
                       '0000ff')
     segment = chart.AddSegment(10, label='Dummy', color='0000ff')
     self.assertRaises(AssertionError, segment._SetSize, -5)
示例#2
0
 def testAddSegmentToPie(self):
     chart = pie_chart.PieChart()
     chart.AddPie([1], ['A'], ['ff0000'])
     chart.AddPie([2], ['B'], ['0000ff'])
     chart.AddSegment([10], ['AA'])
     self.assertEqual(len(chart.data[0]), 2)
     self.assertEqual(len(chart.data[1]), 1)
     chart.AddSegment([20], ['BB'], pie_index=1)
     self.assertEqual(len(chart.data[0]), 2)
     self.assertEqual(len(chart.data[1]), 2)
示例#3
0
 def testAddSegmentsOrder(self):
     chart = pie_chart.PieChart()
     # Deprecated approach
     warnings.filterwarnings('error')
     self.assertRaises(DeprecationWarning, chart.AddSegments, [1],
                       ['0000FF'], ['label'])
     # New order
     warnings.filterwarnings('ignore')
     chart.AddSegments([1], ['label'], ['0000FF'])
     self.assertEqual('label', chart.data[0][0].label)
     self.assertEqual('0000FF', chart.data[0][0].color)
示例#4
0
    def testAddSegmentOrder(self):
        chart = pie_chart.PieChart()
        # Deprecated approach
        warnings.filterwarnings('error')
        self.assertRaises(DeprecationWarning, chart.AddSegment, 1, '0000FF',
                          'label')

        # New order
        chart.AddSegment(1, 'label', '0000FF')
        self.assertEqual('label', chart.data[0][0].label)
        self.assertEqual('0000FF', chart.data[0][0].color)
示例#5
0
 def testAddPie(self):
     chart = pie_chart.PieChart()
     i = chart.AddPie([1], ['A'], ['ff0000'])
     self.assertEqual(i, 0)
     self.assertEqual(len(chart.data), 1)
     self.assertEqual(len(chart.data[0]), 1)
     self.assertEqual(chart.data[0][0].size, 1)
     i = chart.AddPie([2], ['B'], ['0000ff'])
     self.assertEqual(i, 1)
     self.assertEqual(len(chart.data), 2)
     self.assertEqual(len(chart.data[0]), 1)
     self.assertEqual(chart.data[0][0].size, 1)
     self.assertEqual(len(chart.data[1]), 1)
     self.assertEqual(chart.data[1][0].size, 2)