/usr/lib/python2.7/dist-packages/openpyxl/chart/tests/test_data_source.py is in python-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 | 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 NumRef():
from ..data_source import NumRef
return NumRef
class TestNumRef:
def test_from_xml(self, NumRef):
src = """
<numRef>
<f>Blatt1!$A$1:$A$12</f>
</numRef>
"""
node = fromstring(src)
num = NumRef.from_tree(node)
assert num.ref == "Blatt1!$A$1:$A$12"
def test_to_xml(self, NumRef):
num = NumRef(f="Blatt1!$A$1:$A$12")
xml = tostring(num.to_tree("numRef"))
expected = """
<numRef>
<f>Blatt1!$A$1:$A$12</f>
</numRef>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
@pytest.fixture
def StrRef():
from ..data_source import StrRef
return StrRef
class TestStrRef:
def test_ctor(self, StrRef):
data_source = StrRef(f="Sheet1!A1")
xml = tostring(data_source.to_tree())
expected = """
<strRef>
<f>Sheet1!A1</f>
</strRef>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, StrRef):
src = """
<strRef>
<f>'Render Start'!$A$2</f>
</strRef>
"""
node = fromstring(src)
data_source = StrRef.from_tree(node)
assert data_source == StrRef(f="'Render Start'!$A$2")
@pytest.fixture
def StrVal():
from ..data_source import StrVal
return StrVal
class TestStrVal:
def test_ctor(self, StrVal):
val = StrVal(v="something")
xml = tostring(val.to_tree())
expected = """
<strVal idx="0">
<v val="something"></v>
</strVal>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, StrVal):
src = """
<strVal idx="4">
<v val="else"></v>
</strVal>
"""
node = fromstring(src)
val = StrVal.from_tree(node)
assert val == StrVal(idx=4, v="else")
@pytest.fixture
def StrData():
from ..data_source import StrData
return StrData
class TestStrData:
def test_ctor(self, StrData):
data_source = StrData(ptCount=1)
xml = tostring(data_source.to_tree())
expected = """
<strData>
<ptCount val="1"></ptCount>
</strData>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, StrData):
src = """
<strData>
<ptCount val="4"></ptCount>
</strData>
"""
node = fromstring(src)
data_source = StrData.from_tree(node)
assert data_source == StrData(ptCount=4)
|