Skip to content

Commit

Permalink
Merge 75ea47d into 43d7351
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Jun 30, 2017
2 parents 43d7351 + 75ea47d commit eb34906
Show file tree
Hide file tree
Showing 26 changed files with 240 additions and 390 deletions.
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
[run]
source = zope.component
omit =
src/zope/component/standalonetests.py
# Runs in a subprocess

[report]
exclude_lines =
pragma: no cover
pragma NO COVER
if __name__ == '__main__':
raise NotImplementedError
self.fail
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ coverage.xml
.coverage
dist/
.eggs/
htmlcov/
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sudo: false
matrix:
include:
- python: 2.7
env: MINIMAL="-t !persistentregistry -t !security"
env: MINIMAL=1
python:
- 2.7
- 3.4
Expand All @@ -12,7 +12,7 @@ python:
- pypy-5.6.0

script:
- coverage run -m zope.testrunner --test-path=src $MINIMAL
- coverage run -m zope.testrunner --test-path=src
- if [[ -z "$MINIMAL" ]]; then sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html; fi
- if [[ -z "$MINIMAL" ]]; then coverage run -a `which sphinx-build` -b doctest -d docs/_build/doctrees docs docs/_build/doctest; fi

Expand Down
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ Changes

- Drop support for "setup.py test".

- Code coverage reports are now `produced and hosted by coveralls.io
<https://coveralls.io/github/zopefoundation/zope.component>`_, and
PRs must keep them at 100%.

- Internal test code in ``zope.component.testfiles`` has been adjusted
and in some cases removed.

4.3.0 (2016-08-26)
------------------

Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ include *.py
include .travis.yml
include buildout.cfg
include tox.ini
include .coveragerc

prune docs/_build
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@

.. image:: https://travis-ci.org/zopefoundation/zope.component.png?branch=master
:target: https://travis-ci.org/zopefoundation/zope.component
:alt: Build Status

.. image:: https://readthedocs.org/projects/zopecomponent/badge/?version=latest
:target: http://zopecomponent.readthedocs.org/en/latest/
:alt: Documentation Status

.. image:: https://coveralls.io/repos/github/zopefoundation/zope.component/badge.svg?branch=master
:target: https://coveralls.io/github/zopefoundation/zope.component?branch=master
:alt: Coverage Status


.. note::

This package is intended to be independently reusable in any Python
Expand Down
11 changes: 8 additions & 3 deletions docs/testlayer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,29 @@ ZCMLLayer

We now want a layer that loads up some ZCML from a file. The default
is ``ftesting.zcml``, but here we'll load a test ``testlayer.zcml``.
We can also choose to provide extra ZCML features (here, "devmode").

.. doctest::

>>> from zope.component.testlayer import ZCMLFileLayer
>>> import zope.component.testfiles
>>> zcml_file_layer = ZCMLFileLayer(
... zope.component.testfiles,
... 'testlayer.zcml')
... 'testlayer.zcml',
... features=["devmode"])

>>> class TestCase(unittest.TestCase):
... layer = zcml_file_layer
...
... def testFoo(self):
... # The feature was registered
... self.assertTrue(self.layer.context.hasFeature('devmode'))
... # we should now have the adapter registered
... from zope import component
... from zope.component.testfiles import components
... self.assert_(isinstance(
... components.IApp2(components.content), components.Comp2))
... self.assertIsInstance(
... components.IApp2(components.content), components.Comp2)


Since the ZCML sets up an adapter, we expect the tests to pass:

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def read(*rnames):
+ '\n' +
read('CHANGES.rst')
),
keywords="interface component coupling loose utility adapter",
packages=find_packages('src'),
package_dir={'': 'src'},
classifiers=[
Expand Down
5 changes: 3 additions & 2 deletions src/zope/component/standalonetests.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""
See: https://bugs.launchpad.net/zope3/+bug/98401
"""

import sys
import pickle

def write(x): # pragma: NO COVER
def write(x):
sys.stdout.write('%s\n' % x)

if __name__ == "__main__": #pragma NO COVER (runs in subprocess)
if __name__ == "__main__":
if sys.version_info[0] >= 3:
# TextIO? Are you kidding me?
data = sys.stdin.buffer.read()
Expand Down
4 changes: 0 additions & 4 deletions src/zope/component/testfiles/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ class Comp2(object):
def __init__(self, context):
self.context = context

class Comp3(object):
def __init__(self, context):
self.context = context

@adapter(IContent)
@implementer(IApp)
@named('app')
Expand Down
48 changes: 1 addition & 47 deletions src/zope/component/testfiles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,52 +15,6 @@
"""

from zope.interface import Interface
from zope.interface import implementer
from zope.interface import directlyProvides

class Request(object):

def __init__(self, type):
directlyProvides(self, type)

class IR(Interface):
pass

class IV(Interface):
def index():
pass

class IC(Interface): pass

@implementer(IV)
class V1(object):

def __init__(self, context, request):
self.context = context
self.request = request

def index(self):
return 'V1 here'

def action(self):
return 'done'

class VZMI(V1):
def index(self):
return 'ZMI here'

@implementer(IV)
class R1(object):

def index(self):
return 'R1 here'

def action(self):
return 'R done'

def __init__(self, request):
pass


class RZMI(R1):
class IC(Interface):
pass
18 changes: 9 additions & 9 deletions src/zope/component/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
import zope.component.event

# we really don't need special setup now:
class _PlacelessSetupFallback(object):
def cleanUp(self):
from zope.component.globalregistry import base
base.__init__('base')

setUp = tearDown = cleanUp

try:
from zope.testing.cleanup import CleanUp as PlacelessSetup
except ImportError:
class PlacelessSetup(object):
def cleanUp(self):
from zope.component.globalregistry import base
base.__init__('base')
def setUp(self):
self.cleanUp()
def tearDown(self):
self.cleanUp()
except ImportError: # pragma: no cover
PlacelessSetup = _PlacelessSetupFallback

def setUp(test=None):
PlacelessSetup().setUp()
Expand Down
4 changes: 2 additions & 2 deletions src/zope/component/testlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from zope.configuration import xmlconfig, config
try:
from zope.testing.cleanup import cleanUp
except ImportError:
except ImportError: # pragma: no cover
def cleanUp():
pass

Expand Down Expand Up @@ -62,7 +62,7 @@ def __init__(self, package, name=None):
self.__name__ = name
self.__module__ = package.__name__
self.package = package

def setUp(self):
pass

Expand Down
17 changes: 16 additions & 1 deletion src/zope/component/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
# tests package
import unittest

def skipIfNoSecurity(testfunc):
try:
import zope.security
except ImportError:
return unittest.skip("zope.security not installed")(testfunc)
return testfunc

def fails_if_called(test, msg="This function must not be called."):
"""
Return a new function (accepting any arguments)
that will call test.fail(msg) if it is called.
"""

return lambda: test.fail(msg)
8 changes: 0 additions & 8 deletions src/zope/component/tests/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ class ISI(Interface):
class ISII(Interface):
pass

def noop(*args):
pass

class U(object):

def __init__(self, name):
Expand Down Expand Up @@ -121,11 +118,6 @@ def __init__(self, context):

comp = Comp(1)

@implementer(I3)
class Comp2(object):
def __init__(self, context):
self.context = context


class ConformsToIComponentLookup(object):
"""Allow a dummy sitemanager to conform/adapt to `IComponentLookup`."""
Expand Down
Loading

0 comments on commit eb34906

Please sign in to comment.