Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4 from zopefoundation/resurrection-python3
Browse files Browse the repository at this point in the history
Resurrection python3. WIP.
  • Loading branch information
janwijbrand committed Jan 5, 2018
2 parents 17a5d51 + 4216fb1 commit 254ad66
Show file tree
Hide file tree
Showing 17 changed files with 120 additions and 53 deletions.
7 changes: 4 additions & 3 deletions .gitignore
@@ -1,8 +1,9 @@
*.pyc
__pycache__
src/*.egg-info

.coverage
.installed.cfg
.tox
*.pyc
bin
develop-eggs
parts
src/*.egg-info
16 changes: 12 additions & 4 deletions .travis.yml
@@ -1,11 +1,19 @@
language: python
python:
- 2.6
- 2.7
- 3.4
- 3.5
- 3.6
- pypy
- pypy3
install:
- python bootstrap.py
- bin/buildout
- pip install -U pip setuptools
- pip install -U zope.testrunner coverage coveralls
- pip install -U -e .[test]
script:
- bin/test -v1
- coverage run -m zope.testrunner --test-path=src
after_success:
- coveralls
notifications:
email: false
cache: pip
4 changes: 2 additions & 2 deletions CHANGES.txt
Expand Up @@ -4,15 +4,15 @@ Changes
1.2.2 (unreleased)
==================

- Fix view_lookup test.
- Python 3 compatibility.

- Fix view_lookup test.

1.2.1 (2016-02-15)
==================

- Update tests.


1.2 (2012-05-01)
================

Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
@@ -1,4 +1,3 @@
global-include *.mo
include *.txt
include *.rst
include bootstrap.py
Expand Down
7 changes: 5 additions & 2 deletions buildout.cfg
@@ -1,7 +1,10 @@
[buildout]
extends =
https://raw.githubusercontent.com/zopefoundation/groktoolkit/resurrection-python3/grok.cfg
develop = .
parts = interpreter test
extends = https://raw.github.com/zopefoundation/groktoolkit/master/grok.cfg
parts =
interpreter
test
versions = versions

[versions]
Expand Down
23 changes: 17 additions & 6 deletions setup.py
@@ -1,18 +1,20 @@
from setuptools import setup, find_packages
import os
from setuptools import setup, find_packages


def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()


long_description = (
read('README.rst')
+ '\n' +
read('CHANGES.txt')
)

tests_require = [
'grokcore.view [test]',
'grokcore.view [security_publication]',
'grokcore.view[test]',
'grokcore.view[security_publication]',
'zope.testing',
'zope.app.wsgi',
'zope.app.appsetup',
Expand All @@ -33,19 +35,28 @@ def read(*rnames):
'Intended Audience :: Developers',
'License :: OSI Approved :: Zope Public License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Framework :: Zope3',
],
packages=find_packages('src'),
package_dir = {'': 'src'},
package_dir={'': 'src'},
namespace_packages=['grokcore'],
include_package_data = True,
include_package_data=True,
zip_safe=False,
install_requires=[
'setuptools',
'grokcore.component >= 2.5dev',
'grokcore.security',
'grokcore.view',
'martian',
'setuptools',
'simplejson',
'zope.component',
'zope.interface',
Expand Down
4 changes: 2 additions & 2 deletions src/grokcore/json/components.py
Expand Up @@ -24,12 +24,12 @@

import simplejson
import grokcore.view
from zope.interface import implements
from zope.interface import implementer


@implementer(grokcore.view.IGrokSecurityView)
class JSON(BrowserPage, grokcore.view.ViewSupport):
"""Base class for JSON views in Grok applications."""
implements(grokcore.view.IGrokSecurityView)

def __call__(self):
view_name = self.__view_name__
Expand Down
33 changes: 22 additions & 11 deletions src/grokcore/json/ftests/test_functional.py
@@ -1,14 +1,21 @@
import doctest
import grokcore.json
import re
import unittest
from pkg_resources import resource_listdir
import zope.app.wsgi.testlayer
import zope.testbrowser.wsgi

from pkg_resources import resource_listdir
from zope.app.wsgi.testlayer import http
from zope.testing import renormalizing
from zope.app.wsgi.testlayer import BrowserLayer, http
import grokcore.json


FunctionalLayer = BrowserLayer(grokcore.json)
class Layer(
zope.testbrowser.wsgi.TestBrowserLayer,
zope.app.wsgi.testlayer.BrowserLayer):
pass

layer = Layer(grokcore.view, allowTearDown=True)


checker = renormalizing.RENormalizing([
Expand Down Expand Up @@ -50,13 +57,16 @@ def suiteFromPackage(name):
test = doctest.DocTestSuite(
dottedname,
checker=checker,
extraglobs=dict(http_call=http_call,
http=http,
getRootFolder=FunctionalLayer.getRootFolder),
optionflags=(doctest.ELLIPSIS +
doctest.NORMALIZE_WHITESPACE +
doctest.REPORT_NDIFF))
test.layer = FunctionalLayer
extraglobs=dict(
http_call=http_call,
http=http,
getRootFolder=layer.getRootFolder),
optionflags=(
doctest.ELLIPSIS +
doctest.NORMALIZE_WHITESPACE +
doctest.REPORT_NDIFF +
renormalizing.IGNORE_EXCEPTION_MODULE_IN_PYTHON2))
test.layer = layer

suite.addTest(test)
return suite
Expand All @@ -68,5 +78,6 @@ def test_suite():
suite.addTest(suiteFromPackage(name))
return suite


if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
10 changes: 6 additions & 4 deletions src/grokcore/json/tests/json/json_layers.py
Expand Up @@ -32,8 +32,9 @@
>>> view = getMultiAdapter((mammoth, jsonlayer_request), name='public')
Traceback (most recent call last):
...
ComponentLookupError: ((<grokcore.json.tests.json.json_layers.Mammoth object at ...>,
<zope.publisher.browser.TestRequest instance URL=http://127.0.0.1>),
zope.interface.interfaces.ComponentLookupError: \
((<grokcore.json.tests.json.json_layers.Mammoth object at ...>, \
<zope.publisher.browser.TestRequest instance URL=http://127.0.0.1>), \
<InterfaceClass zope.interface.Interface>, 'public')
The 'public' view not available on the default skin, available on
Expand All @@ -42,8 +43,9 @@
>>> view = getMultiAdapter((mammoth, request), name='another')
Traceback (most recent call last):
...
ComponentLookupError: ((<grokcore.json.tests.json.json_layers.Mammoth object at ...>,
<zope.publisher.browser.TestRequest instance URL=http://127.0.0.1>),
zope.interface.interfaces.ComponentLookupError: \
((<grokcore.json.tests.json.json_layers.Mammoth object at ...>, \
<zope.publisher.browser.TestRequest instance URL=http://127.0.0.1>), \
<InterfaceClass zope.interface.Interface>, 'another')
>>> view = getMultiAdapter((mammoth, jsonlayer_request), name='another')
Expand Down
5 changes: 4 additions & 1 deletion src/grokcore/json/tests/json/missing_permission.py
Expand Up @@ -5,8 +5,11 @@
>>> from grokcore.json import testing
>>> testing.grok(__name__)
Traceback (most recent call last):
ConfigurationExecutionError: martian.error.GrokError: Undefined permission 'doesnt.exist' in <class 'grokcore.json.tests.json.missing_permission.MissingPermission'>. Use grok.Permission first.
...
zope.configuration.config.ConfigurationExecutionError: \
martian.error.GrokError: Undefined permission 'doesnt.exist' in \
<class 'grokcore.json.tests.json.missing_permission.MissingPermission'>. \
Use grok.Permission first...
"""

Expand Down
5 changes: 4 additions & 1 deletion src/grokcore/json/tests/json/missing_permission2.py
Expand Up @@ -6,8 +6,11 @@
>>> from grokcore.json import testing
>>> testing.grok(__name__)
Traceback (most recent call last):
ConfigurationExecutionError: martian.error.GrokError: Undefined permission 'doesnt.exist' in <class 'grokcore.json.tests.json.missing_permission2.MissingPermission'>. Use grok.Permission first.
...
zope.configuration.config.ConfigurationExecutionError: \
martian.error.GrokError: Undefined permission 'doesnt.exist' in \
<class 'grokcore.json.tests.json.missing_permission2.MissingPermission'>. \
Use grok.Permission first...
"""

Expand Down
4 changes: 3 additions & 1 deletion src/grokcore/json/tests/json/multiple_require.py
Expand Up @@ -5,7 +5,9 @@
>>> testing.grok(__name__)
Traceback (most recent call last):
...
GrokError: grok.require was called multiple times in <class 'grokcore.json.tests.json.multiple_require.MultipleJSON'>. It may only be set once for a class.
martian.error.GrokError: grok.require was called multiple times in \
<class 'grokcore.json.tests.json.multiple_require.MultipleJSON'>. It may \
only be set once for a class.
"""
import grokcore.json as grok
Expand Down
4 changes: 2 additions & 2 deletions src/grokcore/json/tests/json/nocontext.py
Expand Up @@ -7,8 +7,8 @@
>>> testing.grok(__name__)
Traceback (most recent call last):
...
GrokError: No module-level context for
<class 'grokcore.json.tests.json.nocontext.TestJSON'>, please use the
martian.error.GrokError: No module-level context for \
<class 'grokcore.json.tests.json.nocontext.TestJSON'>, please use the \
'context' directive.
"""
Expand Down
5 changes: 3 additions & 2 deletions src/grokcore/json/tests/json/nomethods.py
Expand Up @@ -3,8 +3,9 @@
>>> testing.grok(__name__)
Traceback (most recent call last):
...
GrokError: <class 'grokcore.json.tests.json.nomethods.RemoteCaveman'> does not
define any public methods. Please add methods to this class to enable
martian.error.GrokError: \
<class 'grokcore.json.tests.json.nomethods.RemoteCaveman'> does not \
define any public methods. Please add methods to this class to enable \
its registration.
"""
Expand Down
20 changes: 12 additions & 8 deletions src/grokcore/json/tests/json/view_lookup.py
Expand Up @@ -28,8 +28,9 @@
>>> view = getMultiAdapter((mammoth, request), name='_private')
Traceback (most recent call last):
...
ComponentLookupError: ((<grokcore.json.tests.json.view_lookup.Mammoth object at ...>,
<zope.publisher.browser.TestRequest instance URL=http://127.0.0.1>),
zope.interface.interfaces.ComponentLookupError: \
((<grokcore.json.tests.json.view_lookup.Mammoth object at ...>, \
<zope.publisher.browser.TestRequest instance URL=http://127.0.0.1>), \
<InterfaceClass zope.interface.Interface>, '_private')
Even more important, special methods like __call__ are not registered
Expand All @@ -39,8 +40,9 @@
>>> view = getMultiAdapter((mammoth, request), name='__call__')
Traceback (most recent call last):
...
ComponentLookupError: ((<grokcore.json.tests.json.view_lookup.Mammoth object at ...>,
<zope.publisher.browser.TestRequest instance URL=http://127.0.0.1>),
zope.interface.interfaces.ComponentLookupError: \
((<grokcore.json.tests.json.view_lookup.Mammoth object at ...>, \
<zope.publisher.browser.TestRequest instance URL=http://127.0.0.1>), \
<InterfaceClass zope.interface.Interface>, '__call__')
For JSON views we also need to confirm some methods that are defined on the
Expand All @@ -49,15 +51,17 @@
>>> view = getMultiAdapter((mammoth, request), name='browserDefault')
Traceback (most recent call last):
...
ComponentLookupError: ((<grokcore.json.tests.json.view_lookup.Mammoth object at ...>,
<zope.publisher.browser.TestRequest instance URL=http://127.0.0.1>),
zope.interface.interfaces.ComponentLookupError: \
((<grokcore.json.tests.json.view_lookup.Mammoth object at ...>, \
<zope.publisher.browser.TestRequest instance URL=http://127.0.0.1>), \
<InterfaceClass zope.interface.Interface>, 'browserDefault')
>>> view = getMultiAdapter((mammoth, request), name='publishTraverse')
Traceback (most recent call last):
...
ComponentLookupError: ((<grokcore.json.tests.json.view_lookup.Mammoth object at ...>,
<zope.publisher.browser.TestRequest instance URL=http://127.0.0.1>),
zope.interface.interfaces.ComponentLookupError: \
((<grokcore.json.tests.json.view_lookup.Mammoth object at ...>, \
<zope.publisher.browser.TestRequest instance URL=http://127.0.0.1>), \
<InterfaceClass zope.interface.Interface>, 'publishTraverse')
"""
Expand Down
9 changes: 6 additions & 3 deletions src/grokcore/json/tests/test_package.py
@@ -1,8 +1,8 @@
import doctest
import re
import unittest
from pkg_resources import resource_listdir

from pkg_resources import resource_listdir
from zope.testing import cleanup, renormalizing


Expand Down Expand Up @@ -35,8 +35,10 @@ def suiteFromPackage(name):
dottedname,
tearDown=cleanUpZope,
checker=checker,
optionflags=doctest.ELLIPSIS + doctest.NORMALIZE_WHITESPACE)

optionflags=(
doctest.ELLIPSIS +
doctest.NORMALIZE_WHITESPACE +
renormalizing.IGNORE_EXCEPTION_MODULE_IN_PYTHON2))
suite.addTest(test)
return suite

Expand All @@ -47,5 +49,6 @@ def test_suite():
suite.addTest(suiteFromPackage(name))
return suite


if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
16 changes: 16 additions & 0 deletions tox.ini
@@ -0,0 +1,16 @@
[tox]
envlist =
py27,
py34,
py35,
py36,
pypy,
pypy3

[testenv]
commands =
coverage run -m zope.testrunner --test-path=src {posargs:-vc}
deps =
.[test]
zope.testrunner
coverage

0 comments on commit 254ad66

Please sign in to comment.