/usr/lib/python2.7/dist-packages/openpyxl/writer/tests/test_worksheet.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 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 | from __future__ import absolute_import
# Copyright (c) 2010-2015 openpyxl
import datetime
import decimal
from io import BytesIO
import pytest
from openpyxl.xml.functions import fromstring, tostring, xmlfile
from openpyxl.reader.excel import load_workbook
from openpyxl import Workbook
from .. worksheet import write_worksheet
from .. relations import write_rels
from openpyxl.tests.helper import compare_xml
from openpyxl.worksheet.properties import PageSetupProperties
from openpyxl.xml.constants import SHEET_MAIN_NS, REL_NS
@pytest.fixture
def worksheet():
from openpyxl import Workbook
wb = Workbook()
return wb.active
@pytest.fixture
def DummyWorksheet():
class DummyWorksheet:
def __init__(self):
self._styles = {}
self.column_dimensions = {}
self.parent = Workbook()
return DummyWorksheet()
@pytest.fixture
def write_cols():
from .. worksheet import write_cols
return write_cols
@pytest.fixture
def ColumnDimension():
from openpyxl.worksheet.dimensions import ColumnDimension
return ColumnDimension
def test_no_cols(write_cols, DummyWorksheet):
cols = write_cols(DummyWorksheet)
assert cols is None
def test_col_widths(write_cols, ColumnDimension, DummyWorksheet):
ws = DummyWorksheet
ws.column_dimensions['A'] = ColumnDimension(worksheet=ws, width=4)
cols = write_cols(ws)
xml = tostring(cols)
expected = """<cols><col width="4" min="1" max="1" customWidth="1"></col></cols>"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_col_style(write_cols, ColumnDimension, DummyWorksheet):
from openpyxl.styles import Font
ws = DummyWorksheet
cd = ColumnDimension(worksheet=ws)
ws.column_dimensions['A'] = cd
cd.font = Font(color="FF0000")
cols = write_cols(ws)
xml = tostring(cols)
expected = """<cols><col max="1" min="1" style="1"></col></cols>"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_lots_cols(write_cols, ColumnDimension, DummyWorksheet):
from openpyxl.styles import Font
ws = DummyWorksheet
from openpyxl.cell import get_column_letter
for i in range(1, 15):
label = get_column_letter(i)
cd = ColumnDimension(worksheet=ws)
cd.font = Font(name=label)
dict(cd) # create style_id in order for test
ws.column_dimensions[label] = cd
cols = write_cols(ws)
xml = tostring(cols)
expected = """<cols>
<col max="1" min="1" style="1"></col>
<col max="2" min="2" style="2"></col>
<col max="3" min="3" style="3"></col>
<col max="4" min="4" style="4"></col>
<col max="5" min="5" style="5"></col>
<col max="6" min="6" style="6"></col>
<col max="7" min="7" style="7"></col>
<col max="8" min="8" style="8"></col>
<col max="9" min="9" style="9"></col>
<col max="10" min="10" style="10"></col>
<col max="11" min="11" style="11"></col>
<col max="12" min="12" style="12"></col>
<col max="13" min="13" style="13"></col>
<col max="14" min="14" style="14"></col>
</cols>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
@pytest.fixture
def write_format():
from .. worksheet import write_format
return write_format
def test_sheet_format(write_format, ColumnDimension, DummyWorksheet):
fmt = write_format(DummyWorksheet)
xml = tostring(fmt)
expected = """<sheetFormatPr defaultRowHeight="15" baseColWidth="10"/>"""
diff = compare_xml(expected, xml)
assert diff is None, diff
def test_outline_format(write_format, ColumnDimension, DummyWorksheet):
worksheet = DummyWorksheet
worksheet.column_dimensions['A'] = ColumnDimension(worksheet=worksheet,
outline_level=1)
fmt = write_format(worksheet)
xml = tostring(fmt)
expected = """<sheetFormatPr defaultRowHeight="15" baseColWidth="10" outlineLevelCol="1" />"""
diff = compare_xml(expected, xml)
assert diff is None, diff
def test_outline_cols(write_cols, ColumnDimension, DummyWorksheet):
worksheet = DummyWorksheet
worksheet.column_dimensions['A'] = ColumnDimension(worksheet=worksheet,
outline_level=1)
cols = write_cols(worksheet)
xml = tostring(cols)
expected = """<cols><col max="1" min="1" outlineLevel="1"/></cols>"""
diff = compare_xml(expected, xml)
assert diff is None, diff
@pytest.fixture
def write_rows():
from .. etree_worksheet import write_rows
return write_rows
@pytest.mark.parametrize("value, expected",
[
(9781231231230, """<c t="n" r="A1"><v>9781231231230</v></c>"""),
(decimal.Decimal('3.14'), """<c t="n" r="A1"><v>3.14</v></c>"""),
(1234567890, """<c t="n" r="A1"><v>1234567890</v></c>"""),
("=sum(1+1)", """<c r="A1"><f>sum(1+1)</f><v></v></c>"""),
(True, """<c t="b" r="A1"><v>1</v></c>"""),
("Hello", """<c t="s" r="A1"><v>0</v></c>"""),
("", """<c r="A1" t="s"></c>"""),
(None, """<c r="A1" t="n"></c>"""),
(datetime.date(2011, 12, 25), """<c r="A1" t="n" s="1"><v>40902</v></c>"""),
])
def test_write_cell(worksheet, value, expected):
from openpyxl.cell import Cell
from .. etree_worksheet import write_cell
ws = worksheet
cell = ws['A1']
cell.value = value
el = write_cell(ws, cell, cell.has_style)
xml = tostring(el)
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_write_formula(worksheet, write_rows):
ws = worksheet
ws['F1'] = 10
ws['F2'] = 32
ws['F3'] = '=F1+F2'
ws['A4'] = '=A1+A2+A3'
ws['B4'] = "=SUM(A10:A14*B10:B14)"
ws.formula_attributes['B4'] = {'t': 'array', 'ref': 'B4:B8'}
out = BytesIO()
with xmlfile(out) as xf:
write_rows(xf, ws)
xml = out.getvalue()
expected = """
<sheetData>
<row r="1" spans="1:6">
<c r="F1" t="n">
<v>10</v>
</c>
</row>
<row r="2" spans="1:6">
<c r="F2" t="n">
<v>32</v>
</c>
</row>
<row r="3" spans="1:6">
<c r="F3">
<f>F1+F2</f>
<v></v>
</c>
</row>
<row r="4" spans="1:6">
<c r="A4">
<f>A1+A2+A3</f>
<v></v>
</c>
<c r="B4">
<f ref="B4:B8" t="array">SUM(A10:A14*B10:B14)</f>
<v></v>
</c>
</row>
</sheetData>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_write_height(worksheet, write_rows):
from openpyxl.worksheet.dimensions import RowDimension
ws = worksheet
ws['F1'] = 10
ws.row_dimensions[1] = RowDimension(ws, height=30)
ws.row_dimensions[2] = RowDimension(ws, height=30)
out = BytesIO()
with xmlfile(out) as xf:
write_rows(xf, ws)
xml = out.getvalue()
expected = """
<sheetData>
<row customHeight="1" ht="30" r="1" spans="1:6">
<c r="F1" t="n">
<v>10</v>
</c>
</row>
<row customHeight="1" ht="30" r="2" spans="1:6"></row>
</sheetData>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_get_rows_to_write(worksheet):
from .. etree_worksheet import get_rows_to_write
ws = worksheet
ws['A10'] = "test"
ws.row_dimensions[10] = None
ws.row_dimensions[2] = None
cells_by_row = get_rows_to_write(ws)
assert cells_by_row == [
(2, []),
(10, [(1, ws['A10'])])
]
@pytest.fixture
def write_autofilter():
from .. worksheet import write_autofilter
return write_autofilter
def test_auto_filter(worksheet, write_autofilter):
ws = worksheet
ws.auto_filter.ref = 'A1:F1'
af = write_autofilter(ws)
xml = tostring(af)
expected = """<autoFilter ref="A1:F1"></autoFilter>"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_auto_filter_filter_column(worksheet, write_autofilter):
ws = worksheet
ws.auto_filter.ref = 'A1:F1'
ws.auto_filter.add_filter_column(0, ["0"], blank=True)
af = write_autofilter(ws)
xml = tostring(af)
expected = """
<autoFilter ref="A1:F1">
<filterColumn colId="0">
<filters blank="1">
<filter val="0"></filter>
</filters>
</filterColumn>
</autoFilter>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_auto_filter_sort_condition(worksheet, write_autofilter):
ws = worksheet
ws.cell('A1').value = 'header'
ws.cell('A2').value = 1
ws.cell('A3').value = 0
ws.auto_filter.ref = 'A2:A3'
ws.auto_filter.add_sort_condition('A2:A3', descending=True)
af = write_autofilter(ws)
xml = tostring(af)
expected = """
<autoFilter ref="A2:A3">
<sortState ref="A2:A3">
<sortCondtion descending="1" ref="A2:A3"></sortCondtion>
</sortState>
</autoFilter>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_auto_filter_worksheet(worksheet, write_worksheet):
worksheet.auto_filter.ref = 'A1:F1'
xml = write_worksheet(worksheet, None)
expected = """
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<sheetPr>
<outlinePr summaryBelow="1" summaryRight="1"/>
<pageSetUpPr/>
</sheetPr>
<dimension ref="A1:A1"/>
<sheetViews>
<sheetView workbookViewId="0">
<selection activeCell="A1" sqref="A1"/>
</sheetView>
</sheetViews>
<sheetFormatPr baseColWidth="10" defaultRowHeight="15"/>
<sheetData/>
<autoFilter ref="A1:F1"/>
<pageMargins bottom="1" footer="0.5" header="0.5" left="0.75" right="0.75" top="1"/>
</worksheet>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_merge(worksheet):
from .. worksheet import write_mergecells
ws = worksheet
ws.cell('A1').value = 'Cell A1'
ws.cell('B1').value = 'Cell B1'
ws.merge_cells('A1:B1')
merge = write_mergecells(ws)
xml = tostring(merge)
expected = """
<mergeCells count="1">
<mergeCell ref="A1:B1"/>
</mergeCells>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_no_merge(worksheet):
from .. worksheet import write_mergecells
merge = write_mergecells(worksheet)
assert merge is None
def test_header_footer(worksheet):
ws = worksheet
ws.header_footer.left_header.text = "Left Header Text"
ws.header_footer.center_header.text = "Center Header Text"
ws.header_footer.center_header.font_name = "Arial,Regular"
ws.header_footer.center_header.font_size = 6
ws.header_footer.center_header.font_color = "445566"
ws.header_footer.right_header.text = "Right Header Text"
ws.header_footer.right_header.font_name = "Arial,Bold"
ws.header_footer.right_header.font_size = 8
ws.header_footer.right_header.font_color = "112233"
ws.header_footer.left_footer.text = "Left Footer Text\nAnd &[Date] and &[Time]"
ws.header_footer.left_footer.font_name = "Times New Roman,Regular"
ws.header_footer.left_footer.font_size = 10
ws.header_footer.left_footer.font_color = "445566"
ws.header_footer.center_footer.text = "Center Footer Text &[Path]&[File] on &[Tab]"
ws.header_footer.center_footer.font_name = "Times New Roman,Bold"
ws.header_footer.center_footer.font_size = 12
ws.header_footer.center_footer.font_color = "778899"
ws.header_footer.right_footer.text = "Right Footer Text &[Page] of &[Pages]"
ws.header_footer.right_footer.font_name = "Times New Roman,Italic"
ws.header_footer.right_footer.font_size = 14
ws.header_footer.right_footer.font_color = "AABBCC"
from .. worksheet import write_header_footer
hf = write_header_footer(ws)
xml = tostring(hf)
expected = """
<headerFooter>
<oddHeader>&L&"Calibri,Regular"&K000000Left Header Text&C&"Arial,Regular"&6&K445566Center Header Text&R&"Arial,Bold"&8&K112233Right Header Text</oddHeader>
<oddFooter>&L&"Times New Roman,Regular"&10&K445566Left Footer Text_x000D_And &D and &T&C&"Times New Roman,Bold"&12&K778899Center Footer Text &Z&F on &A&R&"Times New Roman,Italic"&14&KAABBCCRight Footer Text &P of &N</oddFooter>
</headerFooter>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_no_header(worksheet):
from .. worksheet import write_header_footer
hf = write_header_footer(worksheet)
assert hf is None
def test_hyperlink(worksheet):
from .. worksheet import write_hyperlinks
ws = worksheet
ws.cell('A1').value = "test"
ws.cell('A1').hyperlink = "http://test.com"
hyper = write_hyperlinks(ws)
assert len(worksheet._rels) == 1
assert worksheet._rels[0].target == "http://test.com"
xml = tostring(hyper)
expected = """
<hyperlinks xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<hyperlink r:id="rId1" ref="A1"/>
</hyperlinks>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_no_hyperlink(worksheet):
from .. worksheet import write_hyperlinks
l = write_hyperlinks(worksheet)
assert l is None
@pytest.mark.xfail
@pytest.mark.pil_required
def test_write_hyperlink_image_rels(Workbook, Image, datadir):
datadir.chdir()
wb = Workbook()
ws = wb.create_sheet()
ws.cell('A1').value = "test"
ws.cell('A1').hyperlink = "http://test.com/"
i = Image("plain.png")
ws.add_image(i)
raise ValueError("Resulting file is invalid")
# TODO write integration test with duplicate relation ids then fix
@pytest.fixture
def worksheet_with_cf(worksheet):
from openpyxl.formatting import ConditionalFormatting
worksheet.conditional_formating = ConditionalFormatting()
return worksheet
@pytest.fixture
def write_conditional_formatting():
from .. worksheet import write_conditional_formatting
return write_conditional_formatting
def test_conditional_formatting_customRule(worksheet_with_cf, write_conditional_formatting):
ws = worksheet_with_cf
from openpyxl.formatting.rule import Rule
ws.conditional_formatting.add('C1:C10',
Rule(**{'type': 'expression',
'formula': ['ISBLANK(C1)'], 'stopIfTrue': '1'}
)
)
cfs = write_conditional_formatting(ws)
xml = b""
for cf in cfs:
xml += tostring(cf)
diff = compare_xml(xml, """
<conditionalFormatting sqref="C1:C10">
<cfRule type="expression" stopIfTrue="1" priority="1">
<formula>ISBLANK(C1)</formula>
</cfRule>
</conditionalFormatting>
""")
assert diff is None, diff
def test_conditional_font(worksheet_with_cf, write_conditional_formatting):
"""Test to verify font style written correctly."""
# Create cf rule
from openpyxl.styles import PatternFill, Font, Color
from openpyxl.formatting.rule import CellIsRule
redFill = PatternFill(start_color=Color('FFEE1111'),
end_color=Color('FFEE1111'),
patternType='solid')
whiteFont = Font(color=Color("FFFFFFFF"))
ws = worksheet_with_cf
ws.conditional_formatting.add('A1:A3',
CellIsRule(operator='equal',
formula=['"Fail"'],
stopIfTrue=False,
font=whiteFont,
fill=redFill))
cfs = write_conditional_formatting(ws)
xml = b""
for cf in cfs:
xml += tostring(cf)
diff = compare_xml(xml, """
<conditionalFormatting sqref="A1:A3">
<cfRule operator="equal" priority="1" type="cellIs" dxfId="0" stopIfTrue="0">
<formula>"Fail"</formula>
</cfRule>
</conditionalFormatting>
""")
assert diff is None, diff
def test_formula_rule(worksheet_with_cf, write_conditional_formatting):
from openpyxl.formatting.rule import FormulaRule
ws = worksheet_with_cf
ws.conditional_formatting.add('C1:C10',
FormulaRule(
formula=['ISBLANK(C1)'],
stopIfTrue=True)
)
cfs = write_conditional_formatting(ws)
xml = b""
for cf in cfs:
xml += tostring(cf)
diff = compare_xml(xml, """
<conditionalFormatting sqref="C1:C10">
<cfRule type="expression" stopIfTrue="1" priority="1">
<formula>ISBLANK(C1)</formula>
</cfRule>
</conditionalFormatting>
""")
assert diff is None, diff
@pytest.fixture
def write_worksheet():
from .. worksheet import write_worksheet
return write_worksheet
def test_write_empty(worksheet, write_worksheet):
ws = worksheet
xml = write_worksheet(ws, None)
expected = """
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<sheetPr>
<outlinePr summaryRight="1" summaryBelow="1"/>
<pageSetUpPr/>
</sheetPr>
<dimension ref="A1:A1"/>
<sheetViews>
<sheetView workbookViewId="0">
<selection sqref="A1" activeCell="A1"/>
</sheetView>
</sheetViews>
<sheetFormatPr baseColWidth="10" defaultRowHeight="15"/>
<sheetData/>
<pageMargins left="0.75" right="0.75" top="1" bottom="1" header="0.5" footer="0.5"/>
</worksheet>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_vba(worksheet, write_worksheet):
ws = worksheet
ws.vba_code = {"codeName":"Sheet1"}
ws.vba_controls = "rId2"
xml = write_worksheet(ws, None)
expected = """
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<sheetPr codeName="Sheet1">
<outlinePr summaryBelow="1" summaryRight="1"/>
<pageSetUpPr/>
</sheetPr>
<dimension ref="A1:A1"/>
<sheetViews>
<sheetView workbookViewId="0">
<selection activeCell="A1" sqref="A1"/>
</sheetView>
</sheetViews>
<sheetFormatPr baseColWidth="10" defaultRowHeight="15"/>
<sheetData/>
<pageMargins bottom="1" footer="0.5" header="0.5" left="0.75" right="0.75" top="1"/>
<legacyDrawing r:id="rId2"/>
</worksheet>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_vba_comments(datadir, write_worksheet):
datadir.chdir()
fname = 'vba+comments.xlsm'
wb = load_workbook(fname, keep_vba=True)
ws = wb['Form Controls']
sheet = fromstring(write_worksheet(ws, None))
els = sheet.findall('{%s}legacyDrawing' % SHEET_MAIN_NS)
assert len(els) == 1, "Wrong number of legacyDrawing elements %d" % len(els)
assert els[0].get('{%s}id' % REL_NS) == 'vbaControlId'
def test_vba_rels(datadir, write_worksheet):
datadir.chdir()
fname = 'vba+comments.xlsm'
wb = load_workbook(fname, keep_vba=True)
ws = wb['Form Controls']
xml = tostring(write_rels(ws, comments_id=1, vba_controls_id=1))
expected = """
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="vbaControlId" Target="/xl/drawings/vmlDrawing1.vml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing"/>
<Relationship Id="comments" Target="/xl/comments1.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"/>
</Relationships>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_write_comments(worksheet, write_worksheet):
ws = worksheet
worksheet._comment_count = 1
xml = write_worksheet(ws, None)
expected = """
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<sheetPr>
<outlinePr summaryBelow="1" summaryRight="1"/>
<pageSetUpPr/>
</sheetPr>
<dimension ref="A1:A1"/>
<sheetViews>
<sheetView workbookViewId="0">
<selection activeCell="A1" sqref="A1"/>
</sheetView>
</sheetViews>
<sheetFormatPr baseColWidth="10" defaultRowHeight="15"/>
<sheetData/>
<pageMargins bottom="1" footer="0.5" header="0.5" left="0.75" right="0.75" top="1"/>
<legacyDrawing r:id="commentsvml"></legacyDrawing>
</worksheet>
"""
diff = compare_xml(xml, expected)
assert diff is None, diff
def test_write_drawing(worksheet):
from ..worksheet import write_drawing
worksheet._images = [1]
expected = """
<drawing xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:id="rId1"/>
"""
xml = tostring(write_drawing(worksheet))
diff = compare_xml(xml, expected)
assert diff is None, diff
|