/usr/lib/python2.7/dist-packages/openpyxl/chart/tests/test_series_factory.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 | from __future__ import absolute_import
# Copyright (c) 2010-2017 openpyxl
import pytest
from openpyxl.xml.functions import tostring, fromstring
from openpyxl.tests.helper import compare_xml
@pytest.fixture
def Series():
from ..series_factory import SeriesFactory
return SeriesFactory
class TestSeriesFactory:
def test_ctor(self, Series):
series = Series(values="Sheet1!$A$1:$A$10")
series.__elements__ = ('idx', 'order', 'val')
xml = tostring(series.to_tree())
expected = """
<ser>
<idx val="0"></idx>
<order val="0"></order>
<val>
<numRef>
<f>Sheet1!$A$1:$A$10</f>
</numRef>
</val>
</ser>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_manual_idx(self, Series):
series = Series(values="Sheet1!$A$1:$A$10")
series.__elements__ = ('idx', 'order', 'val')
xml = tostring(series.to_tree(idx=5))
expected = """
<ser>
<idx val="5"></idx>
<order val="5"></order>
<val>
<numRef>
<f>Sheet1!$A$1:$A$10</f>
</numRef>
</val>
</ser>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_manual_order(self, Series):
series = Series(values="Sheet1!$A$1:$A$10")
series.order = 2
series.__elements__ = ('idx', 'order', 'val')
xml = tostring(series.to_tree(idx=5))
expected = """
<ser>
<idx val="5"></idx>
<order val="2"></order>
<val>
<numRef>
<f>Sheet1!$A$1:$A$10</f>
</numRef>
</val>
</ser>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_title(self, Series):
series = Series("Sheet1!A1:A10", title="First Series")
series.__elements__ = ('idx', 'order', 'tx')
xml = tostring(series.to_tree(idx=0))
expected = """
<ser>
<idx val="0"></idx>
<order val="0"></order>
<tx>
<v>First Series</v>
</tx>
</ser>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_title_from_data(self, Series):
series = Series("Sheet1!A1:A10", title_from_data=True)
series.__elements__ = ('tx', 'val')
xml = tostring(series.to_tree(idx=0))
expected = """
<ser>
<tx>
<strRef>
<f>Sheet1!A1</f>
</strRef>
</tx>
<val>
<numRef>
<f>Sheet1!$A$2:$A$10</f>
</numRef>
</val>
</ser>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_xy(self, Series):
from ..series import XYSeries
series = Series("Sheet!A1:A10", xvalues="Sheet!B1:B10")
assert isinstance(series, XYSeries)
def test_zvalues(self, Series):
series = Series("Sheet!A2:A5", xvalues="Sheet!B2:B5", zvalues="Sheet!C2:C5")
series.__elements__ = ('xVal', 'yVal', 'bubbleSize')
xml = tostring(series.to_tree())
expected = """
<ser>
<xVal>
<numRef>
<f>Sheet!$B$2:$B$5</f>
</numRef>
</xVal>
<yVal>
<numRef>
<f>Sheet!$A$2:$A$5</f>
</numRef>
</yVal>
<bubbleSize>
<numRef>
<f>Sheet!$C$2:$C$5</f>
</numRef>
</bubbleSize>
</ser>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
|