/usr/lib/python2.7/dist-packages/openpyxl/descriptors/tests/test_excel.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 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 | from __future__ import absolute_import
# Copyright (c) 2010-2015 openpyxl
import pytest
from .. import Strict
@pytest.fixture
def UniversalMeasure():
from ..excel import UniversalMeasure
class Dummy(Strict):
value = UniversalMeasure()
return Dummy()
class TestUniversalMeasure:
@pytest.mark.parametrize("value",
["24.73mm", "0cm", "24pt", '999pc', "50pi"]
)
def test_valid(self, UniversalMeasure, value):
UniversalMeasure.value = value
assert UniversalMeasure.value == value
@pytest.mark.parametrize("value",
[24.73, '24.73zz', "24.73 mm", None, "-24.73cm"]
)
def test_invalid(self, UniversalMeasure, value):
with pytest.raises(ValueError):
UniversalMeasure.value = "{0}".format(value)
@pytest.fixture
def HexBinary():
from ..excel import HexBinary
class Dummy(Strict):
value = HexBinary()
return Dummy()
class TestHexBinary:
@pytest.mark.parametrize("value",
["aa35efd", "AABBCCDD"]
)
def test_valid(self, HexBinary, value):
HexBinary.value = value
assert HexBinary.value == value
@pytest.mark.parametrize("value",
["GGII", "35.5"]
)
def test_invalid(self, HexBinary, value):
with pytest.raises(ValueError):
HexBinary.value = value
@pytest.fixture
def TextPoint():
from ..excel import TextPoint
class Dummy(Strict):
value = TextPoint()
return Dummy()
class TestTextPoint:
@pytest.mark.parametrize("value",
[-400000, "400000", 0]
)
def test_valid(self, TextPoint, value):
TextPoint.value = value
assert TextPoint.value == int(value)
def test_invalid_value(self, TextPoint):
with pytest.raises(ValueError):
TextPoint.value = -400001
def test_invalid_type(self, TextPoint):
with pytest.raises(TypeError):
TextPoint.value = "40pt"
@pytest.fixture
def Percentage():
from ..excel import Percentage
class Dummy(Strict):
value = Percentage()
return Dummy()
class TestPercentage:
@pytest.mark.parametrize("value",
["15%", "15.5%"]
)
def test_valid(self, Percentage, value):
Percentage.value = value
assert Percentage.value == value
@pytest.mark.parametrize("value",
["15", "101%", "-1%"]
)
def test_valid(self, Percentage, value):
with pytest.raises(ValueError):
Percentage.value = value
@pytest.fixture
def Guid():
from ..excel import Guid
class Dummy(Strict):
value = Guid()
return Dummy()
class TestGuid():
@pytest.mark.parametrize("value",
["{00000000-5BD2-4BC8-9F70-7020E1357FB2}"]
)
def test_valid(self, Guid, value):
Guid.value = value
assert Guid.value == value
@pytest.mark.parametrize("value",
["{00000000-5BD2-4BC8-9F70-7020E1357FB2"]
)
def test_valid(self, Guid, value):
with pytest.raises(ValueError):
Guid.value = value
@pytest.fixture
def Base64Binary():
from ..excel import Base64Binary
class Dummy(Strict):
value = Base64Binary()
return Dummy()
class TestBase64Binary():
@pytest.mark.parametrize("value",
["9oN7nWkCAyEZib1RomSJTjmPpCY="]
)
def test_valid(self, Base64Binary, value):
Base64Binary.value = value
assert Base64Binary.value == value
@pytest.mark.parametrize("value",
["==0F"]
)
def test_valid(self, Base64Binary, value):
with pytest.raises(ValueError):
Base64Binary.value = value
|