Skip to content

Commit

Permalink
Fix doctests under PyPy
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Oct 13, 2017
1 parent ea2aba5 commit 5915cdd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
20 changes: 13 additions & 7 deletions docs/zca_background.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,20 @@ language (because the class is a factory, this is called

>>> from zope.interface import implementer

>>> class SensibleRepr(object):
... def __repr__(self):
... return '<%s>' % (type(self).__name__)

>>> @implementer(IGermanSpeaker)
... class GermanDiplomat(object):
... class GermanDiplomat(SensibleRepr):
... """The German diplomat speaks German."""

>>> @implementer(ISpanishSpeaker)
... class SpanishDiplomat(object):
... class SpanishDiplomat(SensibleRepr):
... """The Spanish diplomat speaks Spanish."""

>>> @implementer(IFrenchSpeaker)
... class FrenchDiplomat(object):
... class FrenchDiplomat(SensibleRepr):
... """The French diplomat speaks French."""

>>> french_diplomat = FrenchDiplomat()
Expand Down Expand Up @@ -179,8 +183,10 @@ inherently secure:
... IGermanSpeaker,
... IFrenchSpeaker)
... class ComputerTranslator(object):
... def __init__(self, person_a, person_b):
... pass
... def __init__(self, *args):
... self.a, self.b = args
... def __repr__(self):
... return '<ComputerTranslator for %r %r>' %(self.a, self.b)

(The computer might want to know exactly who it is translating
for---maybe to adapt to regional dialects---so we'll let it have
Expand All @@ -201,7 +207,7 @@ The diplomats can now have a secure conversation:
.. doctest::

>>> component.getMultiAdapter((spanish_diplomat, german_diplomat), ISecureLanguageTranslator)
<ComputerTranslator ...>
<ComputerTranslator for <SpanishDiplomat> <GermanDiplomat>>

Steve only speaks Spanish and German, but what if the Spanish and
French speakers want to have a (non-secure) conversation about their home town
Expand All @@ -210,7 +216,7 @@ football teams? Steve can't do it. Can anyone?
.. doctest::

>>> component.getMultiAdapter((spanish_diplomat, french_diplomat), ILanguageTranslator)
<ComputerTranslator ...
<ComputerTranslator for <SpanishDiplomat> <FrenchDiplomat>>

The computer can! Because ``ISecureLanguageTranslator`` extends
``ILanguageTranslator``, when we ask for the latter, the registry is
Expand Down
5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ envlist =
[testenv]
commands =
zope-testrunner --test-path=src []
sphinx-build -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest
deps =
.[test]
.[test,docs]

[testenv:coverage]
usedevelop = true
Expand All @@ -23,5 +24,3 @@ deps =
commands =
sphinx-build -a -v -b doctest -d docs/_build/doctrees docs docs/_build/html
sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html
deps =
.[docs]

0 comments on commit 5915cdd

Please sign in to comment.