Skip to content

Commit

Permalink
enhance readability
Browse files Browse the repository at this point in the history
  • Loading branch information
loechel committed Jul 31, 2017
1 parent d3bc761 commit e557add
Show file tree
Hide file tree
Showing 7 changed files with 219 additions and 88 deletions.
2 changes: 1 addition & 1 deletion src/plone/api/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def create(
id=None,
title=None,
safe_id=False,
**kwargs
**kwargs # NOQA: C816
):
"""Create a new content item.
Expand Down
11 changes: 4 additions & 7 deletions src/plone/api/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def show_message(message=None, request=None, type='info'):
:param message: [required] Message to show.
:type message: string
:param request: [required] Request.
:type request: TODO: hm?
:type request: HTTPRequest
:param type: Message type. Possible values: 'info', 'warn', 'error'
:type type: string
:raises:
Expand Down Expand Up @@ -308,8 +308,8 @@ def get_registry_record(name=None, interface=None, default=MISSING):
# Show all records on the interface.
records = [key for key in interface.names()]
msg = (
"Cannot find a record with name '{name}'"
" on interface {identifier}.\n"
'Cannot find a record with name "{name}"'
' on interface {identifier}.\n'
'Did you mean?\n'
'{records}'.format(
name=name,
Expand Down Expand Up @@ -370,10 +370,7 @@ def set_registry_record(name=None, value=None, interface=None):

from zope.schema._bootstrapinterfaces import WrongType
try:
registry['{identifier}.{name}'.format(
identifier=interface.__identifier__,
name=name
)] = value
registry[interface.__identifier__ + '.' + name] = value
except WrongType:
field_type = [
field[1]
Expand Down
6 changes: 5 additions & 1 deletion src/plone/api/tests/test_doctests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
"""Boilerplate for doctest functional tests."""

from logging import getLogger
from plone.app.testing import applyProfile
from plone.app.testing import PLONE_INTEGRATION_TESTING
Expand Down Expand Up @@ -117,6 +118,9 @@ def test_suite():
try:
doctests.append(DocFileSuite(os.path.join(path, filename)))
except IOError:
logger.warning('test_doctest.py skipping {0}'.format(filename))
logger.warning('test_doctest.py skipping {file}'.format(
file=filename,
)
)

return unittest.TestSuite(doctests)
14 changes: 14 additions & 0 deletions src/plone/api/tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,20 @@ def test_adopt_manager_role(self):
])
self.test_test_defaults()

def test_adopt_manager_string_role(self):
"""Test that we can adopt the Manager role temporarily."""
with api.env.adopt_roles(roles='Manager'):
self.should_allow([
'public_method',
'pp_method',
'qq_method',
'rr_method',
])
self.should_forbid([
'private_method',
])
self.test_test_defaults()

def test_adopt_fewers_role(self):
"""Test that we can adopt a non-Manager role temporarily."""
with api.env.adopt_roles(roles=['Member']):
Expand Down
5 changes: 4 additions & 1 deletion src/plone/api/tests/test_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ def setUp(self):
'sender@example.org',
)
else:
self.portal._updateProperty('email_from_name', 'Portal Owner')
self.portal._updateProperty(
'email_from_name',
'Portal Owner',
)
self.portal._updateProperty(
'email_from_address',
'sender@example.org',
Expand Down

1 comment on commit e557add

@jenkins-plone-org
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@loechel Jenkins CI reporting about code analysis
See the full report here: http://jenkins.plone.org/job/package-plone.api/40/violations

src/plone/api/tests/test_doctests.py:121:28: S100 First argument on the same line
src/plone/api/tests/test_doctests.py:121:68: S101 Multi-line construct missing trailing comma
src/plone/api/tests/test_doctests.py:122:21: E126 continuation line over-indented for hanging indent
src/plone/api/tests/test_doctests.py:123:17: E121 continuation line under-indented for hanging indent
src/plone/api/tests/test_doctests.py:123:18: C812 missing trailing comma

Follow these instructions to reproduce it locally.

Please sign in to comment.