Skip to content

Commit

Permalink
Add Python 3 and PyPy support.
Browse files Browse the repository at this point in the history
Add tox.ini

Test configure.zcml

100% coverage
  • Loading branch information
jamadden committed Apr 22, 2017
1 parent 4a909c4 commit 65c165f
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 52 deletions.
6 changes: 6 additions & 0 deletions .coveragerc
@@ -0,0 +1,6 @@
[run]
source = src

[report]
exclude_lines =
pragma: no cover
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -9,3 +9,5 @@ build/
dist/
*.egg-info/
.tox/
.coverage
htmlcov/
16 changes: 14 additions & 2 deletions .travis.yml
@@ -1,9 +1,21 @@
language: python
sudo: false
python:
- 2.7
- pypy-5.4.1
- 3.4
- 3.5
- 3.6
install:
- pip install .
- pip install -U pip setuptools
- pip install -U coverage coveralls zope.testrunner
- pip install -U -e .[test]
script:
- python setup.py test -q
- coverage run -m zope.testrunner --test-path=src --auto-color --auto-progress
notifications:
email: false
after_success:
- coveralls
cache: pip
before_cache:
- rm -f $HOME/.cache/pip/log/debug.log
5 changes: 3 additions & 2 deletions CHANGES.txt
Expand Up @@ -2,10 +2,11 @@
CHANGES
=======

3.5.2 (unreleased)
4.0.0 (unreleased)
------------------

- Nothing changed yet.
- Add support for PyPy.
- Add support for Python 3.4, 3.5 and 3.6.


3.5.1 (2010-12-21)
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
@@ -1,4 +1,6 @@
include *.py
include *.txt
include buildout.cfg
include tox.ini
include .coveragerc
recursive-include src *.zcml
2 changes: 2 additions & 0 deletions setup.cfg
@@ -0,0 +1,2 @@
[bdist_wheel]
universal = 1
58 changes: 39 additions & 19 deletions setup.py
Expand Up @@ -21,10 +21,19 @@
from setuptools import setup, find_packages

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

version = '4.0.0.dev0'

tests_require = [
'zope.configuration',
'zope.testing',
'zope.testrunner',
]

setup(name='zope.app.content',
version='3.5.2dev',
version=version,
author='Zope Foundation and Contributors',
author_email='zope-dev@zope.org',
description='Zope Content Type',
Expand All @@ -33,31 +42,42 @@ def read(*rnames):
+ '\n\n' +
read('CHANGES.txt')
),
keywords = "zope3 content type",
classifiers = [
keywords="zope3 content type",
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'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 :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Natural Language :: English',
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
'Framework :: Zope3'],
url='http://cheeseshop.python.org/pypi/zope.app.content',
'Framework :: Zope3'
],
url='http://github.com/zopefoundation/zope.app.content',
license='ZPL 2.1',
packages=find_packages('src'),
package_dir = {'': 'src'},
package_dir={'': 'src'},
namespace_packages=['zope', 'zope.app'],
install_requires=['setuptools',
'zope.componentvocabulary',
'zope.interface',
'zope.schema',
'zope.security',
],
extras_require=dict(test=[
'zope.testing',
]),
include_package_data = True,
zip_safe = False,
)
install_requires=[
'setuptools',
'zope.componentvocabulary',
'zope.interface',
'zope.schema',
'zope.security',
],
extras_require={
'test': tests_require,
},
tests_require=tests_require,
include_package_data=True,
zip_safe=False,
)
7 changes: 1 addition & 6 deletions src/zope/__init__.py
@@ -1,7 +1,2 @@
# this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
7 changes: 1 addition & 6 deletions src/zope/app/__init__.py
@@ -1,7 +1,2 @@
# this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
61 changes: 45 additions & 16 deletions src/zope/app/content/__init__.py
Expand Up @@ -13,7 +13,7 @@
##############################################################################
"""Content Type convenience lookup functions."""

from zope.interface import classProvides
from zope.interface import provider
from zope.interface import providedBy
from zope.schema.interfaces import IVocabularyFactory
from zope.app.content.interfaces import IContentType
Expand All @@ -27,16 +27,21 @@ def queryType(object, interface):
>>> from zope.interface import Interface
>>> class IContentType(Interface):
... pass
>>> from zope.interface import Interface, implements, directlyProvides
>>> from zope.interface import Interface, implementer, directlyProvides
>>> class I(Interface):
... pass
>>> class J(Interface):
... pass
>>> directlyProvides(I, IContentType)
>>> class C(object):
... implements(I)
>>> class D(object):
... implements(J,I)
>>> @implementer(I)
... class C(object):
... pass
>>> @implementer(J, I)
... class D(object):
... pass
>>> obj = C()
>>> c1_ctype = queryType(obj, IContentType)
>>> c1_ctype.__name__
Expand All @@ -47,21 +52,27 @@ def queryType(object, interface):
... pass
>>> class I3(Interface):
... pass
>>> class C1(object):
... implements(I1)
>>> @implementer(I1)
... class C1(object):
... pass
>>> obj1 = C1()
>>> c1_ctype = queryType(obj1, IContentType)
>>> c1_ctype.__name__
'I'
>>> class C2(object):
... implements(I2)
>>> @implementer(I2)
... class C2(object):
... pass
>>> obj2 = C2()
>>> c2_ctype = queryType(obj2, IContentType)
>>> c2_ctype.__name__
'I'
>>> class C3(object):
... implements(I3)
>>> @implementer(I3)
... class C3(object):
... pass
>>> obj3 = C3()
If Interface doesn't provide `IContentType`, `queryType` returns ``None``.
Expand All @@ -73,8 +84,10 @@ def queryType(object, interface):
>>> class I4(I):
... pass
>>> directlyProvides(I4, IContentType)
>>> class C4(object):
... implements(I4)
>>> @implementer(I4)
... class C4(object):
... pass
>>> obj4 = C4()
>>> c4_ctype = queryType(obj4, IContentType)
>>> c4_ctype.__name__
Expand All @@ -93,10 +106,26 @@ def queryType(object, interface):

def queryContentType(object):
"""Returns the interface implemented by object which implements
`IContentType`."""
:class:`zope.app.content.interfaces.IContentType`.
>>> from zope.interface import Interface, implementer, directlyProvides
>>> class I(Interface):
... pass
>>> directlyProvides(I, IContentType)
>>> @implementer(I)
... class C(object):
... pass
>>> obj = C()
>>> c1_ctype = queryContentType(obj)
>>> c1_ctype.__name__
'I'
"""
return queryType(object, IContentType)


@provider(IVocabularyFactory)
class ContentTypesVocabulary(UtilityVocabulary):
classProvides(IVocabularyFactory)
interface = IContentType
2 changes: 2 additions & 0 deletions src/zope/app/content/configure.zcml
@@ -1,6 +1,8 @@
<configure
xmlns="http://namespaces.zope.org/zope">

<include package="zope.component" file="meta.zcml" />

<interface
interface="zope.app.content.interfaces.IContentType"
/>
Expand Down
18 changes: 17 additions & 1 deletion src/zope/app/content/tests.py
Expand Up @@ -16,5 +16,21 @@
import doctest
import unittest

from zope import component
from zope.schema.interfaces import IVocabularyFactory
from zope.testing.cleanup import CleanUp
import zope.app.content

class TestConfiguration(CleanUp, unittest.TestCase):

def test_configuration(self):
from zope.configuration import xmlconfig
xmlconfig.file('configure.zcml', package=zope.app.content)

component.getUtility(IVocabularyFactory, name="Content Types")

def test_suite():
return doctest.DocTestSuite("zope.app.content")
return unittest.TestSuite((
doctest.DocTestSuite("zope.app.content"),
unittest.defaultTestLoader.loadTestsFromName(__name__),
))
9 changes: 9 additions & 0 deletions tox.ini
@@ -0,0 +1,9 @@
[tox]
envlist =
py27, pypy, py34, py35, py36

[testenv]
commands =
zope-testrunner --test-path=src
deps =
.[test]

0 comments on commit 65c165f

Please sign in to comment.