Skip to content

Commit 367afac

Browse files
committed
test: update tox and fix py3 failures
* Sequence is now in `collections.abc` and will be removed from `collections` in 3.8. * zip() returns an iterator in Python 3 and must be wrapped with something like list() or tuple() to be realized. * Remove support for 2.6. * Add tox tests for 3.6 and 3.7. * Update .travis.yml to match tox versions.
1 parent a1ac389 commit 367afac

File tree

5 files changed

+17
-21
lines changed

5 files changed

+17
-21
lines changed

docx/bookmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
from __future__ import absolute_import, division, print_function, unicode_literals
66

7-
from collections import Sequence
87
from itertools import chain
98

9+
from docx.compat import Sequence
1010
from docx.oxml.ns import qn
1111
from docx.shared import lazyproperty
1212

docx/compat.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@
1212
# Python 3 versions
1313
# ===========================================================================
1414

15+
if sys.version_info >= (3, 3):
16+
from collections.abc import Sequence
17+
else:
18+
from collections import Sequence # noqa
19+
1520
if sys.version_info >= (3, 0):
1621

17-
from collections.abc import Sequence
1822
from io import BytesIO
1923

2024
def is_string(obj):
@@ -29,7 +33,6 @@ def is_string(obj):
2933

3034
else:
3135

32-
from collections import Sequence # noqa
3336
from StringIO import StringIO as BytesIO # noqa
3437

3538
def is_string(obj):

tests/test_bookmark.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def it_provides_access_to_bookmarks_by_index(
3636
bookmarkStarts = tuple(element("w:bookmarkStart") for _ in range(3))
3737
bookmarkEnds = tuple(element("w:bookmarkEnd") for _ in range(3))
3838
_finder_prop_.return_value = finder_
39-
finder_.bookmark_pairs = zip(bookmarkStarts, bookmarkEnds)
39+
finder_.bookmark_pairs = list(zip(bookmarkStarts, bookmarkEnds))
4040
_Bookmark_.return_value = bookmark_
4141
bookmarks = Bookmarks(None)
4242

@@ -51,7 +51,7 @@ def it_provides_access_to_bookmarks_by_slice(
5151
bookmarkStarts = tuple(element("w:bookmarkStart") for _ in range(4))
5252
bookmarkEnds = tuple(element("w:bookmarkEnd") for _ in range(4))
5353
_finder_prop_.return_value = finder_
54-
finder_.bookmark_pairs = zip(bookmarkStarts, bookmarkEnds)
54+
finder_.bookmark_pairs = list(zip(bookmarkStarts, bookmarkEnds))
5555
_Bookmark_.return_value = bookmark_
5656
bookmarks = Bookmarks(None)
5757

@@ -69,7 +69,7 @@ def it_can_iterate_its_bookmarks(
6969
bookmarkStarts = tuple(element("w:bookmarkStart") for _ in range(3))
7070
bookmarkEnds = tuple(element("w:bookmarkEnd") for _ in range(3))
7171
_finder_prop_.return_value = finder_
72-
finder_.bookmark_pairs = zip(bookmarkStarts, bookmarkEnds)
72+
finder_.bookmark_pairs = list(zip(bookmarkStarts, bookmarkEnds))
7373
_Bookmark_.return_value = bookmark_
7474
bookmarks = Bookmarks(None)
7575

tests/unitutil/mock.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66

77
import sys
88

9-
if sys.version_info >= (3, 3):
10-
from unittest import mock # noqa
9+
if sys.version_info > (3, 0):
1110
from unittest.mock import ANY, call, MagicMock # noqa
1211
from unittest.mock import create_autospec, Mock, mock_open, patch, PropertyMock
1312
else:
14-
import mock # noqa
1513
from mock import ANY, call, MagicMock # noqa
1614
from mock import create_autospec, Mock, patch, PropertyMock
1715

tox.ini

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,25 @@ testpaths = tests
1717
[tox]
1818
envlist = py26, py27, py34, py35, py36, py38
1919

20-
[testenv]
20+
[testenv:py27]
2121
deps =
2222
behave
2323
lxml
24+
mock
2425
pyparsing
2526
pytest
2627

2728
commands =
2829
py.test -qx
29-
behave --format progress --stop --tags=-wip
30+
behave --format progress
3031

31-
[testenv:py26]
32+
[testenv]
3233
deps =
33-
importlib>=1.0.3
3434
behave
3535
lxml
36-
mock
3736
pyparsing
3837
pytest
3938

40-
[testenv:py27]
41-
deps =
42-
behave
43-
lxml
44-
mock
45-
pyparsing
46-
pytest
39+
commands =
40+
py.test -qx
41+
behave --format progress

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy