Skip to content

Commit

Permalink
Add Python 3.6, drop Python 3.3
Browse files Browse the repository at this point in the history
- Badges
- coveralls and coverage environment
  - 100% coverage
- Ensure configure.zcml can be loaded with a test.
  • Loading branch information
jamadden committed Aug 14, 2017
1 parent dce3d2c commit da21f9c
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 83 deletions.
11 changes: 11 additions & 0 deletions .coveragerc
@@ -0,0 +1,11 @@
[run]
source = zope.ptresource

[report]
precision = 2
exclude_lines =
pragma: no cover
if __name__ == '__main__':
raise NotImplementedError
self.fail
raise AssertionError
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -8,3 +8,5 @@ bin/
develop-eggs/
eggs/
parts/
.coverage
htmlcov/
21 changes: 13 additions & 8 deletions .travis.yml
@@ -1,15 +1,20 @@
language: python
sudo: false
python:
- 2.7
- 3.3
- 3.4
- 3.5
- pypy
- pypy3
- 2.7
- 3.4
- 3.5
- 3.6
- pypy
- pypy3.5-5.8.0
install:
- pip install tox-travis
- pip install -U setuptools pip
- pip install -U coveralls coverage
- pip install -U -e .[test]
script:
- tox
- coverage run -m zope.testrunner --test-path=src
after_success:
- coveralls
notifications:
email: false
cache: pip
15 changes: 10 additions & 5 deletions CHANGES.rst
@@ -1,12 +1,15 @@
Changes
=======
=========
Changes
=========


4.1.0 (unreleased)
==================

- Add support for Python 3.5.
- Add support for Python 3.5 and 3.6.

- Drop support for Python 2.6 and 3.3.

- Drop support for Python 2.6.


4.0.0 (2014-12-24)
Expand All @@ -19,6 +22,7 @@ Changes
- Add support for testing on Travis.



4.0.0a1 (2013-02-25)
====================

Expand All @@ -30,10 +34,11 @@ Changes
- Drop support for Python 2.4 and 2.5.



3.9.0 (2009-08-27)
==================

Initial release. This package was splitted off zope.app.publisher as a part
Initial release. This package was split off zope.app.publisher as a part
of refactoring process. It's now a plugin for another package that was
refactored from zope.app.publisher - zope.browserresource. See its
documentation for more details.
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Expand Up @@ -3,6 +3,8 @@ include *.txt
include *.py
include buildout.cfg
include tox.ini
include .travis.yml
include .coveragerc

recursive-include src *

Expand Down
29 changes: 22 additions & 7 deletions README.rst
@@ -1,18 +1,33 @@
``zope.ptresource``
===================
=====================
``zope.ptresource``
=====================

.. image:: https://img.shields.io/pypi/v/zope.ptresource.svg
:target: https://pypi.python.org/pypi/zope.ptresource/
:alt: Latest release

.. image:: https://img.shields.io/pypi/pyversions/zope.ptresource.svg
:target: https://pypi.org/project/zope.ptresource/
:alt: Supported Python versions

.. image:: https://travis-ci.org/zopefoundation/zope.ptresource.png?branch=master
:target: https://travis-ci.org/zopefoundation/zope.ptresource

.. image:: https://coveralls.io/repos/github/zopefoundation/zope.ptresource/badge.svg?branch=master
:target: https://coveralls.io/github/zopefoundation/zope.ptresource?branch=master


.. note::

This package is at present not reusable without depending on a large
chunk of the Zope Toolkit and its assumptions. It is maintained by the
`Zope Toolkit project <http://docs.zope.org/zopetoolkit/>`_.

This package provides a "page template" resource class, a resource which
content is processed with Zope Page Templates engine before returning to
client.
This package provides a "page template" `resource class
<https://pypi.python.org/pypi/zope.browserresource>`_, a resource
whose content is processed with the `Zope Page Templates
<https://pypi.python.org/pypi/zope.pagetemplate>`_ engine before
being returned to client.

The resource factory class is registered for "pt", "zpt" and "html" file
extensions in package's ``configure.zcml`` file.
extensions in the package's ``configure.zcml`` file.
82 changes: 44 additions & 38 deletions setup.py
Expand Up @@ -22,47 +22,53 @@ def read(*rnames):

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

setup(name='zope.ptresource',
version='4.1.0.dev0',
url='http://pypi.python.org/pypi/zope.ptresource/',
author='Zope Foundation and Contributors',
author_email='zope-dev@zope.org',
classifiers = [
'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.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
'Framework :: Zope3',
],
description='Page template resource plugin for zope.browserresource',
long_description=long_description,
license='ZPL 2.1',
packages=find_packages('src'),
package_dir={'': 'src'},
namespace_packages=['zope'],
install_requires=[
TESTS_REQUIRE = [
'zope.testing',
'zope.testrunner',
]

setup(
name='zope.ptresource',
version='4.1.0.dev0',
url='http://github.com/zopefoundation/zope.ptresource/',
author='Zope Foundation and Contributors',
author_email='zope-dev@zope.org',
classifiers=[
'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',
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
'Framework :: Zope3',
],
description='Page template resource plugin for zope.browserresource',
long_description=long_description,
license='ZPL 2.1',
packages=find_packages('src'),
package_dir={'': 'src'},
namespace_packages=['zope'],
install_requires=[
'setuptools',
'zope.browserresource',
'zope.interface',
'zope.pagetemplate',
'zope.publisher',
'zope.security',
],
extras_require={
'test': ['zope.testing'],
},
tests_require=['zope.testing'],
test_suite='zope.ptresource.tests.test_suite',
include_package_data=True,
zip_safe = False,
)
],
extras_require={
'test': TESTS_REQUIRE
},
tests_require=TESTS_REQUIRE,
test_suite='zope.ptresource.tests.test_suite',
include_package_data=True,
zip_safe=False,
)
2 changes: 1 addition & 1 deletion src/zope/__init__.py
@@ -1 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
9 changes: 6 additions & 3 deletions src/zope/ptresource/configure.zcml
@@ -1,17 +1,20 @@
<configure xmlns="http://namespaces.zope.org/zope">

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

<utility
name="pt"
component=".ptresource.PageTemplateResourceFactory"
provides="zope.browserresource.interfaces.IResourceFactoryFactory"
/>

<utility
name="zpt"
component=".ptresource.PageTemplateResourceFactory"
provides="zope.browserresource.interfaces.IResourceFactoryFactory"
/>

<utility
name="html"
component=".ptresource.PageTemplateResourceFactory"
Expand All @@ -21,7 +24,7 @@
<class class=".ptresource.PageTemplateResource">
<allow
interface="zope.publisher.interfaces.browser.IBrowserPublisher"
attributes="__call__"
attributes="__call__"
/>
</class>

Expand Down
35 changes: 22 additions & 13 deletions src/zope/ptresource/tests.py
Expand Up @@ -26,29 +26,23 @@
from zope.traversing.interfaces import ITraversable

from zope.ptresource.ptresource import PageTemplateResourceFactory

from zope.ptresource.ptresource import PageTemplateResource
from zope.ptresource.ptresource import PageTemplate

checker = NamesChecker(('__call__', 'request', 'publishTraverse'))


class Test(cleanup.CleanUp, unittest.TestCase):

_test_file = None

def setUp(self):
super(Test, self).setUp()
provideAdapter(DefaultTraversable, (None,), ITraversable)

def tearDown(self):
super(Test, self).tearDown()
if self._test_file is not None:
os.unlink(self._test_file)

def createTestFile(self, contents):
f = tempfile.NamedTemporaryFile(mode='w', delete=False)
f.write(contents)
f.close()
self._test_file = f.name
self.addCleanup(os.unlink, f.name)
return f.name

def testNoTraversal(self):
Expand All @@ -68,19 +62,34 @@ def testBrowserDefault(self):
resource = factory(request)
view, next = resource.browserDefault(request)
self.assertEqual(view(),
'<html><body>%s</body></html>' % test_data)
'<html><body>%s</body></html>' % test_data)
self.assertEqual('text/html',
request.response.getHeader('Content-Type'))
request.response.getHeader('Content-Type'))
self.assertEqual(next, ())

request = TestRequest(test_data=test_data, REQUEST_METHOD='HEAD')
resource = factory(request)
view, next = resource.browserDefault(request)
self.assertEqual(view(), '')
self.assertEqual('text/html',
request.response.getHeader('Content-Type'))
request.response.getHeader('Content-Type'))
self.assertEqual(next, ())

def testContentType(self):
path = self.createTestFile('<html><body><p>test</p></body></html>')
request = TestRequest()
pt = PageTemplate(path, content_type='text/xhtml')

resource = PageTemplateResource(pt, request)
resource.GET()
self.assertEqual('text/xhtml',
request.response.getHeader('Content-Type'))

def testConfigure(self):
from zope.configuration import xmlconfig
import zope.ptresource
xmlconfig.file('configure.zcml', zope.ptresource)


def test_suite():
return unittest.makeSuite(Test)
return unittest.defaultTestLoader.loadTestsFromName(__name__)
22 changes: 14 additions & 8 deletions tox.ini
@@ -1,14 +1,20 @@
[tox]
envlist =
py27,py33,py34,py35,pypy,pypy3
py27,py34,py35,py36,pypy,pypy3,coverage

[testenv]
commands =
python setup.py -q test -q
zope-testrunner --test-path=src []
deps =
zope.browserresource
zope.interface
zope.pagetemplate
zope.publisher
zope.security
zope.testing
.[test]

[testenv:coverage]
usedevelop = true
basepython =
python2.7
commands =
coverage run -m zope.testrunner --test-path=src []
coverage report --fail-under=100
deps =
{[testenv]deps}
coverage

0 comments on commit da21f9c

Please sign in to comment.