diff options
author | Colin Watson <cjwatson@debian.org> | 2019-12-18 23:26:03 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2019-12-18 23:31:28 +0000 |
commit | 292dc07c0d7ea832c075f7f8e44074c1e21de127 (patch) | |
tree | e63dabd21c9dd649e106608d5f15c82d2c051c53 | |
parent | 1ff5d03b90cf0a2e37fc673e3865e506c6734b94 (diff) | |
download | zope-contenttype-292dc07c0d7ea832c075f7f8e44074c1e21de127.tar.gz |
Fix tests on Python 3.8
Marius Gedminas worked out that the fix for
https://bugs.python.org/issue4963 in Python 3.8 (also backported to 3.7)
meant that `mimetypes.init` now modifies `mimetypes.types_map` in place.
Work around this by remembering the length of `types_map` at the start
of each test.
Fixes #7.
-rw-r--r-- | CHANGES.rst | 3 | ||||
-rw-r--r-- | src/zope/contenttype/tests/testContentTypes.py | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 00bc4a2..c6f86f7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,8 @@ 4.5 (unreleased) ================ -- Nothing changed yet. +- Fix tests on Python 3.8 + (`#7 <https://github.com/zopefoundation/zope.contenttype/issues/7>`_). 4.4 (2018-10-05) diff --git a/src/zope/contenttype/tests/testContentTypes.py b/src/zope/contenttype/tests/testContentTypes.py index 6afeb53..db229a4 100644 --- a/src/zope/contenttype/tests/testContentTypes.py +++ b/src/zope/contenttype/tests/testContentTypes.py @@ -22,6 +22,7 @@ class ContentTypesTestCase(unittest.TestCase): import mimetypes mimetypes.init() self._old_state = mimetypes.__dict__.copy() + self._old_types_count = len(self._old_state["types_map"]) def tearDown(self): import mimetypes @@ -31,7 +32,7 @@ class ContentTypesTestCase(unittest.TestCase): def _check_types_count(self, delta): import mimetypes self.assertEqual(len(mimetypes.types_map), - len(self._old_state["types_map"]) + delta) + self._old_types_count + delta) def _getFilename(self, name): import os.path |