forked from python-openxml/python-docx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblock.py
More file actions
54 lines (35 loc) · 1.25 KB
/
block.py
File metadata and controls
54 lines (35 loc) · 1.25 KB
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
# encoding: utf-8
"""
Step implementations for block content containers
"""
from behave import given, then, when
from docx import Document
from docx.table import Table
from helpers import test_docx
# given ===================================================
@given('a document containing a table')
def given_a_document_containing_a_table(context):
docx_path = test_docx('blk-containing-table')
context.document = Document(docx_path)
@given('a paragraph')
def given_a_paragraph(context):
context.document = Document()
context.p = context.document.add_paragraph()
# when ====================================================
@when('I add a paragraph')
def when_add_paragraph(context):
document = context.document
context.p = document.add_paragraph()
@when('I add a table')
def when_add_table(context):
rows, cols = 2, 2
context.document.add_table(rows, cols)
# then =====================================================
@then('I can access the table')
def then_can_access_table(context):
table = context.document.tables[-1]
assert isinstance(table, Table)
@then('the new table appears in the document')
def then_new_table_appears_in_document(context):
table = context.document.tables[-1]
assert isinstance(table, Table)