Skip to content

Commit

Permalink
- Fix several DeprecationWarnings during unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed Apr 23, 2021
1 parent 560ee65 commit 7bf80e0
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Expand Up @@ -4,6 +4,9 @@ Products.CMFCore Changelog
2.5.2 (unreleased)
------------------

- Fix several DeprecationWarnings during unit tests
(`#112 <https://github.com/zopefoundation/Products.CMFCore/issues/112>`_)

- Set Cache-Control header in '304 Not Modified' response case as well.
(`#111 <https://github.com/zopefoundation/Products.CMFCore/issues/111>`_)

Expand Down
3 changes: 1 addition & 2 deletions buildout.cfg
Expand Up @@ -7,16 +7,15 @@ parts =
test_no_zsql
sphinx


[test]
recipe = zc.recipe.testrunner
defaults = ['-cv']
eggs =
Products.CMFCore[zsql]


[test_no_zsql]
recipe = zc.recipe.testrunner
defaults = ['-cv']
eggs =
Products.CMFCore

Expand Down
@@ -0,0 +1,2 @@
[default]
encoding=UTF-8
37 changes: 22 additions & 15 deletions src/Products/CMFCore/tests/test_ActionsTool.py
Expand Up @@ -159,21 +159,28 @@ def test_listActionInformationActions(self):
visible=1),)

newSecurityManager(None, OmnipotentUser().__of__(self.app.acl_users))
self.assertEqual(tool.listFilteredActionsFor(self.app.foo),
{'workflow': [],
'user': [],
'object': [],
'folder': [{'id': 'folderContents',
'url': 'http://nohost/folder_contents',
'icon': 'http://nohost/icon.gif',
'title': 'Folder contents',
'description': '',
'visible': True,
'available': True,
'allowed': True,
'category': 'folder',
'link_target': '_top'}],
'global': []})
expected = {'workflow': [],
'user': [],
'object': [],
'folder': [{'id': 'folderContents',
'url': 'http://nohost/folder_contents',
'icon': 'http://nohost/icon.gif',
'title': 'Folder contents',
'description': '',
'visible': True,
'available': True,
'allowed': True,
'category': 'folder',
'link_target': '_top'}],
'global': []}
with warnings.catch_warnings():
# Ignore the warning - anything that uses the attribute
# ``_actions`` will raise it. The DeprecationWarning mentions the
# goal of removing old-style actions, but this is too hard and may
# never happen.
warnings.simplefilter('ignore')
self.assertEqual(tool.listFilteredActionsFor(self.app.foo),
expected)


def test_suite():
Expand Down
8 changes: 7 additions & 1 deletion src/Products/CMFCore/tests/test_FSFile.py
Expand Up @@ -15,6 +15,7 @@

import os
import unittest
import warnings

import six

Expand Down Expand Up @@ -119,7 +120,12 @@ def test_str(self):
if six.PY2:
self.assertEqual(str(file), real_data)
else:
self.assertRaises(UnicodeDecodeError, file.__str__)
# Calling ``__str__`` on non-text binary data in Python 3
# will raise a DeprecationWarning because it makes no sense.
# Ignore it here, the warning is irrelevant for the test.
with warnings.catch_warnings():
warnings.simplefilter('ignore')
self.assertRaises(UnicodeDecodeError, file.__str__)

def test_index_html(self):
path, ref = self._extractFile('test_file.swf')
Expand Down

0 comments on commit 7bf80e0

Please sign in to comment.