/usr/lib/python2.7/dist-packages/openpyxl/drawing/tests/test_color.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 | from __future__ import absolute_import
# Copyright (c) 2010-2015 openpyxl
import pytest
from openpyxl.xml.functions import fromstring, tostring
from openpyxl.tests.helper import compare_xml
@pytest.fixture
def ColorChoice():
from ..colors import ColorChoice
return ColorChoice
class TestColorChoice:
def test_ctor(self, ColorChoice):
color = ColorChoice()
color.RGB = "000000"
xml = tostring(color.to_tree())
expected = """
<colorChoice xmlns="http://schemas.openxmlformats.org/drawingml/2006/main">
<srgbClr val="000000" />
</colorChoice>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, ColorChoice):
src = """
<colorChoice />
"""
node = fromstring(src)
color = ColorChoice.from_tree(node)
assert color == ColorChoice()
@pytest.fixture
def SystemColor():
from ..colors import SystemColor
return SystemColor
class TestSystemColor:
def test_ctor(self, SystemColor):
colors = SystemColor()
xml = tostring(colors.to_tree())
expected = """
<sysClr val="bg1"></sysClr>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, SystemColor):
src = """
<sysClr val="tx1"></sysClr>
"""
node = fromstring(src)
colors = SystemColor.from_tree(node)
assert colors == SystemColor(val="tx1")
@pytest.fixture
def HSLColor():
from ..colors import HSLColor
return HSLColor
class TestHSLColor:
def test_ctor(self, HSLColor):
colors = HSLColor(hue=50, sat=10, lum=90)
xml = tostring(colors.to_tree())
expected = """
<hslClr hue="50" lum="90" sat="10" />
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, HSLColor):
src = """
<hslClr hue="0" lum="70" sat="20" />
"""
node = fromstring(src)
colors = HSLColor.from_tree(node)
assert colors == HSLColor(hue=0, sat=20, lum=70)
@pytest.fixture
def RGBPercent():
from ..colors import RGBPercent
return RGBPercent
class TestRGBPercent:
def test_ctor(self, RGBPercent):
colors = RGBPercent(r=30, g=40, b=20)
xml = tostring(colors.to_tree())
expected = """
<rgbClr b="20" g="40" r="30" />
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, RGBPercent):
src = """
<rgbClr b="20" g="40" r="30" />
"""
node = fromstring(src)
colors = RGBPercent.from_tree(node)
assert colors == RGBPercent(r=30, g=40, b=20)
@pytest.fixture
def ColorMapping():
from ..colors import ColorMapping
return ColorMapping
class TestColorMapping:
def test_ctor(self, ColorMapping):
colors = ColorMapping()
xml = tostring(colors.to_tree())
expected = """
<clrMapOvr accent1="accent1" accent2="accent2"
accent3="accent3" accent4="accent4" accent5="accent5"
accent6="accent6" bg1="lt1" bg2="lt2" folHlink="folHlink"
hlink="hlink" tx1="dk1" tx2="dk2"
/>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, ColorMapping):
src = """
<clrMapOvr accent1="accent1" accent2="accent2"
accent3="accent3" accent4="accent4" accent5="accent5"
accent6="accent6" bg1="lt1" bg2="lt2" folHlink="folHlink"
hlink="hlink" tx1="dk1" tx2="dk2"
/>
"""
node = fromstring(src)
colors = ColorMapping.from_tree(node)
assert colors == ColorMapping()
|