Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tests for py3 #5

Merged
merged 1 commit into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Fixes:
because they get the acquisition-wrapped object.
[jensens]

- Fix tests to work in Python 3
[pbauer]


1.0.4 (2016-02-25)
------------------
Expand Down
4 changes: 2 additions & 2 deletions plone/indexer/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ For example::

>>> test_page = Page(text=u"My page with some text")
>>> page_description(test_page)()
u'My page wi'
'My page wi'

This will suffice in most cases.
Note that there is actually a second parameter, catalog, which defaults to None.
Expand Down Expand Up @@ -163,7 +163,7 @@ We have a compatibility alias in this package for use with CMF 2.1.
... indexed_value = getattr(object, idx)
... if callable(indexed_value):
... indexed_value = indexed_value()
... print idx, "=", indexed_value
... print(idx, "=", indexed_value)
... except (AttributeError, TypeError,):
... pass

Expand Down
17 changes: 15 additions & 2 deletions plone/indexer/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from zope.component import testing

import doctest
import re
import six
import unittest


Expand All @@ -20,11 +22,22 @@ def my_func(obj):
self.assertEqual(my_func.__name__, 'my_func')


class Py23DocChecker(doctest.OutputChecker):
def check_output(self, want, got, optionflags):
if six.PY2:
got = re.sub("u'(.*?)'", "'\\1'", want)
return doctest.OutputChecker.check_output(self, want, got, optionflags)


def test_suite():
return unittest.TestSuite([
doctest.DocFileSuite(
'README.rst', package='plone.indexer',
setUp=testing.setUp, tearDown=testing.tearDown),
'README.rst',
package='plone.indexer',
setUp=testing.setUp,
tearDown=testing.tearDown,
checker=Py23DocChecker(),
),
unittest.makeSuite(TestWrapperUpdate),
])

Expand Down