Skip to content

Commit

Permalink
Do not require mock on Python2.7
Browse files Browse the repository at this point in the history
Fixes #198
  • Loading branch information
ale-rt committed May 25, 2020
1 parent 5c5015c commit 0409d15
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions news/198.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Require mock only on Python 2.7 [ale-rt]
6 changes: 5 additions & 1 deletion plone/app/content/tests/test_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
from zope.component import getUtility

import json
import mock
import transaction
import unittest

try:
from unittest import mock
except ImportError:
import mock


class ContentsCopyTests(unittest.TestCase):
layer = PLONE_APP_CONTENT_DX_INTEGRATION_TESTING
Expand Down
13 changes: 8 additions & 5 deletions plone/app/content/tests/test_widgets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from mock import Mock
from plone.app.content.browser import vocabulary
from plone.app.content.browser.file import FileUploadView
from plone.app.content.browser.query import QueryStringIndexOptions
Expand All @@ -26,7 +25,6 @@
from zope.publisher.browser import TestRequest

import json
import mock
import os
import transaction

Expand All @@ -37,6 +35,11 @@
def processQueue():
pass

try:
from unittest import mock
except ImportError:
import mock


_dir = os.path.dirname(__file__)

Expand Down Expand Up @@ -388,7 +391,7 @@ def testSource(self):
class DummyCatalogSource(object):
def search_catalog(self, query):
querytext = query['SearchableText']['query']
return [Mock(id=querytext)]
return [mock.Mock(id=querytext)]

widget = TextWidget(self.request)
widget.context = self.portal
Expand Down Expand Up @@ -468,7 +471,7 @@ def testSourcePermissionDenied(self):
class DummyCatalogSource(object):
def search_catalog(self, query):
querytext = query['SearchableText']['query']
return [Mock(id=querytext)]
return [mock.Mock(id=querytext)]

widget = TextWidget(self.request)
widget.context = self.portal
Expand Down Expand Up @@ -503,7 +506,7 @@ def testSourceTextQuery(self):
@implementer(ISource)
class DummyCatalogSource(object):
def search(self, query):
return [Mock(value=Mock(id=query))]
return [mock.Mock(value=mock.Mock(id=query))]

widget = TextWidget(self.request)
widget.context = self.portal
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
test=[
'plone.app.contenttypes',
'plone.app.testing',
'mock'
'mock;python_version<"3.3"'
]
),
install_requires=[
Expand Down

0 comments on commit 0409d15

Please sign in to comment.