Skip to content

Commit 2d6c913

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 bd58f43 commit 2d6c913

File tree

7 files changed

+22
-28
lines changed

7 files changed

+22
-28
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
language: python
22
python:
3-
- "3.6"
4-
- "3.5"
53
- "2.7"
6-
- "2.6"
4+
- "3.4"
5+
- "3.5"
6+
- "3.6"
7+
- "3.7"
78
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
89
install: pip install -r requirements.txt
910
# command to run tests, e.g. python setup.py test

docx/bookmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
absolute_import, division, print_function, unicode_literals
77
)
88

9-
from collections import Sequence
109
from itertools import chain
1110

11+
from docx.compat import Sequence
1212
from docx.oxml.ns import qn
1313
from docx.shared import lazyproperty
1414

docx/compat.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
# Python 3 versions
1515
# ===========================================================================
1616

17+
if sys.version_info >= (3, 3):
18+
from collections.abc import Sequence
19+
else:
20+
from collections import Sequence # noqa
21+
1722
if sys.version_info >= (3, 0):
1823

1924
from io import BytesIO

docx/section.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from __future__ import absolute_import, print_function, unicode_literals
88

9-
from collections import Sequence
9+
from docx.compat import Sequence
1010

1111

1212
class Sections(Sequence):

tests/test_bookmark.py

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

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

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

tests/unitutil/mock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
if sys.version_info >= (3, 3):
1212
from unittest import mock # noqa
13-
from unittest.mock import call, MagicMock # noqa
13+
from unittest.mock import ANY, call, MagicMock # noqa
1414
from unittest.mock import create_autospec, Mock, mock_open, patch, PropertyMock
1515
else:
1616
import mock # noqa

tox.ini

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ python_functions = it_ they_ but_ and_it_
1515
testpaths = tests
1616

1717
[tox]
18-
envlist = py26, py27, py33, py34, py35
18+
envlist = py27, py34, py35, py36, py37
1919

20-
[testenv]
20+
[testenv:py27]
2121
deps =
2222
behave
2323
lxml
@@ -27,27 +27,15 @@ deps =
2727

2828
commands =
2929
py.test -qx
30-
behave --format progress --stop --tags=-wip
31-
32-
[testenv:py26]
33-
deps =
34-
importlib>=1.0.3
35-
behave
36-
lxml
37-
mock
38-
pyparsing
39-
pytest
30+
behave --format progress
4031

41-
[testenv:py33]
32+
[testenv]
4233
deps =
4334
behave
4435
lxml
4536
pyparsing
4637
pytest
4738

48-
[testenv:py34]
49-
deps =
50-
behave
51-
lxml
52-
pyparsing
53-
pytest
39+
commands =
40+
py.test -qx
41+
behave --format progress

0 commit comments

Comments
 (0)