/usr/lib/python3/dist-packages/openpyxl/chart/tests/test_pie_chart.py is in python3-openpyxl 2.3.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | from __future__ import absolute_import
# Copyright (c) 2010-2015 openpyxl
import pytest
from openpyxl.xml.functions import fromstring, tostring
from openpyxl.tests.helper import compare_xml
@pytest.fixture
def PieChart():
from ..pie_chart import PieChart
return PieChart
class TestPieChart:
def test_ctor(self, PieChart):
chart = PieChart()
xml = tostring(chart.to_tree())
expected = """
<pieChart>
<varyColors val="1" />
<firstSliceAng val="0" />
</pieChart>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, PieChart):
src = """
<pieChart>
<varyColors val="1" />
<explosion val="5"/>
<firstSliceAng val="60"/>
</pieChart>
"""
node = fromstring(src)
chart = PieChart.from_tree(node)
assert dict(chart) == {}
assert chart.varyColors is True
assert chart.firstSliceAng == 60
@pytest.fixture
def PieChart3D():
from ..pie_chart import PieChart3D
return PieChart3D
class TestPieChart3D:
def test_ctor(self, PieChart3D):
chart = PieChart3D()
xml = tostring(chart.to_tree())
expected = """
<pie3DChart>
<varyColors val="1" />
</pie3DChart>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
@pytest.fixture
def DoughnutChart():
from ..pie_chart import DoughnutChart
return DoughnutChart
class TestDoughnutChart:
def test_ctor(self, DoughnutChart):
chart = DoughnutChart()
xml = tostring(chart.to_tree())
expected = """
<doughnutChart>
<varyColors val="1" />
<firstSliceAng val="0" />
<holeSize val="10" />
</doughnutChart>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, DoughnutChart):
src = """
<doughnutChart>
<firstSliceAng val="0"/>
<holeSize val="50"/>
</doughnutChart>
"""
node = fromstring(src)
chart = DoughnutChart.from_tree(node)
assert dict(chart) == {}
assert chart.firstSliceAng == 0
assert chart.holeSize == 50
@pytest.fixture
def ProjectedPieChart():
from ..pie_chart import ProjectedPieChart
return ProjectedPieChart
class TestProjectedPieChart:
def test_ctor(self, ProjectedPieChart):
chart = ProjectedPieChart()
xml = tostring(chart.to_tree())
expected = """
<ofPieChart>
<varyColors val="1" />
<ofPieType val="pie"/>
<splitType val="auto"/>
<secondPieSize val="75"/>
<serLines/>
</ofPieChart>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, ProjectedPieChart):
src = """
<ofPieChart>
<varyColors val="1"/>
<ofPieType val="pie"/>
<splitType val="auto"/>
<dLbls>
<showLegendKey val="0"/>
<showVal val="0"/>
<showCatName val="0"/>
<showSerName val="0"/>
<showPercent val="0"/>
<showBubbleSize val="0"/>
<showLeaderLines val="1"/>
</dLbls>
<gapWidth val="150"/>
<secondPieSize val="75"/>
<serLines/>
</ofPieChart>
"""
node = fromstring(src)
chart = ProjectedPieChart.from_tree(node)
assert dict(chart) == {}
assert chart.gapWidth == 150
assert chart.secondPieSize == 75
@pytest.fixture
def CustomSplit():
from ..pie_chart import CustomSplit
return CustomSplit
class TestCustomSplit:
def test_ctor(self, CustomSplit):
pie_chart = CustomSplit([1, 2, 3])
xml = tostring(pie_chart.to_tree())
expected = """
<custSplit>
<secondPiePt val="1" />
<secondPiePt val="2" />
<secondPiePt val="3" />
</custSplit>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, CustomSplit):
src = """
<custSplit>
<secondPiePt val="1" />
<secondPiePt val="2" />
</custSplit>
"""
node = fromstring(src)
pie_chart = CustomSplit.from_tree(node)
assert pie_chart == CustomSplit([1, 2])
|