Skip to content

Commit 2bad8ed

Browse files
author
Steve Canny
committed
api: remove old Document.tables
1 parent 8f7f4fa commit 2bad8ed

File tree

4 files changed

+1
-93
lines changed

4 files changed

+1
-93
lines changed

docx/api.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,4 @@ def styles(self):
9797

9898
@property
9999
def tables(self):
100-
"""
101-
A list of |Table| instances corresponding to the tables in the
102-
document, in document order. Note that tables within revision marks
103-
such as ``<w:ins>`` or ``<w:del>`` do not appear in this list.
104-
"""
105-
return self._document_part.tables
100+
return self._document.tables

docx/parts/document.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,6 @@ def styles(self):
125125
"""
126126
return self._styles_part.styles
127127

128-
@property
129-
def tables(self):
130-
"""
131-
A list of |Table| instances corresponding to the tables in the
132-
document, in document order. Note that tables within revision marks
133-
such as ``<w:ins>`` or ``<w:del>`` do not appear in this list.
134-
"""
135-
return self.body.tables
136-
137128
@property
138129
def _styles_part(self):
139130
"""

tests/parts/test_document.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ def it_has_a_body(self, body_fixture):
4545
_Body_.assert_called_once_with(body_elm, document_part)
4646
assert _body is _Body_.return_value
4747

48-
def it_provides_access_to_the_document_tables(self, tables_fixture):
49-
document_part, tables_ = tables_fixture
50-
tables = document_part.tables
51-
assert tables is tables_
52-
5348
def it_provides_access_to_the_document_styles(self, styles_fixture):
5449
document_part, styles_ = styles_fixture
5550
styles = document_part.styles
@@ -232,32 +227,16 @@ def styles_part_get_fixture(self, part_related_by_, styles_part_):
232227
part_related_by_.return_value = styles_part_
233228
return document_part, styles_part_
234229

235-
@pytest.fixture
236-
def tables_fixture(self, document_part_body_, body_, tables_):
237-
document_part = DocumentPart(None, None, None, None)
238-
body_.tables = tables_
239-
return document_part, tables_
240-
241230
# fixture components ---------------------------------------------
242231

243232
@pytest.fixture
244233
def _Body_(self, request):
245234
return class_mock(request, 'docx.parts.document._Body')
246235

247-
@pytest.fixture
248-
def body_(self, request):
249-
return instance_mock(request, _Body)
250-
251236
@pytest.fixture
252237
def core_properties_(self, request):
253238
return instance_mock(request, CoreProperties)
254239

255-
@pytest.fixture
256-
def document_part_body_(self, request, body_):
257-
return property_mock(
258-
request, DocumentPart, 'body', return_value=body_
259-
)
260-
261240
@pytest.fixture
262241
def get_or_add_image_fixture(
263242
self, request, package_, image_descriptor_, image_parts_,
@@ -343,10 +322,6 @@ def styles_prop_(self, request, styles_):
343322
def _styles_part_prop_(self, request):
344323
return property_mock(request, DocumentPart, '_styles_part')
345324

346-
@pytest.fixture
347-
def tables_(self, request):
348-
return instance_mock(request, list)
349-
350325

351326
class Describe_Body(object):
352327

tests/test_api.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
from docx.api import Document, DocumentNew
1616
from docx.opc.constants import CONTENT_TYPE as CT
17-
from docx.package import Package
18-
from docx.parts.document import DocumentPart
1917

2018
from .unitutil.mock import function_mock, instance_mock, class_mock
2119

@@ -77,54 +75,3 @@ def document_(self, request):
7775
@pytest.fixture
7876
def Package_(self, request):
7977
return class_mock(request, 'docx.api.Package')
80-
81-
82-
class DescribeDocumentOld(object):
83-
84-
def it_provides_access_to_the_document_tables(self, tables_fixture):
85-
document, tables_ = tables_fixture
86-
tables = document.tables
87-
assert tables is tables_
88-
89-
# fixtures -------------------------------------------------------
90-
91-
@pytest.fixture
92-
def tables_fixture(self, document, tables_):
93-
return document, tables_
94-
95-
# fixture components ---------------------------------------------
96-
97-
@pytest.fixture
98-
def document(self, open_):
99-
return Document()
100-
101-
@pytest.fixture
102-
def document_obj_(self, request):
103-
return instance_mock(request, docx.document.Document)
104-
105-
@pytest.fixture
106-
def document_part_(self, request, tables_):
107-
document_part_ = instance_mock(
108-
request, DocumentPart, content_type=CT.WML_DOCUMENT_MAIN
109-
)
110-
document_part_.tables = tables_
111-
return document_part_
112-
113-
@pytest.fixture
114-
def open_(self, request, document_obj_, document_part_, package_):
115-
document_part_.package = package_
116-
document_obj_._part = document_part_
117-
return function_mock(
118-
request, 'docx.api.DocumentNew',
119-
return_value=document_obj_
120-
)
121-
122-
@pytest.fixture
123-
def package_(self, request, document_part_):
124-
package_ = instance_mock(request, Package)
125-
package_.main_document_part = document_part_
126-
return package_
127-
128-
@pytest.fixture
129-
def tables_(self, request):
130-
return instance_mock(request, list)

0 commit comments

Comments
 (0)