X Tutup
Skip to content

Commit 03e48de

Browse files
author
Steve Canny
committed
acpt: add blk-add-table.feature
Also reorganized acceptance tests a bit.
1 parent 46827d0 commit 03e48de

File tree

14 files changed

+218
-150
lines changed

14 files changed

+218
-150
lines changed

docs/dev/analysis/schema/ct_body.rst

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
###########
1+
22
``CT_Body``
3-
###########
3+
===========
44

55
.. highlight:: xml
66

@@ -16,37 +16,8 @@
1616
Spec Section , 17.2.2
1717

1818

19-
Analysis
20-
========
21-
22-
XPath expression from `<p:sp>` is ``./p:txBody``
23-
24-
Can only occur in ``<p:sp>``. Other shape types do not have text.
25-
26-
.. note:: There is a special case of a text box, there's an element or
27-
attribute for that but I'm not sure yet on the details.
28-
29-
30-
attributes
31-
^^^^^^^^^^
32-
33-
None.
34-
35-
36-
child elements
37-
^^^^^^^^^^^^^^
38-
39-
========= ==== ====================== ==========
40-
name # type line
41-
========= ==== ====================== ==========
42-
bodyPr 1 CT_TextBodyProperties 2612 dml
43-
lstStyle ? CT_TextListStyle 2579 dml
44-
p \+ CT_TextParagraph 2527 dml
45-
========= ==== ====================== ==========
46-
47-
4819
Spec text
49-
^^^^^^^^^
20+
---------
5021

5122
This element specifies the contents of the body of the document -- the main
5223
document editing surface.
@@ -70,7 +41,7 @@ Spec text
7041

7142

7243
Schema excerpt
73-
^^^^^^^^^^^^^^
44+
--------------
7445

7546
::
7647

docx/table.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# encoding: utf-8
2+
3+
"""
4+
The |Table| object and related proxy classes.
5+
"""
6+
7+
8+
class Table(object):
9+
"""
10+
Proxy class for a WordprocessingML table.
11+
"""

features/add_paragraph.feature

Lines changed: 0 additions & 12 deletions
This file was deleted.

features/blk-add-paragraph.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Feature: Add a paragraph of text
2+
In order to add text to a document
3+
As an python-docx developer
4+
I need to add a paragraph
5+
6+
Scenario: Add a paragraph
7+
Given a document
8+
When I add a paragraph
9+
And I add a run to the paragraph
10+
And I add text to the run
11+
And I save the document
12+
Then the document contains the text I added

features/blk-add-table.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Feature: Add a table
2+
In order to fulfill a requirement for a table in a document
3+
As an python-docx developer
4+
I need the ability to add a table
5+
6+
@wip
7+
Scenario: Access a table
8+
Given a document containing a table
9+
Then I can access the table
10+
11+
@wip
12+
Scenario: Add a table
13+
Given a document
14+
When I add a table
15+
Then the new table appears in the document

features/environment.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
# -*- coding: utf-8 -*-
2-
#
3-
# environment.py
4-
#
5-
# Copyright (C) 2013 Steve Canny scanny@cisco.com
6-
#
7-
# This module is part of python-docx and is released under the MIT License:
8-
# http://www.opensource.org/licenses/mit-license.php
1+
# encoding: utf-8
92

103
"""
114
Used by behave to set testing environment before and after running acceptance

features/par-set-style.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Feature: Each paragraph has a read/write style
2+
In order to use the stylesheet capability built into Word
3+
As an python-docx developer
4+
I need the ability to get and set the style of a paragraph
5+
6+
Scenario: Set the style of a paragraph
7+
Given a paragraph
8+
When I set the paragraph style
9+
And I save the document
10+
Then the paragraph has the style I set

features/paragraph_style.feature

Lines changed: 0 additions & 11 deletions
This file was deleted.

features/steps/block.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# encoding: utf-8
2+
3+
"""
4+
Step implementations for block content containers
5+
"""
6+
7+
from behave import given, then, when
8+
9+
from docx import Document
10+
from docx.table import Table
11+
12+
from .helpers import test_docx
13+
14+
15+
# given ===================================================
16+
17+
@given('a document containing a table')
18+
def given_a_document_containing_a_table(context):
19+
docx_path = test_docx('blk-containing-table')
20+
context.document = Document(docx_path)
21+
22+
23+
@given('a paragraph')
24+
def given_a_paragraph(context):
25+
context.document = Document()
26+
body = context.document.body
27+
context.p = body.add_paragraph()
28+
29+
30+
# when ====================================================
31+
32+
@when('I add a paragraph')
33+
def when_add_paragraph(context):
34+
body = context.document.body
35+
context.p = body.add_paragraph()
36+
37+
38+
@when('I add a table')
39+
def when_add_table(context):
40+
rows, cols = 2, 2
41+
context.document.body.add_table(rows, cols)
42+
43+
44+
# then =====================================================
45+
46+
@then('I can access the table')
47+
def then_can_access_table(context):
48+
table = context.document.body.tables[-1]
49+
assert isinstance(table, Table)
50+
51+
52+
@then('the new table appears in the document')
53+
def then_new_table_appears_in_document(context):
54+
table = context.document.body.tables[-1]
55+
assert isinstance(table, Table)

features/steps/docx_steps.py

Lines changed: 0 additions & 86 deletions
This file was deleted.

0 commit comments

Comments
 (0)
X Tutup