/usr/lib/python2.7/dist-packages/openpyxl/chart/tests/test_chartspace.py is in python-openpyxl 2.4.9-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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | from __future__ import absolute_import
# Copyright (c) 2010-2017 openpyxl
import pytest
from openpyxl.xml.functions import fromstring, tostring
from openpyxl.tests.helper import compare_xml
@pytest.fixture
def ChartContainer():
from ..chartspace import ChartContainer
return ChartContainer
class TestChartContainer:
def test_ctor(self, ChartContainer):
container = ChartContainer()
xml = tostring(container.to_tree())
expected = """
<chart>
<plotArea></plotArea>
<dispBlanksAs val="gap"></dispBlanksAs>
</chart>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, ChartContainer):
src = """
<chart>
<plotArea></plotArea>
<dispBlanksAs val="gap"></dispBlanksAs>
</chart>
"""
node = fromstring(src)
container = ChartContainer.from_tree(node)
assert container == ChartContainer()
@pytest.fixture
def PlotArea():
from ..chartspace import PlotArea
return PlotArea
class TestPlotArea:
def test_ctor(self, PlotArea):
chartspace = PlotArea()
xml = tostring(chartspace.to_tree())
expected = """
<plotArea />
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, PlotArea):
src = """
<plotArea />
"""
node = fromstring(src)
chartspace = PlotArea.from_tree(node)
assert chartspace == PlotArea()
@pytest.fixture
def DataTable():
from ..chartspace import DataTable
return DataTable
class TestDataTable:
def test_ctor(self, DataTable):
table = DataTable()
xml = tostring(table.to_tree())
expected = """
<dTable />
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, DataTable):
src = """
<dTable />
"""
node = fromstring(src)
table = DataTable.from_tree(node)
assert table == DataTable()
@pytest.fixture
def Surface():
from .._3d import Surface
return Surface
class TestSurface:
def test_ctor(self, Surface):
surface = Surface()
xml = tostring(surface.to_tree())
expected = """
<surface />
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, Surface):
src = """
<surface />
"""
node = fromstring(src)
surface = Surface.from_tree(node)
assert surface == Surface()
@pytest.fixture
def View3D():
from .._3d import View3D
return View3D
class TestView3D:
def test_ctor(self, View3D):
view = View3D()
xml = tostring(view.to_tree())
expected = """
<view3D>
<rotX val="15"></rotX>
<rotY val="20"></rotY>
<rAngAx val="1"></rAngAx>
</view3D>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, View3D):
src = """
<view3D>
<rotX val="15"/>
<rotY val="20"/>
<rAngAx val="0"/>
<perspective val="30"/>
</view3D>
"""
node = fromstring(src)
view = View3D.from_tree(node)
assert view == View3D(rotX=15, rotY=20, rAngAx=False, perspective=30)
@pytest.fixture
def PivotFormat():
from ..chartspace import PivotFormat
return PivotFormat
class TestPivotFormat:
def test_ctor(self, PivotFormat):
fmt = PivotFormat()
xml = tostring(fmt.to_tree())
expected = """
<pivotFmt>
<idx val="0" />
</pivotFmt>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, PivotFormat):
src = """
<pivotFmt>
<idx val="0" />
</pivotFmt>
"""
node = fromstring(src)
fmt = PivotFormat.from_tree(node)
assert fmt == PivotFormat()
@pytest.fixture
def PivotFormatList():
from ..chartspace import PivotFormatList
return PivotFormatList
class TestPivotFormatList:
def test_ctor(self, PivotFormatList):
fmt = PivotFormatList()
xml = tostring(fmt.to_tree())
expected = """
<pivotFmts />
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, PivotFormatList):
src = """
<pivotFmts />
"""
node = fromstring(src)
fmt = PivotFormatList.from_tree(node)
assert fmt == PivotFormatList()
@pytest.fixture
def Protection():
from ..chartspace import Protection
return Protection
class TestProtection:
def test_ctor(self, Protection):
prot = Protection()
xml = tostring(prot.to_tree())
expected = """
<protection />
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, Protection):
src = """
<protection>
<chartObject val="1" />
</protection>
"""
node = fromstring(src)
prot = Protection.from_tree(node)
assert prot == Protection(chartObject=True)
@pytest.fixture
def PivotSource():
from ..chartspace import PivotSource
return PivotSource
class TestPivotSource:
def test_ctor(self, PivotSource):
src = PivotSource(name="pivot source", fmtId=1)
xml = tostring(src.to_tree())
expected = """
<pivotSource>
<name>pivot source</name>
<fmtId>1</fmtId>
</pivotSource>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, PivotSource):
src = """
<pivotSource>
<name>pivot source</name>
<fmtId>1</fmtId>
</pivotSource>
"""
node = fromstring(src)
src = PivotSource.from_tree(node)
assert src == PivotSource(name="pivot source", fmtId=1)
@pytest.fixture
def ExternalData():
from ..chartspace import ExternalData
return ExternalData
class TestExternalData:
def test_ctor(self, ExternalData):
data = ExternalData(id='rId1')
xml = tostring(data.to_tree())
expected = """
<externalData id="rId1"/>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, ExternalData):
src = """
<externalData id="rId1"/>
"""
node = fromstring(src)
data = ExternalData.from_tree(node)
assert data == ExternalData(id="rId1")
|