Skip to content

Commit 762cd2c

Browse files
author
Steve Canny
committed
test: add Python 3.4 compatibility
* remove 3.2 compatibility claim from setup.py * add 3.4 environment to tox.ini * add version-dependent mock imports, becomes unittest.mock from 3.3 forward. Put all the imports in tests.unittest and import locally from there to centralize version-detection logic.
1 parent f74dcd2 commit 762cd2c

File tree

14 files changed

+43
-35
lines changed

14 files changed

+43
-35
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
language: python
22
python:
3+
- "3.4"
34
- "3.3"
45
- "2.7"
56
- "2.6"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def text_of(relpath):
5151
'Programming Language :: Python :: 2.6',
5252
'Programming Language :: Python :: 2.7',
5353
'Programming Language :: Python :: 3',
54-
'Programming Language :: Python :: 3.2',
5554
'Programming Language :: Python :: 3.3',
55+
'Programming Language :: Python :: 3.4',
5656
'Topic :: Office/Business :: Office Suites',
5757
'Topic :: Software Development :: Libraries'
5858
]

tests/image/test_jpeg.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
import pytest
1010

11-
from mock import call
12-
1311
from docx.compat import BytesIO
1412
from docx.image.constants import JPEG_MARKER_CODE, MIME_TYPE
1513
from docx.image.helpers import BIG_ENDIAN, StreamReader
@@ -20,7 +18,7 @@
2018
from docx.image.tiff import Tiff
2119

2220
from ..unitutil import (
23-
initializer_mock, class_mock, instance_mock, method_mock
21+
call, class_mock, initializer_mock, instance_mock, method_mock
2422
)
2523

2624

tests/image/test_png.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
import pytest
1010

11-
from mock import call
12-
1311
from docx.compat import BytesIO
1412
from docx.image.constants import MIME_TYPE, PNG_CHUNK_TYPE
1513
from docx.image.exceptions import InvalidImageStreamError
@@ -20,7 +18,8 @@
2018
)
2119

2220
from ..unitutil import (
23-
function_mock, class_mock, initializer_mock, instance_mock, method_mock
21+
call, class_mock, function_mock, initializer_mock, instance_mock,
22+
method_mock
2423
)
2524

2625

tests/image/test_tiff.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
import pytest
1010

11-
from mock import call
12-
1311
from docx.compat import BytesIO
1412
from docx.image.constants import MIME_TYPE, TIFF_TAG
1513
from docx.image.helpers import BIG_ENDIAN, LITTLE_ENDIAN, StreamReader
@@ -19,8 +17,8 @@
1917
)
2018

2119
from ..unitutil import (
22-
function_mock, class_mock, initializer_mock, instance_mock, loose_mock,
23-
method_mock
20+
call, class_mock, function_mock, initializer_mock, instance_mock,
21+
loose_mock, method_mock
2422
)
2523

2624

tests/opc/test_package.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
import pytest
1010

11-
from mock import call, Mock, patch, PropertyMock
12-
1311
from docx.opc.oxml import CT_Relationships
1412
from docx.opc.packuri import PACKAGE_URI, PackURI
1513
from docx.opc.package import (
@@ -19,8 +17,8 @@
1917
from docx.opc.pkgreader import PackageReader
2018

2119
from ..unitutil import (
22-
cls_attr_mock, class_mock, function_mock, instance_mock, loose_mock,
23-
method_mock
20+
call, class_mock, cls_attr_mock, function_mock, instance_mock,
21+
loose_mock, method_mock, Mock, patch, PropertyMock
2422
)
2523

2624

tests/opc/test_phys_pkg.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import hashlib
1515
import pytest
1616

17-
from mock import Mock
1817
from zipfile import ZIP_DEFLATED, ZipFile
1918

2019
from docx.opc.exceptions import PackageNotFoundError
@@ -23,7 +22,7 @@
2322
_DirPkgReader, PhysPkgReader, PhysPkgWriter, _ZipPkgReader, _ZipPkgWriter
2423
)
2524

26-
from ..unitutil import absjoin, class_mock, loose_mock, test_file_dir
25+
from ..unitutil import absjoin, class_mock, loose_mock, Mock, test_file_dir
2726

2827

2928
test_docx_path = absjoin(test_file_dir, 'test.docx')

tests/opc/test_pkgreader.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
import pytest
1010

11-
from mock import call, Mock, patch
12-
1311
from docx.opc.constants import (
1412
CONTENT_TYPE as CT, RELATIONSHIP_TARGET_MODE as RTM
1513
)
@@ -22,8 +20,8 @@
2220

2321
from .unitdata.types import a_Default, a_Types, an_Override
2422
from ..unitutil import (
25-
initializer_mock, class_mock, function_mock, instance_mock, loose_mock,
26-
method_mock
23+
call, class_mock, function_mock, initializer_mock, instance_mock,
24+
loose_mock, method_mock, Mock, patch
2725
)
2826

2927

tests/opc/test_pkgwriter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
import pytest
88

9-
from mock import call, MagicMock, Mock, patch
10-
119
from docx.opc.constants import CONTENT_TYPE as CT
1210
from docx.opc.package import Part
1311
from docx.opc.packuri import PackURI
1412
from docx.opc.phys_pkg import _ZipPkgWriter
1513
from docx.opc.pkgwriter import _ContentTypesItem, PackageWriter
1614

1715
from .unitdata.types import a_Default, a_Types, an_Override
18-
from ..unitutil import class_mock, instance_mock, method_mock
16+
from ..unitutil import (
17+
call, class_mock, instance_mock, MagicMock, method_mock, Mock, patch
18+
)
1919

2020

2121
class DescribePackageWriter(object):

tests/opc/test_rels.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
import pytest
1010

11-
from mock import call, Mock, patch, PropertyMock
12-
1311
from docx.opc.constants import RELATIONSHIP_TYPE as RT
1412
from docx.opc.oxml import CT_Relationships
1513
from docx.opc.package import Part, _Relationship, Relationships
1614
from docx.opc.packuri import PackURI
1715

18-
from ..unitutil import class_mock, instance_mock, loose_mock
16+
from ..unitutil import (
17+
call, class_mock, instance_mock, loose_mock, Mock, patch, PropertyMock
18+
)
1919

2020

2121
class Describe_Relationship(object):

0 commit comments

Comments
 (0)