# Copyright (c) 2010-2017 openpyxl
import pytest
import re
from openpyxl.xml.functions import fromstring, tostring
from openpyxl.tests.helper import compare_xml
[docs]def test_split_into_parts():
from .. header_footer import _split_string
headers = _split_string("&Ltest header")
assert headers['left'] == "test header"
headers = _split_string("""&L&"Lucida Grande,Standard"&K000000Left top&C&"Lucida Grande,Standard"&K000000Middle top&R&"Lucida Grande,Standard"&K000000Right top""")
assert headers['left'] == '&"Lucida Grande,Standard"&K000000Left top'
assert headers['center'] == '&"Lucida Grande,Standard"&K000000Middle top'
assert headers['right'] == '&"Lucida Grande,Standard"&K000000Right top'
[docs]def test_cannot_split():
from ..header_footer import _split_string
s = """\n """
parts = _split_string(s)
assert parts == {'left':'', 'right':'', 'center':''}
[docs]def test_multiline_string():
from .. header_footer import _split_string
s = """&L141023 V1&CRoute - Malls\nSchedules R1201 v R1301&RClient-internal use only"""
headers = _split_string(s)
assert headers == {
'center': 'Route - Malls\nSchedules R1201 v R1301',
'left': '141023 V1',
'right': 'Client-internal use only'
}
@pytest.mark.parametrize("value, expected",
[
("&9", [('', '', '9')]),
('&"Lucida Grande,Standard"', [("Lucida Grande,Standard", '', '')]),
('&K000000', [('', '000000', '')])
]
)
@pytest.fixture
def _HeaderFooterPart():
from ..header_footer import _HeaderFooterPart
return _HeaderFooterPart
@pytest.fixture
@pytest.fixture