/usr/lib/python2.7/dist-packages/openpyxl/chart/tests/test_axis.py is in python-openpyxl 2.3.0-3.
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 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | from __future__ import absolute_import
# Copyright (c) 2010-2015 openpyxl
import pytest
from openpyxl.xml.functions import tostring, fromstring
from openpyxl.tests.helper import compare_xml
@pytest.fixture
def Scaling():
from ..axis import Scaling
return Scaling
def test_scaling(Scaling):
scale = Scaling()
xml = tostring(scale.to_tree())
expected = """
<scaling>
<orientation val="minMax"></orientation>
</scaling>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
@pytest.fixture
def _BaseAxis():
from ..axis import _BaseAxis
return _BaseAxis
class TestAxis:
def test_ctor(self, _BaseAxis, Scaling):
axis = _BaseAxis(axId=10, crossAx=100)
xml = tostring(axis.to_tree(tagname="baseAxis"))
expected = """
<baseAxis>
<axId val="10"></axId>
<scaling>
<orientation val="minMax"></orientation>
</scaling>
<axPos val="l" />
<crossAx val="100" />
</baseAxis>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
@pytest.fixture
def TextAxis():
from ..axis import TextAxis
return TextAxis
class TestTextAxis:
def test_ctor(self, TextAxis):
axis = TextAxis(axId=10, crossAx=100)
xml = tostring(axis.to_tree())
expected = """
<catAx>
<axId val="10"></axId>
<scaling>
<orientation val="minMax"></orientation>
</scaling>
<axPos val="l" />
<crossAx val="100" />
<lblOffset val="100" />
</catAx>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def from_xml(self, TextAxis):
src = """
<catAx>
<axId val="2065276984"/>
<scaling>
<orientation val="minMax"/>
</scaling>
<delete val="0"/>
<axPos val="b"/>
<majorTickMark val="out"/>
<minorTickMark val="none"/>
<tickLblPos val="nextTo"/>
<crossAx val="2056619928"/>
<crosses val="autoZero"/>
<auto val="1"/>
<lblAlgn val="ctr"/>
<lblOffset val="100"/>
<noMultiLvlLbl val="0"/>
</catAx>
"""
node = fromstring(src)
axis = CatAx.from_tree(node)
assert axis.scaling.orientation == "minMax"
assert axis.auto is True
assert axis.majorTickMark == "out"
assert axis.minorTickMark is None
@pytest.fixture
def NumericAxis():
from ..axis import NumericAxis
return NumericAxis
class TestValAx:
def test_ctor(self, NumericAxis):
axis = NumericAxis(axId=100, crossAx=10)
xml = tostring(axis.to_tree())
expected = """
<valAx>
<axId val="100"></axId>
<scaling>
<orientation val="minMax"></orientation>
</scaling>
<axPos val="l" />
<majorGridlines />
<crossAx val="10" />
</valAx>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, NumericAxis):
src = """
<valAx>
<axId val="2056619928"/>
<scaling>
<orientation val="minMax"/>
</scaling>
<delete val="0"/>
<axPos val="l"/>
<majorGridlines/>
<numFmt formatCode="General" sourceLinked="1"/>
<majorTickMark val="out"/>
<minorTickMark val="none"/>
<tickLblPos val="nextTo"/>
<crossAx val="2065276984"/>
<crosses val="autoZero"/>
<crossBetween val="between"/>
</valAx>
"""
node = fromstring(src)
axis = NumericAxis.from_tree(node)
assert axis.delete is False
assert axis.crossAx == 2065276984
assert axis.crossBetween == "between"
@pytest.fixture
def DateAxis():
from ..axis import DateAxis
return DateAxis
class TestDateAx:
def test_ctor(self, DateAxis):
axis = DateAxis(axId=500, crossAx=10)
xml = tostring(axis.to_tree())
expected = """
<dateAx>
<axId val="500"></axId>
<scaling>
<orientation val="minMax"></orientation>
</scaling>
<axPos val="l" />
<crossAx val="10" />
<majorUnit val="1" />
</dateAx>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, DateAxis):
from openpyxl.chart.data_source import NumFmt
src = """
<dateAx>
<axId val="20"/>
<scaling>
<orientation val="minMax"/>
</scaling>
<delete val="0"/>
<axPos val="b"/>
<numFmt formatCode="d-mmm" sourceLinked="1"/>
<majorTickMark val="out"/>
<minorTickMark val="none"/>
<tickLblPos val="nextTo"/>
<crossAx val="10"/>
<crosses val="autoZero"/>
<auto val="1"/>
<lblOffset val="100"/>
<baseTimeUnit val="months"/>
</dateAx>
"""
node = fromstring(src)
axis = DateAxis.from_tree(node)
assert axis == DateAxis(axId=20, crossAx=10, axPos="b",
scaling="minMax", delete=False, numFmt=NumFmt("d-mmm", True),
majorTickMark="out", crosses="autoZero", tickLblPos="nextTo",
auto=True, lblOffset=100, baseTimeUnit="months")
@pytest.fixture
def SeriesAxis():
from ..axis import SeriesAxis
return SeriesAxis
class TestSeriesAxis:
def test_ctor(self, SeriesAxis):
axis = SeriesAxis(axId=1000, crossAx=10)
xml = tostring(axis.to_tree())
expected = """
<serAx>
<axId val="1000"></axId>
<scaling>
<orientation val="minMax"></orientation>
</scaling>
<axPos val="l" />
<crossAx val="10" />
</serAx>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, SeriesAxis):
src = """
<serAx>
<axId val="1000"></axId>
<scaling>
<orientation val="minMax"></orientation>
</scaling>
<axPos val="l" />
<crossAx val="10" />
</serAx>
"""
node = fromstring(src)
axis = SeriesAxis.from_tree(node)
assert axis == SeriesAxis()
@pytest.fixture
def DisplayUnitsLabel():
from ..axis import DisplayUnitsLabel
return DisplayUnitsLabel
class TestDispUnitsLabel:
def test_ctor(self, DisplayUnitsLabel):
axis = DisplayUnitsLabel()
xml = tostring(axis.to_tree())
expected = """
<dispUnitsLbl />
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, DisplayUnitsLabel):
src = """
<dispUnitsLbl />
"""
node = fromstring(src)
axis = DisplayUnitsLabel.from_tree(node)
assert axis == DisplayUnitsLabel()
@pytest.fixture
def DisplayUnitsLabelList():
from ..axis import DisplayUnitsLabelList
return DisplayUnitsLabelList
class TestDisplayUnitList:
def test_ctor(self, DisplayUnitsLabelList):
axis = DisplayUnitsLabelList()
xml = tostring(axis.to_tree())
expected = """
<dispUnits />
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, DisplayUnitsLabelList):
src = """
<dispUnits />
"""
node = fromstring(src)
axis = DisplayUnitsLabelList.from_tree(node)
assert axis == DisplayUnitsLabelList()
@pytest.fixture
def ChartLines():
from ..axis import ChartLines
return ChartLines
class TestChartLines:
def test_ctor(self, ChartLines):
axis = ChartLines()
xml = tostring(axis.to_tree())
expected = """
<chartLines />
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, ChartLines):
src = """
<chartLines />
"""
node = fromstring(src)
axis = ChartLines.from_tree(node)
assert axis == ChartLines()
|