/usr/lib/python2.7/dist-packages/openpyxl/cell/tests/test_text.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 | from __future__ import absolute_import
# coding=utf8
# Copyright (c) 2010-2017 openpyxl
import pytest
from openpyxl.xml.functions import fromstring, tostring
from openpyxl.tests.helper import compare_xml
@pytest.fixture
def InlineFont():
from ..text import InlineFont
return InlineFont
class TestInlineFont:
def test_ctor(self, InlineFont):
font = InlineFont()
xml = tostring(font.to_tree())
expected = """
<RPrElt />
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, InlineFont):
src = """
<RPrElt />
"""
node = fromstring(src)
font = InlineFont.from_tree(node)
assert font == InlineFont()
@pytest.fixture
def RichText():
from ..text import RichText
return RichText
class TestRichText:
def test_ctor(self, RichText):
text = RichText()
xml = tostring(text.to_tree())
expected = """
<RElt />
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, RichText):
src = """
<RElt />
"""
node = fromstring(src)
text = RichText.from_tree(node)
assert text == RichText()
@pytest.fixture
def Text():
from ..text import Text
return Text
class TestText:
def test_ctor(self, Text):
text = Text()
text.plain = "comment"
xml = tostring(text.to_tree())
expected = """
<text>
<t>comment</t>
</text>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
@pytest.mark.parametrize("src, expected",
[
("""<is><t>ID</t></is>""", "ID"),
("""
<is>
<r>
<rPr />
<t xml:space="preserve">11 de September de 2014</t>
</r>
</is>
""",
"11 de September de 2014"
),
]
)
def test_from_xml(self, Text, src, expected):
node = fromstring(src)
text = Text.from_tree(node)
assert text.content == expected
def test_empty_element(self, Text):
src = """
<si>
<r>
<t>Replaced Data</t>
</r>
<r>
<rPr>
<sz val="11"/>
<color rgb="FF008080"/>
<rFont val="Calibri"/>
<family val="2"/>
<scheme val="minor"/>
</rPr>
<t/>
</r>
</si>
"""
node = fromstring(src)
text = Text.from_tree(node)
assert text.content == "Replaced Data"
@pytest.fixture
def PhoneticText():
from ..text import PhoneticText
return PhoneticText
class TestPhoneticText:
def test_ctor(self, PhoneticText):
text = PhoneticText(sb=9, eb=10, t=u'\u3088')
xml = tostring(text.to_tree())
expected = b"""
<rPh sb="9" eb="10">
<t>よ</t>
</rPh>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, PhoneticText):
src = b"""
<rPh sb="9" eb="10">
<t>よ</t>
</rPh>
"""
node = fromstring(src)
text = PhoneticText.from_tree(node)
assert text == PhoneticText(sb=9, eb=10, t=u'\u3088')
@pytest.fixture
def PhoneticProperties():
from ..text import PhoneticProperties
return PhoneticProperties
class TestPhoneticProperties:
def test_ctor(self, PhoneticProperties):
props = PhoneticProperties(fontId=0, type="Hiragana")
xml = tostring(props.to_tree())
expected = """
<phoneticPr fontId="0" type="Hiragana"></phoneticPr>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, PhoneticProperties):
src = """
<phoneticPr fontId="0" type="noConversion"/>
"""
node = fromstring(src)
props = PhoneticProperties.from_tree(node)
assert props == PhoneticProperties(fontId=0, type="noConversion")
|