Commit 359c1952 authored by CharlieC's avatar CharlieC
Browse files

Merge with 3.0

--HG--
branch : 3.1
Pipeline #25015 failed with stage
in 3 minutes and 37 seconds
......@@ -22,9 +22,11 @@ The following properties have been removed from worksheets: formula_attributes,
Bugfixes
--------
* `#1284 <https://foss.heptapod.net/openpyxl/openpyxl/-/issues/1284>`_ Ignore blank ignored in existing Data Validations
* `#1645 <https://foss.heptapod.net/openpyxl/openpyxl/-/issues/1645>`_ Timezone-aware datetimes raise an Exception
* `#1666 <https://foss.heptapod.net/openpyxl/openpyxl/-/issues/1666>`_ Improved normalisation of chart series
* `#1670 <https://foss.heptapod.net/openpyxl/openpyxl/-/issues/1670>`_ Catch OverflowError for out of range datetiimes
* `#1670 <https://foss.heptapod.net/openpyxl/openpyxl/-/issues/1670>`_ Catch OverflowError for out of range datetimes
* `#1708 <https://foss.heptapod.net/openpyxl/openpyxl/-/issues/1708>`_ Alignment.relativeIndent can be negative
3.0.7 (2021-03-09)
......
......@@ -37,8 +37,8 @@ class Alignment(Serialisable):
wrap_text = Alias('wrapText')
shrinkToFit = Bool(allow_none=True)
shrink_to_fit = Alias('shrinkToFit')
indent = Min(min=0)
relativeIndent = Min(min=0)
indent = MinMax(min=0, max=255)
relativeIndent = MinMax(min=-255, max=255)
justifyLastLine = Bool(allow_none=True)
readingOrder = Min(min=0)
......
# Copyright (c) 2010-2021 openpyxl
from openpyxl.descriptors import (
Integer,
String,
Typed,
Sequence,
Alias,
......@@ -11,8 +9,6 @@ from openpyxl.descriptors.serialisable import Serialisable
from openpyxl.styles import (
Font,
Fill,
GradientFill,
PatternFill,
Border,
Alignment,
Protection,
......@@ -53,16 +49,17 @@ class DifferentialStyle(Serialisable):
class DifferentialStyleList(Serialisable):
"""
Deduping container for differential styles.
Dedupable container for differential styles.
"""
tagname = "dxfs"
dxf = Sequence(expected_type=DifferentialStyle)
styles = Alias("dxf")
__attrs__ = ("count",)
def __init__(self, dxf=()):
def __init__(self, dxf=(), count=None):
self.dxf = dxf
......@@ -89,6 +86,10 @@ class DifferentialStyleList(Serialisable):
return bool(self.styles)
def __getitem__(self, idx):
return self.styles[idx]
@property
def count(self):
return len(self.dxf)
......@@ -63,3 +63,49 @@ def test_serialise(DifferentialStyle):
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
@pytest.fixture
def DifferentialStyleList():
from ..differential import DifferentialStyleList
return DifferentialStyleList
class TestDifferentialStyleList:
def test_ctor(self, DifferentialStyleList, DifferentialStyle):
cond = DifferentialStyle()
cond.font = Font(name="Calibri", family=2, sz=11)
differential = DifferentialStyleList(dxf=[cond])
xml = tostring(differential.to_tree())
expected = """
<dxfs count="1">
<dxf>
<font>
<name val="Calibri"></name>
<family val="2"></family>
<sz val="11"></sz>
</font>
</dxf>
</dxfs>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_from_xml(self, DifferentialStyleList):
src = """
<dxfs count="1">
<dxf>
<font>
<name val="Calibri"></name>
<family val="2"></family>
<sz val="11"></sz>
</font>
</dxf>
</dxfs>
"""
node = fromstring(src)
differential = DifferentialStyleList.from_tree(node)
assert differential.dxf[0].font == Font(name="Calibri", family=2, sz=11)
......@@ -108,7 +108,6 @@ class DataValidation(Serialisable):
type=None,
formula1=None,
formula2=None,
allow_blank=False,
showErrorMessage=True,
showInputMessage=True,
showDropDown=None,
......@@ -121,6 +120,7 @@ class DataValidation(Serialisable):
errorTitle=None,
imeMode=None,
operator=None,
allow_blank=None,
):
self.sqref = sqref
self.showDropDown = showDropDown
......
......@@ -15,11 +15,12 @@ def DataValidation():
class TestDataValidation:
def test_ctor(self, DataValidation):
dv = DataValidation()
dv = DataValidation(allowBlank=True)
xml = tostring(dv.to_tree())
expected = """
<dataValidation allowBlank="0" showErrorMessage="1" showInputMessage="1" sqref="" />
<dataValidation allowBlank="1" showErrorMessage="1" showInputMessage="1" sqref="" />
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
......@@ -33,14 +34,15 @@ class TestDataValidation:
dv = DataValidation.from_tree(node)
assert dv == DataValidation()
def test_list_validation(DataValidation):
dv = DataValidation(type="list", formula1='"Dog,Cat,Fish"')
assert dv.formula1, '"Dog,Cat == Fish"'
dv_dict = dict(dv)
assert dv_dict['type'] == 'list'
assert dv_dict['allowBlank'] == '0'
assert dv_dict['showErrorMessage'] == '1'
assert dv_dict['showInputMessage'] == '1'
def test_list_validation(self, DataValidation):
dv = DataValidation(type="list", formula1='"Dog,Cat,Fish"')
assert dv.formula1, '"Dog,Cat == Fish"'
dv_dict = dict(dv)
assert dv_dict['type'] == 'list'
assert dv_dict['allowBlank'] == '0'
assert dv_dict['showErrorMessage'] == '1'
assert dv_dict['showInputMessage'] == '1'
def test_hide_drop_down(self, DataValidation):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment