Skip to content

Commit

Permalink
Merge branch 'master' into lazy-annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed May 26, 2017
2 parents cdb786e + 2e3afec commit c4f51a5
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 23 deletions.
20 changes: 20 additions & 0 deletions .coveragerc
@@ -0,0 +1,20 @@
[run]
branch = True
source = grokcore.annotation

[report]
precision = 2
omit = */interfaces.py
*/interfaces/*
*/tests.py
*/tests/*
*/testing.py

[html]
directory = htmlcov

[paths]
source =
src/grokcore/annotation
.tox/*/lib/python*/site-packages/grokcore/annotation

3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -2,7 +2,10 @@
__pycache__
src/*.egg-info

.coverage
.installed.cfg
.tox/
bin
develop-eggs
htmlcov/
parts
16 changes: 13 additions & 3 deletions .travis.yml
@@ -1,10 +1,20 @@
language: python
python:
- 2.7
- 3.4
- 3.5
- 3.6
- pypy-5.4.1
install:
- python bootstrap.py
- bin/buildout
- pip install -U pip setuptools
- pip install -U coveralls coverage
- pip install -U -e ".[test]"
script:
- bin/test -v1
- coverage run -m zope.testrunner --test-path=src
after_success:
- coveralls
cache: pip
before_cache:
- rm -f $HOME/.cache/pip/log/debug.log
notifications:
email: false
5 changes: 4 additions & 1 deletion CHANGES.txt
@@ -1,11 +1,14 @@
Changes
=======

1.6 (unreleased)
2.0 (unreleased)
----------------

- Add LazyAnnotation and LazyAnnotationProperty.

- Drop support of Python 2.6 and claim support for Python 3.4, 3.5, 3.6 and PyPy.


1.5.1 (2016-01-29)
------------------

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
2 changes: 1 addition & 1 deletion buildout.cfg
@@ -1,7 +1,7 @@
[buildout]
develop = .
parts = interpreter test
extends = https://raw.github.com/zopefoundation/groktoolkit/master/grok.cfg
extends = https://raw.githubusercontent.com/zopefoundation/groktoolkit/resurrection-python3/grok.cfg
versions = versions

[versions]
Expand Down
12 changes: 10 additions & 2 deletions setup.py
Expand Up @@ -13,7 +13,7 @@ def read(*rnames):
tests_require = [
'zope.configuration',
'zope.schema',
'zope.testing',
'zope.testing > 4.6',
]


Expand All @@ -31,6 +31,14 @@ 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 :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Framework :: Zope3',
],

Expand All @@ -40,7 +48,6 @@ def read(*rnames):
include_package_data=True,
zip_safe=False,
install_requires=[
'ZODB3',
'grokcore.component >= 2.5dev',
'martian',
'setuptools',
Expand All @@ -52,5 +59,6 @@ def read(*rnames):
'zope.location',
],
tests_require=tests_require,
test_suite='grokcore.annotation.tests.test_grok.test_suite',
extras_require={'test': tests_require},
)
6 changes: 3 additions & 3 deletions src/grokcore/annotation/components.py
Expand Up @@ -18,17 +18,17 @@
from zope.annotation.interfaces import IAttributeAnnotatable
from zope.annotation.interfaces import IAnnotations
from zope.container import contained
from zope.interface import implements, providedBy
from zope.interface import providedBy
from zope.component import getSiteManager
from grokcore.annotation.interfaces import IAnnotationFactory
import persistent
import grokcore.component


@grokcore.component.implementer(IAttributeAnnotatable)
class Model(grokcore.component.Context):
"""Base class for an object which is able to handle annotations
"""
grokcore.component.implements(IAttributeAnnotatable)


class Annotation(persistent.Persistent, contained.Contained):
Expand All @@ -38,8 +38,8 @@ class Annotation(persistent.Persistent, contained.Contained):
"""


@grokcore.component.implementer(IAnnotationFactory)
class AnnotationFactory(object):
implements(IAnnotationFactory)

def __init__(self, factory, name):
self.factory = factory
Expand Down
7 changes: 4 additions & 3 deletions src/grokcore/annotation/testing.py
Expand Up @@ -13,6 +13,7 @@
##############################################################################
"""Grok test helpers
"""
from __future__ import print_function
import sys
from zope.configuration.config import ConfigurationMachine
from grokcore.component import zcml
Expand All @@ -37,7 +38,7 @@ def warn(message, category=None, stacklevel=1):
When zope.deprecation is fixed, this warn function can be removed again.
"""
print "From grok.testing's warn():"
print("From grok.testing's warn():")

frame = sys._getframe(stacklevel)
path = frame.f_globals['__file__']
Expand All @@ -49,10 +50,10 @@ def warn(message, category=None, stacklevel=1):
for i in range(lineno):
line = file.readline()

print "%s:%s: %s: %s\n %s" % (
print("{}:{}: {}: {}\n {}".format(
path,
frame.f_lineno,
category.__name__,
message,
line.strip(),
)
))
17 changes: 17 additions & 0 deletions src/grokcore/annotation/tests/annotation/annotation.py
Expand Up @@ -10,6 +10,11 @@
>>> grok.queryAnnotation(manfred, IBranding) is None
True
If you query an annotation with an interface that does not match you get None:
>>> grok.queryAnnotation(manfred, None) is None
True
We can adapt a model to an annotation interface and obtain a
persistent annotation storage:
Expand Down Expand Up @@ -46,9 +51,21 @@
>>> grok.deleteAnnotation(manfred, IBranding)
True
If you try to delete it again, you get False:
>>> grok.deleteAnnotation(manfred, IBranding)
False
If you try to query for a non existing annotation you get None:
>>> grok.queryAnnotation(manfred, IBranding) is None
True
If you want to delete a non-matching annotation you get False:
>>> grok.deleteAnnotation(manfred, None)
False
"""
Expand Down
6 changes: 2 additions & 4 deletions src/grokcore/annotation/tests/annotation/implementsmany.py
Expand Up @@ -5,10 +5,8 @@
>>> grok.testing.grok(__name__)
Traceback (most recent call last):
GrokError: <class
'grokcore.annotation.tests.annotation.implementsmany.MammothAnnotations'> is
implementing more than one interface (use grok.provides to specify
which one to use).
...
martian.error.GrokError: <class 'grokcore.annotation.tests.annotation.implementsmany.MammothAnnotations'> is implementing more than one interface (use grok.provides to specify which one to use).
"""

import grokcore.annotation as grok
Expand Down
5 changes: 2 additions & 3 deletions src/grokcore/annotation/tests/annotation/implementsnone.py
Expand Up @@ -5,9 +5,8 @@
>>> grok.testing.grok(__name__)
Traceback (most recent call last):
GrokError: <class 'grokcore.annotation.tests.annotation.implementsnone.Branding'>
must implement at least one interface (use grok.implements to
specify).
...
martian.error.GrokError: <class 'grokcore.annotation.tests.annotation.implementsnone.Branding'> must implement at least one interface (use grok.implements to specify).
"""

Expand Down
9 changes: 7 additions & 2 deletions src/grokcore/annotation/tests/test_grok.py
Expand Up @@ -21,7 +21,8 @@ def cleanUpZope(test):
# exceptions appear in traceback printouts.
(re.compile(
r"ConfigurationExecutionError: <class '([\w.]+)'>:"),
r'ConfigurationExecutionError: \1:')])
r'ConfigurationExecutionError: \1:'),
])


def suiteFromPackage(name):
Expand All @@ -41,7 +42,11 @@ def suiteFromPackage(name):
setUp=setUpZope,
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 Down
29 changes: 29 additions & 0 deletions tox.ini
@@ -0,0 +1,29 @@
[tox]
envlist = coverage-clean, py27, py34, py35, py36, pypy, coverage-report

[testenv]
commands =
coverage run {envbindir}/zope-testrunner --test-path=src []
setenv =
COVERAGE_FILE=.coverage.{envname}
deps =
.[test]
coverage

[testenv:coverage-clean]
deps = coverage
setenv =
COVERAGE_FILE=.coverage
skip_install = true
commands = coverage erase

[testenv:coverage-report]
deps = coverage
setenv =
COVERAGE_FILE=.coverage
skip_install = true
commands =
coverage combine
coverage report
coverage html
coverage

0 comments on commit c4f51a5

Please sign in to comment.