Merge from LP branch.

pull/1/head
Tres Seaver 11 years ago
parent 2fd652d0d0
commit bc4d8bc156
  1. 4
      .bzrignore
  2. 79
      README-better_unittest.txt
  3. 9
      buildout.cfg
  4. 153
      docs/Makefile
  5. 0
      docs/README.rst
  6. 0
      docs/README.ru.rst
  7. 0
      docs/adapter.rst
  8. 0
      docs/adapter.ru.rst
  9. 246
      docs/conf.py
  10. 0
      docs/foodforthought.rst
  11. 0
      docs/human.rst
  12. 0
      docs/human.ru.rst
  13. 9
      docs/index.rst
  14. 190
      docs/make.bat
  15. 0
      docs/verify.rst
  16. 10
      setup.cfg
  17. 20
      setup.py
  18. 32
      src/zope/interface/__init__.py
  19. 8
      src/zope/interface/_zope_interface_coptimizations.c
  20. 50
      src/zope/interface/adapter.py
  21. 8
      src/zope/interface/advice.py
  22. 4
      src/zope/interface/common/interfaces.py
  23. 41
      src/zope/interface/declarations.py
  24. 59
      src/zope/interface/interface.py
  25. 4
      src/zope/interface/registry.py
  26. 2
      src/zope/interface/ro.py
  27. 42
      src/zope/interface/tests/advisory_testing.py
  28. 7
      src/zope/interface/tests/dummy.py
  29. 23
      src/zope/interface/tests/idummy.py
  30. 1640
      src/zope/interface/tests/test_adapter.py
  31. 173
      src/zope/interface/tests/test_advice.py
  32. 1860
      src/zope/interface/tests/test_declarations.py
  33. 279
      src/zope/interface/tests/test_document.py
  34. 75
      src/zope/interface/tests/test_exceptions.py
  35. 2282
      src/zope/interface/tests/test_interface.py
  36. 115
      src/zope/interface/tests/test_interfaces.py
  37. 38
      src/zope/interface/tests/test_odd_declarations.py
  38. 3331
      src/zope/interface/tests/test_registry.py
  39. 558
      src/zope/interface/tests/test_verify.py
  40. 140
      src/zope/interface/tests/unitfixtures.py
  41. 7
      src/zope/interface/verify.py

@ -6,3 +6,7 @@
./parts
*.egg-info
./build
.coverage
include
lib
docs/_build

@ -0,0 +1,79 @@
Overview
========
This branch has three goals:
- Convert all doctests in zope.interface to "normal" Sphinx documentation
- Replace existin API coverage previously provided by the doctests with
standard unit tests.
- Get the unit test coverage, sans doctests, to 100%.
There are secondary, related cleanups, mostly in line with the coding
standards for unit tests proposed here:
- http://palladion.com/home/tseaver/obzervationz/2008/unit_testing_notes-20080724
- http://palladion.com/home/tseaver/obzervationz/2009/unit_testing_redux-20090802
TODO
====
- [_] Move doctest files to docs:
o ``src/zope/interface/README.txt``
o ``src/zope/interface/index.txt``
o ``src/zope/interface/adapter.txt``
o ``src/zope/interface/human.txt``
o ``src/zope/interface/verify.txt``
o ``src/zope/interface/tests/foodforthought``
o ``src/zope/interface/README.ru.txt``
o ``src/zope/interface/adapter.ru.txt``
o ``src/zope/interface/human.ru.txt``
- [X] Remove ``src/zope/interface/tests/unitfixtures.py``.
- [X] Test both C and Python implementations.
- [X] 100% unit test coverage when run under ``nose --with-coverage``:
* :mod:`zope.interface`
* :mod:`zope.interface.adapter`
* :mod:`zope.interface.common`
* :mod:`zope.interface.common.idatetime`
* :mod:`zope.interface.common.interfaces`
* :mod:`zope.interface.common.mapping`
* :mod:`zope.interface.common.sequence`
* :mod:`zope.interface.advice`
* :mod:`zope.interface.declarations`
* :mod:`zope.interface.document`
* :mod:`zope.interface.exceptions`
* :mod:`zope.interface.interface`
* :mod:`zope.interface.interfaces`
* :mod:`zope.interface.registry`
* :mod:`zope.interface.ro`
* :mod:`zope.interface.verify`

@ -1,6 +1,6 @@
[buildout]
develop = .
parts = test python docs
parts = test python
[test]
recipe = zc.recipe.testrunner
@ -12,10 +12,3 @@ recipe = zc.recipe.egg
eggs = zope.interface
zope.event
interpreter = python
[docs]
recipe = z3c.recipe.sphinxdoc
eggs = zope.interface [docs]
build-dir = ${buildout:directory}/docs
default.css =
layout.html =

@ -0,0 +1,153 @@
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
-rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/zopeinterface.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/zopeinterface.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/zopeinterface"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/zopeinterface"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."

@ -0,0 +1,246 @@
# -*- coding: utf-8 -*-
#
# zope.interface documentation build configuration file, created by
# sphinx-quickstart on Mon Mar 26 16:31:31 2012.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'zope.interface'
copyright = u'2012, Zope Foundation contributors'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '3.8'
# The full version, including alpha/beta/rc tags.
release = '3.8.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'zopeinterfacedoc'
# -- Options for LaTeX output --------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'zopeinterface.tex', u'zope.interface Documentation',
u'Zope Foundation contributors', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'zopeinterface', u'zope.interface Documentation',
[u'Zope Foundation contributors'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output ------------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'zopeinterface', u'zope.interface Documentation',
u'Zope Foundation contributors', 'zopeinterface', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'http://docs.python.org/': None}

@ -1,3 +1,8 @@
.. zope.interface documentation master file, created by
sphinx-quickstart on Mon Mar 26 16:31:31 2012.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to zope.interface's documentation!
==========================================
@ -10,6 +15,7 @@ Contents:
adapter
human
verify
foodforthought
По-русски
=========
@ -21,9 +27,12 @@ Contents:
adapter.ru
human.ru
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

@ -0,0 +1,190 @@
@ECHO OFF
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set BUILDDIR=_build
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
set I18NSPHINXOPTS=%SPHINXOPTS% .
if NOT "%PAPER%" == "" (
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
)
if "%1" == "" goto help
if "%1" == "help" (
:help
echo.Please use `make ^<target^>` where ^<target^> is one of
echo. html to make standalone HTML files
echo. dirhtml to make HTML files named index.html in directories
echo. singlehtml to make a single large HTML file
echo. pickle to make pickle files
echo. json to make JSON files
echo. htmlhelp to make HTML files and a HTML help project
echo. qthelp to make HTML files and a qthelp project
echo. devhelp to make HTML files and a Devhelp project
echo. epub to make an epub
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
echo. text to make text files
echo. man to make manual pages
echo. texinfo to make Texinfo files
echo. gettext to make PO message catalogs
echo. changes to make an overview over all changed/added/deprecated items
echo. linkcheck to check all external links for integrity
echo. doctest to run all doctests embedded in the documentation if enabled
goto end
)
if "%1" == "clean" (
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
del /q /s %BUILDDIR%\*
goto end
)
if "%1" == "html" (
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
goto end
)
if "%1" == "dirhtml" (
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
goto end
)
if "%1" == "singlehtml" (
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
goto end
)
if "%1" == "pickle" (
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the pickle files.
goto end
)
if "%1" == "json" (
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the JSON files.
goto end
)
if "%1" == "htmlhelp" (
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run HTML Help Workshop with the ^
.hhp project file in %BUILDDIR%/htmlhelp.
goto end
)
if "%1" == "qthelp" (
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run "qcollectiongenerator" with the ^
.qhcp project file in %BUILDDIR%/qthelp, like this:
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\zopeinterface.qhcp
echo.To view the help file:
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\zopeinterface.ghc
goto end
)
if "%1" == "devhelp" (
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished.
goto end
)
if "%1" == "epub" (
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The epub file is in %BUILDDIR%/epub.
goto end
)
if "%1" == "latex" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
if errorlevel 1 exit /b 1
echo.
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "text" (
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The text files are in %BUILDDIR%/text.
goto end
)
if "%1" == "man" (
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The manual pages are in %BUILDDIR%/man.
goto end
)
if "%1" == "texinfo" (
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
goto end
)
if "%1" == "gettext" (
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
goto end
)
if "%1" == "changes" (
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
if errorlevel 1 exit /b 1
echo.
echo.The overview file is in %BUILDDIR%/changes.
goto end
)
if "%1" == "linkcheck" (
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
if errorlevel 1 exit /b 1
echo.
echo.Link check complete; look for any errors in the above output ^
or in %BUILDDIR%/linkcheck/output.txt.
goto end
)
if "%1" == "doctest" (
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
if errorlevel 1 exit /b 1
echo.
echo.Testing of doctests in the sources finished, look at the ^
results in %BUILDDIR%/doctest/output.txt.
goto end
)
:end

@ -0,0 +1,10 @@
[nosetests]
nocapture=1
cover-package=zope.interface
cover-erase=1
with-doctest=0
where=src
[aliases]
dev = develop easy_install zope.interface[testing]
docs = easy_install zope.interface[docs]

@ -61,14 +61,18 @@ else:
features = {}
else:
features = {'codeoptimization': codeoptimization}
tests_require = ['zope.event']
testing_extras = tests_require + ['nose', 'coverage']
extra = dict(
namespace_packages=["zope"],
include_package_data = True,
zip_safe = False,
tests_require = ['zope.event'],
tests_require = tests_require,
install_requires = ['setuptools'],
extras_require={'docs': ['z3c.recipe.sphinxdoc'],
'test': ['zope.event']},
extras_require={'docs': ['Sphinx'],
'test': tests_require,
'testing': testing_extras,
},
features = features
)
@ -87,16 +91,6 @@ try: # Zope setuptools versions
extra['install_requires'] = ['setuptools']
extra['setup_requires'] = ['zope.fixers']
extra['use_2to3'] = True
extra['convert_2to3_doctests'] = [
'src/zope/interface/README.ru.txt',
'src/zope/interface/README.txt',
'src/zope/interface/adapter.ru.txt',
'src/zope/interface/adapter.txt',
'src/zope/interface/human.ru.txt',
'src/zope/interface/human.txt',
'src/zope/interface/index.txt',
'src/zope/interface/verify.txt',
]
extra['use_2to3_fixers'] = ['zope.fixers']
except (ImportError, SyntaxError):

@ -50,23 +50,33 @@ See the module doc strings for more information.
"""
__docformat__ = 'restructuredtext'
from zope.interface.interface import Interface, _wire
from zope.interface.interface import Interface
from zope.interface.interface import _wire
# Need to actually get the interface elements to implement the right interfaces
_wire()
del _wire
from zope.interface.interface import Attribute, invariant, taggedValue
from zope.interface.declarations import providedBy, implementedBy
from zope.interface.declarations import classImplements, classImplementsOnly
from zope.interface.declarations import directlyProvidedBy, directlyProvides
from zope.interface.declarations import alsoProvides, provider
from zope.interface.declarations import implementer, implementer_only
from zope.interface.declarations import implements, implementsOnly
from zope.interface.declarations import classProvides, moduleProvides
from zope.interface.declarations import noLongerProvides, Declaration
from zope.interface.declarations import Declaration
from zope.interface.declarations import alsoProvides
from zope.interface.declarations import classImplements
from zope.interface.declarations import classImplementsOnly
from zope.interface.declarations import classProvides
from zope.interface.declarations import directlyProvidedBy
from zope.interface.declarations import directlyProvides
from zope.interface.declarations import implementedBy
from zope.interface.declarations import implementer
from zope.interface.declarations import implementer_only
from zope.interface.declarations import implements
from zope.interface.declarations import implementsOnly
from zope.interface.declarations import moduleProvides
from zope.interface.declarations import noLongerProvides
from zope.interface.declarations import providedBy
from zope.interface.declarations import provider
from zope.interface.exceptions import Invalid
from zope.interface.interface import Attribute
from zope.interface.interface import invariant
from zope.interface.interface import taggedValue
# The following are to make spec pickles cleaner
from zope.interface.declarations import Provides

@ -979,7 +979,13 @@ _lookup1(lookup *self,
Py_DECREF(tup);
}
else
Py_INCREF(result);
{
if (result == Py_None && default_ != NULL)
{
result = default_;
}
Py_INCREF(result);
}
return result;
}

@ -13,11 +13,12 @@
##############################################################################
"""Adapter management
"""
import weakref
from zope.interface import providedBy, Interface, ro
_marker = object
from zope.interface import providedBy
from zope.interface import Interface
from zope.interface import ro
class BaseAdapterRegistry(object):
# List of methods copied from lookup sub-objects:
@ -62,7 +63,7 @@ class BaseAdapterRegistry(object):
# Invalidating registries have caches that are invalidated
# when they or their base registies change. An invalidating
# registry can only have invalidating registries as bases.
# See LookupBasePy below for the pertinent logic.
# See LookupBaseFallback below for the pertinent logic.
# Verifying registies can't rely on getting invalidation messages,
# so have to check the generations of base registries to determine
@ -245,7 +246,8 @@ class BaseAdapterRegistry(object):
old = components.get(u'')
if not old:
return
# this is belt-and-suspenders against the failure of cleanup below
return #pragma NO COVERAGE
if value is None:
new = ()
@ -285,14 +287,14 @@ class BaseAdapterRegistry(object):
# XXX hack to fake out twisted's use of a private api. We need to get them
# to use the new registed method.
def get(self, _):
def get(self, _): #pragma NO COVER
class XXXTwistedFakeOut:
selfImplied = {}
return XXXTwistedFakeOut
_not_in_mapping = object()
class LookupBasePy(object):
class LookupBaseFallback(object):
def __init__(self):
self._cache = {}
@ -393,12 +395,22 @@ class LookupBasePy(object):
return result
LookupBase = LookupBasePy
LookupBasePy = LookupBaseFallback # BBB
try:
from _zope_interface_coptimizations import LookupBase
except ImportError: #pragma NO COVER
LookupBase = LookupBaseFallback
class VerifyingBasePy(LookupBasePy):
class VerifyingBaseFallback(LookupBaseFallback):
# Mixin for lookups against registries which "chain" upwards, and
# whose lookups invalidate their own caches whenever a parent registry
# bumps its own '_generation' counter. E.g., used by
# zope.component.persistentregistry
def changed(self, originally_changed):
LookupBasePy.changed(self, originally_changed)
LookupBaseFallback.changed(self, originally_changed)
self._verify_ro = self._registry.ro[1:]
self._verify_generations = [r._generation for r in self._verify_ro]
@ -409,25 +421,23 @@ class VerifyingBasePy(LookupBasePy):
def _getcache(self, provided, name):
self._verify()
return LookupBasePy._getcache(self, provided, name)
return LookupBaseFallback._getcache(self, provided, name)
def lookupAll(self, required, provided):
self._verify()
return LookupBasePy.lookupAll(self, required, provided)
return LookupBaseFallback.lookupAll(self, required, provided)
def subscriptions(self, required, provided):
self._verify()
return LookupBasePy.subscriptions(self, required, provided)
VerifyingBase = VerifyingBasePy
return LookupBaseFallback.subscriptions(self, required, provided)
VerifyingBasePy = VerifyingBaseFallback #BBB
try:
import _zope_interface_coptimizations
except ImportError:
pass
else:
from _zope_interface_coptimizations import LookupBase, VerifyingBase
from _zope_interface_coptimizations import VerifyingBase
except ImportError: #pragma NO COVER
VerifyingBase = VerifyingBaseFallback
class AdapterLookupBase(object):

@ -29,7 +29,7 @@ from types import FunctionType
try:
from types import ClassType
__python3 = False
except ImportError:
except ImportError: #pragma NO COVER
__python3 = True
import sys
@ -63,7 +63,7 @@ def getFrameInfo(frame):
kind = "class"
elif not sameNamespace:
kind = "function call"
else:
else: # pragma NO COVER
# How can you have f_locals is f_globals, and have '__module__' set?
# This is probably module-level code, but with a '__module__' variable.
kind = "unknown"
@ -106,7 +106,7 @@ def addClassAdvisor(callback, depth=2):
# )
previousMetaclass = caller_locals.get('__metaclass__')
if __python3:
if __python3: # pragma NO COVER
defaultMetaclass = caller_globals.get('__metaclass__', type)
else:
defaultMetaclass = caller_globals.get('__metaclass__', ClassType)
@ -167,7 +167,7 @@ def determineMetaclass(bases, explicit_mc=None):
candidates = minimalBases(meta) # minimal set of metaclasses
if not candidates:
if not candidates: #pragma NO COVER
# they're all "classic" classes
assert(not __python3) # This should not happen under Python 3
return ClassType

@ -77,14 +77,14 @@ classImplements(OSError, IOSError)
classImplements(OverflowError, IOverflowError)
try:
classImplements(OverflowWarning, IOverflowWarning)
except NameError:
except NameError: #pragma NO COVER
pass # OverflowWarning was removed in Python 2.5
classImplements(ReferenceError, IReferenceError)
classImplements(RuntimeError, IRuntimeError)
classImplements(RuntimeWarning, IRuntimeWarning)
try:
classImplements(StandardError, IStandardError)
except NameError:
except NameError: #pragma NO COVER
pass # StandardError does not exist in Python 3
classImplements(StopIteration, IStopIteration)
classImplements(SyntaxError, ISyntaxError)

@ -27,11 +27,15 @@ There are three flavors of declarations:
__docformat__ = 'restructuredtext'
import sys
from types import FunctionType
from types import MethodType
from types import ModuleType
import weakref
from zope.interface.interface import InterfaceClass, Specification
from zope.interface.interface import SpecificationBase
from types import ModuleType, MethodType, FunctionType
from zope.interface.advice import addClassAdvisor
from zope.interface.interface import InterfaceClass
from zope.interface.interface import SpecificationBase
from zope.interface.interface import Specification
# Registry of class-implementation specifications
BuiltinImplementationSpecifications = {}
@ -760,7 +764,7 @@ Provides.__safe_for_unpickling__ = True
try:
from types import ClassType
DescriptorAwareMetaClasses = ClassType, type
except ImportError: # Python 3
except ImportError: #pragma NO COVERAGE (Python 3)
DescriptorAwareMetaClasses = (type,)
def directlyProvides(object, *interfaces):
@ -973,7 +977,7 @@ def noLongerProvides(object, interface):
if interface.providedBy(object):
raise ValueError("Can only remove directly provided interfaces.")
class ClassProvidesBasePy(object):
class ClassProvidesBaseFallback(object):
def __get__(self, inst, cls):
if cls is self._cls:
@ -988,14 +992,15 @@ class ClassProvidesBasePy(object):
raise AttributeError('__provides__')
ClassProvidesBase = ClassProvidesBasePy
ClassProvidesBasePy = ClassProvidesBaseFallback # BBB
ClassProvidesBase = ClassProvidesBaseFallback
# Try to get C base:
try:
import _zope_interface_coptimizations
except ImportError:
except ImportError: #pragma NO COVERAGE
pass
else:
else: #pragma NO COVERAGE
from _zope_interface_coptimizations import ClassProvidesBase
@ -1185,6 +1190,8 @@ def moduleProvides(*interfaces):
#
# Declaration querying support
# XXX: is this a fossil? Nobody calls it, no unit tests exercise it, no
# doctests import it, and the package __init__ doesn't import it.
def ObjectSpecification(direct, cls):
"""Provide object specifications
@ -1251,9 +1258,9 @@ def ObjectSpecification(direct, cls):
1
"""
return Provides(cls, direct)
return Provides(cls, direct) #pragma NO COVER fossil
def getObjectSpecification(ob):
def getObjectSpecificationFallback(ob):
provides = getattr(ob, '__provides__', None)
if provides is not None:
@ -1268,7 +1275,9 @@ def getObjectSpecification(ob):
return implementedBy(cls)
def providedBy(ob):
getObjectSpecification = getObjectSpecificationFallback
def providedByFallback(ob):
# Here we have either a special object, an old-style declaration
# or a descriptor
@ -1317,8 +1326,9 @@ def providedBy(ob):
return implementedBy(ob.__class__)
return r
providedBy = providedByFallback
class ObjectSpecificationDescriptorPy(object):
class ObjectSpecificationDescriptorFallback(object):
"""Implement the `__providedBy__` attribute
The `__providedBy__` attribute computes the interfaces peovided by
@ -1357,7 +1367,7 @@ class ObjectSpecificationDescriptorPy(object):
return implementedBy(cls)
ObjectSpecificationDescriptor = ObjectSpecificationDescriptorPy
ObjectSpecificationDescriptor = ObjectSpecificationDescriptorFallback
##############################################################################
@ -1385,10 +1395,11 @@ _empty = Declaration()
try:
import _zope_interface_coptimizations
except ImportError:
except ImportError: #pragma NO COVER
pass
else:
from _zope_interface_coptimizations import implementedBy, providedBy
from _zope_interface_coptimizations import implementedBy
from _zope_interface_coptimizations import providedBy
from _zope_interface_coptimizations import getObjectSpecification
from _zope_interface_coptimizations import ObjectSpecificationDescriptor

@ -163,7 +163,7 @@ class SpecificationBasePy(object):
SpecificationBase = SpecificationBasePy
try:
from _zope_interface_coptimizations import SpecificationBase
except ImportError:
except ImportError: #pragma NO COVER
pass
_marker = object()
@ -204,14 +204,14 @@ class InterfaceBasePy(object):
InterfaceBase = InterfaceBasePy
try:
from _zope_interface_coptimizations import InterfaceBase
except ImportError:
except ImportError: #pragma NO COVER
pass
adapter_hooks = []
try:
from _zope_interface_coptimizations import adapter_hooks
except ImportError:
except ImportError: #pragma NO COVER
pass
@ -224,7 +224,7 @@ class Specification(SpecificationBase):
This class is a base class for both interfaces themselves and for
interface specifications (declarations).
Specifications are mutable. If you reassign their cases, their
Specifications are mutable. If you reassign their bases, their
relations with other specifications are adjusted accordingly.
For example:
@ -450,7 +450,7 @@ class InterfaceClass(Element, InterfaceBase, Specification):
# This is how cPython figures out the module of
# a class, but of course it does it in C. :-/
__module__ = sys._getframe(1).f_globals['__name__']
except (AttributeError, KeyError):
except (AttributeError, KeyError): #pragma NO COVERAGE
pass
self.__module__ = __module__
@ -605,9 +605,10 @@ class InterfaceClass(Element, InterfaceBase, Specification):
if errors:
raise Invalid(errors)
def _getInterface(self, ob, name):
"""Retrieve a named interface."""
return None
#XXX I believe this is a fossil: nobody calls it anywhere.
#def _getInterface(self, ob, name):
# """Retrieve a named interface."""
# return None
def __d(self, klass):
for k, v in self.__attrs.items():
@ -632,7 +633,7 @@ class InterfaceClass(Element, InterfaceBase, Specification):
def _call_conform(self, conform):
try:
return conform(self)
except TypeError:
except TypeError: #pragma NO COVER
# We got a TypeError. It might be an error raised by
# the __conform__ implementation, or *we* may have
# made the TypeError by calling an unbound method
@ -646,12 +647,12 @@ class InterfaceClass(Element, InterfaceBase, Specification):
raise
# This clever trick is from Phillip Eby
return None
return None #pragma NO COVER
def __reduce__(self):
return self.__name__
def __cmp(self, o1, o2):
def __cmp(self, other):
# Yes, I did mean to name this __cmp, rather than __cmp__.
# It is a private method used by __lt__ and __gt__.
# I don't want to override __eq__ because I want the default
@ -673,46 +674,44 @@ class InterfaceClass(Element, InterfaceBase, Specification):
sort before None.
"""
if o1 is None:
return 1
if o2 is None:
if other is None:
return -1
n1 = (getattr(o1, '__name__', ''), getattr(o1, '__module__', ''))
n2 = (getattr(o2, '__name__', ''), getattr(o2, '__module__', ''))
n1 = (getattr(self, '__name__', ''), getattr(self, '__module__', ''))
n2 = (getattr(other, '__name__', ''), getattr(other, '__module__', ''))
# This spelling works under Python3, which doesn't have cmp().
return (n1 > n2) - (n1 < n2)
def __hash__(self):
d = self.__dict__
if '__module__' not in d or '__name__' not in d:
if '__module__' not in d or '__name__' not in d: #pragma NO COVER
warnings.warn('Hashing uninitialized InterfaceClass instance')
return 1
return hash((self.__name__, self.__module__))
def __eq__(self, other):
c = self.__cmp(self, other)
c = self.__cmp(other)
return c == 0
def __ne__(self, other):
c = self.__cmp(self, other)
c = self.__cmp(other)
return c != 0
def __lt__(self, other):
c = self.__cmp(self, other)
c = self.__cmp(other)
return c < 0
def __le__(self, other):
c = self.__cmp(self, other)
c = self.__cmp(other)
return c <= 0
def __gt__(self, other):
c = self.__cmp(self, other)
c = self.__cmp(other)
return c > 0
def __ge__(self, other):
c = self.__cmp(self, other)
c = self.__cmp(other)
return c >= 0
@ -742,6 +741,18 @@ class Method(Attribute):
#
# implements(IMethod)
positional = required = ()
_optional = varargs = kwargs = None
def _get_optional(self):
if self._optional is None:
return {}
return self._optional
def _set_optional(self, opt):
self._optional = opt
def _del_optional(self):
self._optional = None
optional = property(_get_optional, _set_optional, _del_optional)
def __call__(self, *args, **kw):
raise BrokenImplementation(self.interface, self.__name__)
@ -758,7 +769,7 @@ class Method(Attribute):
for v in self.positional:
sig.append(v)
if v in self.optional.keys():
sig[-1] += "=" + `self.optional[v]`
sig[-1] += "=" + repr(self.optional[v])
if self.varargs:
sig.append("*" + self.varargs)
if self.kwargs:

@ -18,7 +18,7 @@ import types
try:
from zope.event import notify
except ImportError:
except ImportError: #pragma NO COVER
def notify(*arg, **kw): pass
from zope.interface.interfaces import ISpecification
@ -40,7 +40,7 @@ from zope.interface.declarations import implementer # required by py3k fixers
from zope.interface.declarations import implementer_only # req by py3k fixers
from zope.interface.adapter import AdapterRegistry
if sys.version_info[0] == 3:
if sys.version_info[0] == 3: #pragma NO COVER
def _u(s):
return s
class_types = type

@ -30,7 +30,7 @@ def mergeOrderings(orderings, seen=None):
For example:
>>> _mergeOrderings([