Skip to content

Commit

Permalink
Fix the documentation so it can be tested with `ZOPE_INTERFACE_STRICT…
Browse files Browse the repository at this point in the history
…_IRO=1`. (#242)

Closes #241.
  • Loading branch information
Michael Howitz committed May 5, 2021
1 parent 7928bb3 commit 077ff5b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ jobs:
pip install -U "`ls dist/zope.interface-*.whl`[docs]"
- name: Build docs
env:
ZOPE_INTERFACE_STRICT_IRO: 0
ZOPE_INTERFACE_STRICT_IRO: 1
run: |
sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html
sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctest
Expand Down
6 changes: 3 additions & 3 deletions docs/api/declarations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ Exmples for :meth:`Declaration.__sub__`:
>>> spec -= I1
>>> [iface.getName() for iface in spec]
[]
>>> spec -= Declaration(I1, I2)
>>> spec -= Declaration(I2)
>>> [iface.getName() for iface in spec]
[]
>>> spec = Declaration(I2, I4)
Expand All @@ -755,7 +755,7 @@ Exmples for :meth:`Declaration.__sub__`:
>>> [iface.getName() for iface in spec - I1]
['I4']
>>> [iface.getName() for iface
... in spec - Declaration(I3, I4)]
... in spec - Declaration(I4)]
['I2']

Exmples for :meth:`Declaration.__add__`:
Expand Down Expand Up @@ -784,7 +784,7 @@ Exmples for :meth:`Declaration.__add__`:
['IRoot1']
>>> [iface.getName() for iface in spec2]
[]
>>> spec2 += Declaration(IRoot2, IDerived2)
>>> spec2 += Declaration(IDerived2, IRoot2)
>>> [iface.getName() for iface in spec2]
['IDerived2', 'IRoot2']
>>> [iface.getName() for iface in spec+spec2]
Expand Down
8 changes: 7 additions & 1 deletion docs/verify.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,17 @@ desired interface.
True

If all instances will provide the interface, we can
mark the class as implementing it.
mark a class as implementing it. But we have to remove the interface from the
instance first so a consistent interface resolution order can be achieved.
(Calling ``gc.collect()`` is also necessary because we use weakrefs.)

.. doctest::

>>> from zope.interface import classImplements
>>> from zope.interface import noLongerProvides
>>> import gc
>>> noLongerProvides(foo, IFoo)
>>> _ = gc.collect()
>>> classImplements(Foo, IFoo)
>>> verify_foo()
True
Expand Down
2 changes: 0 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,3 @@ commands =
deps =
Sphinx
repoze.sphinx.autointerface
setenv =
ZOPE_INTERFACE_STRICT_IRO=0

0 comments on commit 077ff5b

Please sign in to comment.