././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1739527947.5183442 zope_testing-5.1/0000755000076600000240000000000014753613414013604 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/.pre-commit-config.yaml0000644000076600000240000000132614753613412020065 0ustar00m.howitzstaff# Generated from: # https://github.com/zopefoundation/meta/tree/master/config/pure-python minimum_pre_commit_version: '3.6' repos: - repo: https://github.com/pycqa/isort rev: "6.0.0" hooks: - id: isort - repo: https://github.com/hhatto/autopep8 rev: "v2.3.2" hooks: - id: autopep8 args: [--in-place, --aggressive, --aggressive] - repo: https://github.com/asottile/pyupgrade rev: v3.19.1 hooks: - id: pyupgrade args: [--py39-plus] - repo: https://github.com/isidentical/teyit rev: 0.4.3 hooks: - id: teyit - repo: https://github.com/PyCQA/flake8 rev: "7.1.1" hooks: - id: flake8 additional_dependencies: - flake8-debugger == 4.1.2 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/.readthedocs.yaml0000644000076600000240000000123514753613412017032 0ustar00m.howitzstaff# Generated from: # https://github.com/zopefoundation/meta/tree/master/config/pure-python # Read the Docs configuration file # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details # Required version: 2 # Set the version of Python and other tools you might need build: os: ubuntu-22.04 tools: python: "3.11" # Build documentation in the docs/ directory with Sphinx sphinx: configuration: docs/conf.py # We recommend specifying your dependencies to enable reproducible builds: # https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html python: install: - requirements: docs/requirements.txt - method: pip path: . ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/CHANGES.rst0000644000076600000240000003655314753613412015420 0ustar00m.howitzstaff========= Changes ========= 5.1 (2025-02-14) ================ - Drop support for Python 3.7, 3.8. - Add support for Python 3.12, 3.13. 5.0.1 (2022-12-20) ================== - Make wheels no longer universal. 5.0 (2022-12-20) ================ Backwards incompatible changes ------------------------------ - Drop support for Python 2.7, 3.5, 3.6. - Drop modules which do not seem to be Python compatible: + ``zope.testing.loghandler`` + ``zope.testing.server`` - Drop doctest option ``IGNORE_EXCEPTION_MODULE_IN_PYTHON2``. - Remove functions: + ``zope.testing.renormalizing.strip_dottedname_from_traceback`` + ``zope.testing.renormalizing.is_dotted_name`` Features -------- - Add support for Python 3.11. 4.10 (2022-03-07) ================= - Show deprecation warnings when importing modules which are not ported to Python 3. - Improve test coverage. - Port ``zope.testing.formparser`` to Python 3. - Add support for Python 3.10. 4.9 (2021-01-08) ================ - Make ``setupstack.txt`` test work again if the current directory is empty. 4.8 (2021-01-04) ================ - Add support for Python 3.8 and 3.9. - Drop support for Python 3.3 and 3.4. - Extend IGNORE_EXCEPTION_MODULE_IN_PYTHON2 to cover also exceptions without arguments (thus without a colon on the last line of the traceback output). 4.7 (2018-10-04) ================ - Added support for Python 3.7. 4.6.2 (2017-06-12) ================== - Remove dependencies on ``zope.interface`` and ``zope.exceptions``; they're not used here. - Remove use of 2to3 for outdated versions of PyPy3, letting us build universal wheels. 4.6.1 (2017-01-04) ================== - Add support for Python 3.6. 4.6.0 (2016-10-20) ================== - Introduce option flag ``IGNORE_EXCEPTION_MODULE_IN_PYTHON2`` to normalize exception class names in traceback output. In Python 3 they are displayed as the full dotted name. In Python 2 they are displayed as "just" the class name. When running doctests in Python 3, the option flag will not have any effect, however when running the same test in Python 2, the segments in the full dotted name leading up to the class name are stripped away from the "expected" string. - Drop support for Python 2.6 and 3.2. - Add support for Python 3.5. - Cleaned up useless 2to3 conversion. 4.5.0 (2015-09-02) ================== - Added meta data for test case methods created with ``zope.testing.doctestcase``. - Reasonable values for ``__name__``, making sure that ``__name__`` starts with ``test``. - For ``doctestfile`` methods, provide ``filename`` and ``filepath`` attributes. The meta data us useful, for example, for selecting tests with the nose attribute mechanism. - Added ``doctestcase.doctestfiles`` - Define multiple doctest files at once. - Automatically assign test class members. So rather than:: class MYTests(unittest.TestCase): ... test_foo = doctestcase.doctestfile('foo.txt') You can use:: @doctestcase.doctestfiles('foo.txt', 'bar.txt', ...) class MYTests(unittest.TestCase): ... 4.4.0 (2015-07-16) ================== - Added ``zope.testing.setupstack.mock`` as a convenience function for setting up mocks in tests. (The Python ``mock`` package must be in the path for this to work. The excellent ``mock`` package isn't a dependency of ``zope.testing``.) - Added the base class ``zope.testing.setupstack.TestCase`` to make it much easier to use ``zope.testing.setupstack`` in ``unittest`` test cases. 4.3.0 (2015-07-15) ================== - Added support for creating doctests as methods of ``unittest.TestCase`` classes so that they can found automatically by test runners, like *nose* that ignore test suites. 4.2.0 (2015-06-01) ================== - **Actually** remove long-deprecated ``zope.testing.doctest`` (announced as removed in 4.0.0) and ``zope.testing.doctestunit``. - Add support for PyPy and PyPy3. 4.1.3 (2014-03-19) ================== - Add support for Python 3.4. - Update ``boostrap.py`` to version 2.2. 4.1.2 (2013-02-19) ================== - Adjust Trove classifiers to reflect the currently supported Python versions. Officially drop Python 2.4 and 2.5. Add Python 3.3. - LP: #1055720: Fix failing test on Python 3.3 due to changed exception messaging. 4.1.1 (2012-02-01) ================== - Fix: Windows test failure. 4.1.0 (2012-01-29) ================== - Add context-manager support to ``zope.testing.setupstack`` - Make ``zope.testing.setupstack`` usable with all tests, not just doctests and added ``zope.testing.setupstack.globs``, which makes it easier to write test setup code that workes with doctests and other kinds of tests. - Add the ``wait`` module, which makes it easier to deal with non-deterministic timing issues. - Rename ``zope.testing.renormalizing.RENormalizing`` to ``zope.testing.renormalizing.OutputChecker``. The old name is an alias. - Update tests to run with Python 3. - Label more clearly which features are supported by Python 3. - Reorganize documentation. 4.0.0 (2011-11-09) ================== - Remove the deprecated ``zope.testing.doctest``. - Add Python 3 support. - Fix test which fails if there is a file named `Data.fs` in the current working directory. 3.10.2 (2010-11-30) =================== - Fix test of broken symlink handling to not break on Windows. 3.10.1 (2010-11-29) =================== - Fix removal of broken symlinks on Unix. 3.10.0 (2010-07-21) =================== - Remove ``zope.testing.testrunner``, which now is moved to zope.testrunner. - Update fix for LP #221151 to a spelling compatible with Python 2.4. 3.9.5 (2010-05-19) ================== - LP #579019: When layers are run in parallel, ensure that each ``tearDown`` is called, including the first layer which is run in the main thread. - Deprecate ``zope.testing.testrunner`` and ``zope.testing.exceptions``. They have been moved to a separate zope.testrunner module, and will be removed from zope.testing in 4.0.0, together with ``zope.testing.doctest``. 3.9.4 (2010-04-13) ================== - LP #560259: Fix subunit output formatter to handle layer setup errors. - LP #399394: Add a ``--stop-on-error`` / ``--stop`` / ``-x`` option to the testrunner. - LP #498162: Add a ``--pdb`` alias for the existing ``--post-mortem`` / ``-D`` option to the testrunner. - LP #547023: Add a ``--version`` option to the testrunner. - Add tests for LP #144569 and #69988. https://bugs.launchpad.net/bugs/69988 https://bugs.launchpad.net/zope3/+bug/144569 3.9.3 (2010-03-26) ================== - Remove import of ``zope.testing.doctest`` from ``zope.testing.renormalizer``. - Suppress output to ``sys.stderr`` in ``testrunner-layers-ntd.txt``. - Suppress ``zope.testing.doctest`` deprecation warning when running our own test suite. 3.9.2 (2010-03-15) ================== - Fix broken ``from zope.testing.doctest import *`` 3.9.1 (2010-03-15) ================== - No changes; reupload to fix broken 3.9.0 release on PyPI. 3.9.0 (2010-03-12) ================== - Modify the testrunner to use the standard Python ``doctest`` module instead of the deprecated ``zope.testing.doctest``. - Fix ``testrunner-leaks.txt`` to use the ``run_internal`` helper, so that ``sys.exit`` isn't triggered during the test run. - Add support for conditionally using a subunit-based output formatter upon request if subunit and testtools are available. Patch contributed by Jonathan Lange. 3.8.7 (2010-01-26) ================== - Downgrade the ``zope.testing.doctest`` deprecation warning into a PendingDeprecationWarning. 3.8.6 (2009-12-23) ================== - Add ``MANIFEST.in`` and reupload to fix broken 3.8.5 release on PyPI. 3.8.5 (2009-12-23) ================== - Add back ``DocFileSuite``, ``DocTestSuite``, ``debug_src`` and ``debug`` BBB imports back into ``zope.testing.doctestunit``; apparently many packages still import them from there! - Deprecate ``zope.testing.doctest`` and ``zope.testing.doctestunit`` in favor of the stdlib ``doctest`` module. 3.8.4 (2009-12-18) ================== - Fix missing imports and undefined variables reported by pyflakes, adding tests to exercise the blind spots. - Cleaned up unused imports reported by pyflakes. - Add two new options to generate randomly ordered list of tests and to select a specific order of tests. - Allow combining RENormalizing checkers via ``+`` now: ``checker1 + checker2`` creates a checker with the transformations of both checkers. - Fix tests under Python 2.7. 3.8.3 (2009-09-21) ================== - Fix test failures due to using ``split()`` on filenames when running from a directory with spaces in it. - Fix testrunner behavior on Windows for ``-j2`` (or greater) combined with ``-v`` (or greater). 3.8.2 (2009-09-15) ================== - Remove hotshot profiler when using Python 2.6. That makes zope.testing compatible with Python 2.6 3.8.1 (2009-08-12) ================== - Avoid hardcoding ``sys.argv[0]`` as script; allow, for instance, Zope 2's `bin/instance test` (LP#407916). - Produce a clear error message when a subprocess doesn't follow the ``zope.testing.testrunner`` protocol (LP#407916). - Avoid unnecessarily squelching verbose output in a subprocess when there are not multiple subprocesses. - Avoid unnecessarily batching subprocess output, which can stymie automated and human processes for identifying hung tests. - Include incremental output when there are multiple subprocesses and a verbosity of ``-vv`` or greater is requested. This again is not batched, supporting automated processes and humans looking for hung tests. 3.8.0 (2009-07-24) ================== - Allow testrunner to include descendants of ``unittest.TestCase`` in test modules, which no longer need to provide ``test_suite()``. 3.7.7 (2009-07-15) ================== - Clean up support for displaying tracebacks with supplements by turning it into an always-enabled feature and making the dependency on ``zope.exceptions`` explicit. - Fix #251759: prevent the testrunner descending into directories that aren't Python packages. - Code cleanups. 3.7.6 (2009-07-02) ================== - Add zope-testrunner ``console_scripts`` entry point. This exposes a ``zope-testrunner`` script with default installs allowing the testrunner to be run from the command line. 3.7.5 (2009-06-08) ================== - Fix bug when running subprocesses on Windows. - The option ``REPORT_ONLY_FIRST_FAILURE`` (command line option "-1") is now respected even when a doctest declares its own ``REPORTING_FLAGS``, such as ``REPORT_NDIFF``. - Fix bug that broke readline with pdb when using doctest (see http://bugs.python.org/issue5727). - Make tests pass on Windows and Linux at the same time. 3.7.4 (2009-05-01) ================== - Filenames of doctest examples now contain the line number and not only the example number. So a stack trace in pdb tells the exact line number of the current example. This fixes https://bugs.launchpad.net/bugs/339813 - Colorization of doctest output correctly handles blank lines. 3.7.3 (2009-04-22) ================== - Improve handling of rogue threads: always exit with status so even spinning daemon threads won't block the runner from exiting. This deprecated the ``--with-exit-status`` option. 3.7.2 (2009-04-13) ================== - Fix test failure on Python 2.4 due to slight difference in the way coverage is reported (__init__ files with only a single comment line are now not reported) - Fix bug that caused the test runner to hang when running subprocesses (as a result Python 2.3 is no longer supported). - Work around a bug in Python 2.6 (related to http://bugs.python.org/issue1303673) that causes the profile tests to fail. - Add explanitory notes to ``buildout.cfg`` about how to run the tests with multiple versions of Python 3.7.1 (2008-10-17) ================== - The ``setupstack`` temporary directory support now properly handles read-only files by making them writable before removing them. 3.7.0 (2008-09-22) ================== - Add alterate setuptools / distutils commands for running all tests using our testrunner. See 'zope.testing.testrunner.eggsupport:ftest'. - Add a setuptools-compatible test loader which skips tests with layers: the testrunner used by ``setup.py test`` doesn't know about them, and those tests then fail. See ``zope.testing.testrunner.eggsupport:SkipLayers``. - Add support for Jython, when a garbage collector call is sent. - Add support to bootstrap on Jython. - Fix NameError in StartUpFailure. - Open doctest files in universal mode, so that packages released on Windows can be tested on Linux, for example. 3.6.0 (2008-07-10) ================== - Add ``-j`` option to parallel tests run in subprocesses. - RENormalizer accepts plain Python callables. - Add ``--slow-test`` option. - Add ``--no-progress`` and ``--auto-progress`` options. - Complete refactoring of the test runner into multiple code files and a more modular (pipeline-like) architecture. - Unify unit tests with the layer support by introducing a real unit test layer. - Add a doctest for ``zope.testing.module``. There were several bugs that were fixed: * ``README.txt`` was a really bad default argument for the module name, as it is not a proper dotted name. The code would immediately fail as it would look for the ``txt`` module in the ``README`` package. The default is now ``__main__``. * The ``tearDown`` function did not clean up the ``__name__`` entry in the global dictionary. - Fix a bug that caused a SubprocessError to be generated if a subprocess sent any output to stderr. - Fix a bug that caused the unit tests to be skipped if run in a subprocess. 3.5.1 (2007-08-14) ================== - Invoke post-mortem debugging for layer-setup failures. 3.5.0 (2007-07-19) ================== - Ensure that the test runner works on Python 2.5. - Add support for ``cProfile``. - Add output colorizing (``-c`` option). - Add ``--hide-secondary-failures`` and ``--show-secondary-failures`` options (https://bugs.launchpad.net/zope3/+bug/115454). - Fix some problems with Unicode in doctests. - Fix "Error reading from subprocess" errors on Unix-like systems. 3.4 (2007-03-29) ================ - Add ``exit-with-status`` support (supports use with buildbot and ``zc.recipe.testing``) - Add a small framework for automating set up and tear down of doctest tests. See ``setupstack.txt``. - Allow ``testrunner-wo-source.txt`` and ``testrunner-errors.txt`` to run within a read-only source tree. 3.0 (2006-09-20) ================ - Update the doctest copy with text-file encoding support. - Add logging-level support to the ``loggingsuppport`` module. - At verbosity-level 1, dots are not output continuously, without any line breaks. - Improve output when the inability to tear down a layer causes tests to be run in a subprocess. - Make ``zope.exception`` required only if the ``zope_tracebacks`` extra is requested. - Fix the test coverage. If a module, for example `interfaces`, was in an ignored directory/package, then if a module of the same name existed in a covered directory/package, then it was also ignored there, because the ignore cache stored the result by module name and not the filename of the module. 2.0 (2006-01-05) ================ - Release a separate project corresponding to the version of ``zope.testing`` shipped as part of the Zope 3.2.0 release. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/CONTRIBUTING.md0000644000076600000240000000144314753613412016035 0ustar00m.howitzstaff # Contributing to zopefoundation projects The projects under the zopefoundation GitHub organization are open source and welcome contributions in different forms: * bug reports * code improvements and bug fixes * documentation improvements * pull request reviews For any changes in the repository besides trivial typo fixes you are required to sign the contributor agreement. See https://www.zope.dev/developer/becoming-a-committer.html for details. Please visit our [Developer Guidelines](https://www.zope.dev/developer/guidelines.html) if you'd like to contribute code changes and our [guidelines for reporting bugs](https://www.zope.dev/developer/reporting-bugs.html) if you want to file a bug report. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/COPYRIGHT.txt0000644000076600000240000000004014753613412015705 0ustar00m.howitzstaffZope Foundation and Contributors././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/LICENSE.txt0000644000076600000240000000402614753613412015427 0ustar00m.howitzstaffZope Public License (ZPL) Version 2.1 A copyright notice accompanies this license document that identifies the copyright holders. This license has been certified as open source. It has also been designated as GPL compatible by the Free Software Foundation (FSF). Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions in source code must retain the accompanying copyright notice, this list of conditions, and the following disclaimer. 2. Redistributions in binary form must reproduce the accompanying copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Names of the copyright holders must not be used to endorse or promote products derived from this software without prior written permission from the copyright holders. 4. The right to distribute this software or to use it for any purpose does not give you the right to use Servicemarks (sm) or Trademarks (tm) of the copyright holders. Use of them is covered by separate agreement with the copyright holders. 5. If any files are modified, you must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. Disclaimer THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/MANIFEST.in0000644000076600000240000000065714753613412015350 0ustar00m.howitzstaff# Generated from: # https://github.com/zopefoundation/meta/tree/master/config/pure-python include *.md include *.rst include *.txt include buildout.cfg include tox.ini include .pre-commit-config.yaml recursive-include docs *.py recursive-include docs *.rst recursive-include docs *.txt recursive-include docs Makefile recursive-include src *.py include *.yaml recursive-include src *.txt include .readthedocs.yml include tox.ini ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1739527947.5181942 zope_testing-5.1/PKG-INFO0000644000076600000240000004572314753613414014714 0ustar00m.howitzstaffMetadata-Version: 2.1 Name: zope.testing Version: 5.1 Summary: Zope testing helpers Home-page: https://github.com/zopefoundation/zope.testing Author: Zope Foundation and Contributors Author-email: zope-dev@zope.dev License: ZPL-2.1 Keywords: zope testing doctest RENormalizing OutputChecker timeout logging Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Zope Public License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: 3.13 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Framework :: Zope :: 3 Classifier: Framework :: Zope :: 4 Classifier: Framework :: Zope :: 5 Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Software Development :: Testing Requires-Python: >=3.9 License-File: LICENSE.txt Requires-Dist: setuptools Provides-Extra: test Requires-Dist: zope.testrunner; extra == "test" Provides-Extra: docs Requires-Dist: sphinx; extra == "docs" Requires-Dist: repoze.sphinx.autointerface; extra == "docs" Requires-Dist: zope.exceptions; extra == "docs" Requires-Dist: zope.interface; extra == "docs" ================= ``zope.testing`` ================= .. image:: https://img.shields.io/pypi/v/zope.testing.svg :target: https://pypi.python.org/pypi/zope.testing/ :alt: Latest Version .. image:: https://github.com/zopefoundation/zope.testing/actions/workflows/tests.yml/badge.svg :target: https://github.com/zopefoundation/zope.testing/actions/workflows/tests.yml .. image:: https://readthedocs.org/projects/zopetesting/badge/?version=latest :target: http://zopetesting.readthedocs.org/en/latest/ :alt: Documentation Status This package provides a number of testing frameworks. For complete documentation, see https://zopetesting.readthedocs.io cleanup Provides a mixin class for cleaning up after tests that make global changes. See `zope.testing.cleanup` formparser An HTML parser that extracts form information. This is intended to support functional tests that need to extract information from HTML forms returned by the publisher. See `zope.testing.formparser` loggingsupport Support for testing logging code If you want to test that your code generates proper log output, you can create and install a handler that collects output. See `zope.testing.loggingsupport` module Lets a doctest pretend to be a Python module. See `zope.testing.module` renormalizing Regular expression pattern normalizing output checker. Useful for doctests. See `zope.testing.renormalizing` setupstack A simple framework for automating doctest set-up and tear-down. See `zope.testing.setupstack` wait A small utility for dealing with timing non-determinism See `zope.testing.wait` doctestcase Support for defining doctests as methods of `unittest.TestCase` classes so that they can be more easily found by test runners, like nose, that ignore test suites. See `zope.testing.doctestcase` Getting started developing zope.testing ======================================= ``zope.testing`` uses ``tox``. To start, install ``tox`` using ``pip install tox``. Now, run ``tox`` to run the ``zope.testing`` test suite. ========= Changes ========= 5.1 (2025-02-14) ================ - Drop support for Python 3.7, 3.8. - Add support for Python 3.12, 3.13. 5.0.1 (2022-12-20) ================== - Make wheels no longer universal. 5.0 (2022-12-20) ================ Backwards incompatible changes ------------------------------ - Drop support for Python 2.7, 3.5, 3.6. - Drop modules which do not seem to be Python compatible: + ``zope.testing.loghandler`` + ``zope.testing.server`` - Drop doctest option ``IGNORE_EXCEPTION_MODULE_IN_PYTHON2``. - Remove functions: + ``zope.testing.renormalizing.strip_dottedname_from_traceback`` + ``zope.testing.renormalizing.is_dotted_name`` Features -------- - Add support for Python 3.11. 4.10 (2022-03-07) ================= - Show deprecation warnings when importing modules which are not ported to Python 3. - Improve test coverage. - Port ``zope.testing.formparser`` to Python 3. - Add support for Python 3.10. 4.9 (2021-01-08) ================ - Make ``setupstack.txt`` test work again if the current directory is empty. 4.8 (2021-01-04) ================ - Add support for Python 3.8 and 3.9. - Drop support for Python 3.3 and 3.4. - Extend IGNORE_EXCEPTION_MODULE_IN_PYTHON2 to cover also exceptions without arguments (thus without a colon on the last line of the traceback output). 4.7 (2018-10-04) ================ - Added support for Python 3.7. 4.6.2 (2017-06-12) ================== - Remove dependencies on ``zope.interface`` and ``zope.exceptions``; they're not used here. - Remove use of 2to3 for outdated versions of PyPy3, letting us build universal wheels. 4.6.1 (2017-01-04) ================== - Add support for Python 3.6. 4.6.0 (2016-10-20) ================== - Introduce option flag ``IGNORE_EXCEPTION_MODULE_IN_PYTHON2`` to normalize exception class names in traceback output. In Python 3 they are displayed as the full dotted name. In Python 2 they are displayed as "just" the class name. When running doctests in Python 3, the option flag will not have any effect, however when running the same test in Python 2, the segments in the full dotted name leading up to the class name are stripped away from the "expected" string. - Drop support for Python 2.6 and 3.2. - Add support for Python 3.5. - Cleaned up useless 2to3 conversion. 4.5.0 (2015-09-02) ================== - Added meta data for test case methods created with ``zope.testing.doctestcase``. - Reasonable values for ``__name__``, making sure that ``__name__`` starts with ``test``. - For ``doctestfile`` methods, provide ``filename`` and ``filepath`` attributes. The meta data us useful, for example, for selecting tests with the nose attribute mechanism. - Added ``doctestcase.doctestfiles`` - Define multiple doctest files at once. - Automatically assign test class members. So rather than:: class MYTests(unittest.TestCase): ... test_foo = doctestcase.doctestfile('foo.txt') You can use:: @doctestcase.doctestfiles('foo.txt', 'bar.txt', ...) class MYTests(unittest.TestCase): ... 4.4.0 (2015-07-16) ================== - Added ``zope.testing.setupstack.mock`` as a convenience function for setting up mocks in tests. (The Python ``mock`` package must be in the path for this to work. The excellent ``mock`` package isn't a dependency of ``zope.testing``.) - Added the base class ``zope.testing.setupstack.TestCase`` to make it much easier to use ``zope.testing.setupstack`` in ``unittest`` test cases. 4.3.0 (2015-07-15) ================== - Added support for creating doctests as methods of ``unittest.TestCase`` classes so that they can found automatically by test runners, like *nose* that ignore test suites. 4.2.0 (2015-06-01) ================== - **Actually** remove long-deprecated ``zope.testing.doctest`` (announced as removed in 4.0.0) and ``zope.testing.doctestunit``. - Add support for PyPy and PyPy3. 4.1.3 (2014-03-19) ================== - Add support for Python 3.4. - Update ``boostrap.py`` to version 2.2. 4.1.2 (2013-02-19) ================== - Adjust Trove classifiers to reflect the currently supported Python versions. Officially drop Python 2.4 and 2.5. Add Python 3.3. - LP: #1055720: Fix failing test on Python 3.3 due to changed exception messaging. 4.1.1 (2012-02-01) ================== - Fix: Windows test failure. 4.1.0 (2012-01-29) ================== - Add context-manager support to ``zope.testing.setupstack`` - Make ``zope.testing.setupstack`` usable with all tests, not just doctests and added ``zope.testing.setupstack.globs``, which makes it easier to write test setup code that workes with doctests and other kinds of tests. - Add the ``wait`` module, which makes it easier to deal with non-deterministic timing issues. - Rename ``zope.testing.renormalizing.RENormalizing`` to ``zope.testing.renormalizing.OutputChecker``. The old name is an alias. - Update tests to run with Python 3. - Label more clearly which features are supported by Python 3. - Reorganize documentation. 4.0.0 (2011-11-09) ================== - Remove the deprecated ``zope.testing.doctest``. - Add Python 3 support. - Fix test which fails if there is a file named `Data.fs` in the current working directory. 3.10.2 (2010-11-30) =================== - Fix test of broken symlink handling to not break on Windows. 3.10.1 (2010-11-29) =================== - Fix removal of broken symlinks on Unix. 3.10.0 (2010-07-21) =================== - Remove ``zope.testing.testrunner``, which now is moved to zope.testrunner. - Update fix for LP #221151 to a spelling compatible with Python 2.4. 3.9.5 (2010-05-19) ================== - LP #579019: When layers are run in parallel, ensure that each ``tearDown`` is called, including the first layer which is run in the main thread. - Deprecate ``zope.testing.testrunner`` and ``zope.testing.exceptions``. They have been moved to a separate zope.testrunner module, and will be removed from zope.testing in 4.0.0, together with ``zope.testing.doctest``. 3.9.4 (2010-04-13) ================== - LP #560259: Fix subunit output formatter to handle layer setup errors. - LP #399394: Add a ``--stop-on-error`` / ``--stop`` / ``-x`` option to the testrunner. - LP #498162: Add a ``--pdb`` alias for the existing ``--post-mortem`` / ``-D`` option to the testrunner. - LP #547023: Add a ``--version`` option to the testrunner. - Add tests for LP #144569 and #69988. https://bugs.launchpad.net/bugs/69988 https://bugs.launchpad.net/zope3/+bug/144569 3.9.3 (2010-03-26) ================== - Remove import of ``zope.testing.doctest`` from ``zope.testing.renormalizer``. - Suppress output to ``sys.stderr`` in ``testrunner-layers-ntd.txt``. - Suppress ``zope.testing.doctest`` deprecation warning when running our own test suite. 3.9.2 (2010-03-15) ================== - Fix broken ``from zope.testing.doctest import *`` 3.9.1 (2010-03-15) ================== - No changes; reupload to fix broken 3.9.0 release on PyPI. 3.9.0 (2010-03-12) ================== - Modify the testrunner to use the standard Python ``doctest`` module instead of the deprecated ``zope.testing.doctest``. - Fix ``testrunner-leaks.txt`` to use the ``run_internal`` helper, so that ``sys.exit`` isn't triggered during the test run. - Add support for conditionally using a subunit-based output formatter upon request if subunit and testtools are available. Patch contributed by Jonathan Lange. 3.8.7 (2010-01-26) ================== - Downgrade the ``zope.testing.doctest`` deprecation warning into a PendingDeprecationWarning. 3.8.6 (2009-12-23) ================== - Add ``MANIFEST.in`` and reupload to fix broken 3.8.5 release on PyPI. 3.8.5 (2009-12-23) ================== - Add back ``DocFileSuite``, ``DocTestSuite``, ``debug_src`` and ``debug`` BBB imports back into ``zope.testing.doctestunit``; apparently many packages still import them from there! - Deprecate ``zope.testing.doctest`` and ``zope.testing.doctestunit`` in favor of the stdlib ``doctest`` module. 3.8.4 (2009-12-18) ================== - Fix missing imports and undefined variables reported by pyflakes, adding tests to exercise the blind spots. - Cleaned up unused imports reported by pyflakes. - Add two new options to generate randomly ordered list of tests and to select a specific order of tests. - Allow combining RENormalizing checkers via ``+`` now: ``checker1 + checker2`` creates a checker with the transformations of both checkers. - Fix tests under Python 2.7. 3.8.3 (2009-09-21) ================== - Fix test failures due to using ``split()`` on filenames when running from a directory with spaces in it. - Fix testrunner behavior on Windows for ``-j2`` (or greater) combined with ``-v`` (or greater). 3.8.2 (2009-09-15) ================== - Remove hotshot profiler when using Python 2.6. That makes zope.testing compatible with Python 2.6 3.8.1 (2009-08-12) ================== - Avoid hardcoding ``sys.argv[0]`` as script; allow, for instance, Zope 2's `bin/instance test` (LP#407916). - Produce a clear error message when a subprocess doesn't follow the ``zope.testing.testrunner`` protocol (LP#407916). - Avoid unnecessarily squelching verbose output in a subprocess when there are not multiple subprocesses. - Avoid unnecessarily batching subprocess output, which can stymie automated and human processes for identifying hung tests. - Include incremental output when there are multiple subprocesses and a verbosity of ``-vv`` or greater is requested. This again is not batched, supporting automated processes and humans looking for hung tests. 3.8.0 (2009-07-24) ================== - Allow testrunner to include descendants of ``unittest.TestCase`` in test modules, which no longer need to provide ``test_suite()``. 3.7.7 (2009-07-15) ================== - Clean up support for displaying tracebacks with supplements by turning it into an always-enabled feature and making the dependency on ``zope.exceptions`` explicit. - Fix #251759: prevent the testrunner descending into directories that aren't Python packages. - Code cleanups. 3.7.6 (2009-07-02) ================== - Add zope-testrunner ``console_scripts`` entry point. This exposes a ``zope-testrunner`` script with default installs allowing the testrunner to be run from the command line. 3.7.5 (2009-06-08) ================== - Fix bug when running subprocesses on Windows. - The option ``REPORT_ONLY_FIRST_FAILURE`` (command line option "-1") is now respected even when a doctest declares its own ``REPORTING_FLAGS``, such as ``REPORT_NDIFF``. - Fix bug that broke readline with pdb when using doctest (see http://bugs.python.org/issue5727). - Make tests pass on Windows and Linux at the same time. 3.7.4 (2009-05-01) ================== - Filenames of doctest examples now contain the line number and not only the example number. So a stack trace in pdb tells the exact line number of the current example. This fixes https://bugs.launchpad.net/bugs/339813 - Colorization of doctest output correctly handles blank lines. 3.7.3 (2009-04-22) ================== - Improve handling of rogue threads: always exit with status so even spinning daemon threads won't block the runner from exiting. This deprecated the ``--with-exit-status`` option. 3.7.2 (2009-04-13) ================== - Fix test failure on Python 2.4 due to slight difference in the way coverage is reported (__init__ files with only a single comment line are now not reported) - Fix bug that caused the test runner to hang when running subprocesses (as a result Python 2.3 is no longer supported). - Work around a bug in Python 2.6 (related to http://bugs.python.org/issue1303673) that causes the profile tests to fail. - Add explanitory notes to ``buildout.cfg`` about how to run the tests with multiple versions of Python 3.7.1 (2008-10-17) ================== - The ``setupstack`` temporary directory support now properly handles read-only files by making them writable before removing them. 3.7.0 (2008-09-22) ================== - Add alterate setuptools / distutils commands for running all tests using our testrunner. See 'zope.testing.testrunner.eggsupport:ftest'. - Add a setuptools-compatible test loader which skips tests with layers: the testrunner used by ``setup.py test`` doesn't know about them, and those tests then fail. See ``zope.testing.testrunner.eggsupport:SkipLayers``. - Add support for Jython, when a garbage collector call is sent. - Add support to bootstrap on Jython. - Fix NameError in StartUpFailure. - Open doctest files in universal mode, so that packages released on Windows can be tested on Linux, for example. 3.6.0 (2008-07-10) ================== - Add ``-j`` option to parallel tests run in subprocesses. - RENormalizer accepts plain Python callables. - Add ``--slow-test`` option. - Add ``--no-progress`` and ``--auto-progress`` options. - Complete refactoring of the test runner into multiple code files and a more modular (pipeline-like) architecture. - Unify unit tests with the layer support by introducing a real unit test layer. - Add a doctest for ``zope.testing.module``. There were several bugs that were fixed: * ``README.txt`` was a really bad default argument for the module name, as it is not a proper dotted name. The code would immediately fail as it would look for the ``txt`` module in the ``README`` package. The default is now ``__main__``. * The ``tearDown`` function did not clean up the ``__name__`` entry in the global dictionary. - Fix a bug that caused a SubprocessError to be generated if a subprocess sent any output to stderr. - Fix a bug that caused the unit tests to be skipped if run in a subprocess. 3.5.1 (2007-08-14) ================== - Invoke post-mortem debugging for layer-setup failures. 3.5.0 (2007-07-19) ================== - Ensure that the test runner works on Python 2.5. - Add support for ``cProfile``. - Add output colorizing (``-c`` option). - Add ``--hide-secondary-failures`` and ``--show-secondary-failures`` options (https://bugs.launchpad.net/zope3/+bug/115454). - Fix some problems with Unicode in doctests. - Fix "Error reading from subprocess" errors on Unix-like systems. 3.4 (2007-03-29) ================ - Add ``exit-with-status`` support (supports use with buildbot and ``zc.recipe.testing``) - Add a small framework for automating set up and tear down of doctest tests. See ``setupstack.txt``. - Allow ``testrunner-wo-source.txt`` and ``testrunner-errors.txt`` to run within a read-only source tree. 3.0 (2006-09-20) ================ - Update the doctest copy with text-file encoding support. - Add logging-level support to the ``loggingsuppport`` module. - At verbosity-level 1, dots are not output continuously, without any line breaks. - Improve output when the inability to tear down a layer causes tests to be run in a subprocess. - Make ``zope.exception`` required only if the ``zope_tracebacks`` extra is requested. - Fix the test coverage. If a module, for example `interfaces`, was in an ignored directory/package, then if a module of the same name existed in a covered directory/package, then it was also ignored there, because the ignore cache stored the result by module name and not the filename of the module. 2.0 (2006-01-05) ================ - Release a separate project corresponding to the version of ``zope.testing`` shipped as part of the Zope 3.2.0 release. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/README.rst0000644000076600000240000000406014753613412015271 0ustar00m.howitzstaff================= ``zope.testing`` ================= .. image:: https://img.shields.io/pypi/v/zope.testing.svg :target: https://pypi.python.org/pypi/zope.testing/ :alt: Latest Version .. image:: https://github.com/zopefoundation/zope.testing/actions/workflows/tests.yml/badge.svg :target: https://github.com/zopefoundation/zope.testing/actions/workflows/tests.yml .. image:: https://readthedocs.org/projects/zopetesting/badge/?version=latest :target: http://zopetesting.readthedocs.org/en/latest/ :alt: Documentation Status This package provides a number of testing frameworks. For complete documentation, see https://zopetesting.readthedocs.io cleanup Provides a mixin class for cleaning up after tests that make global changes. See `zope.testing.cleanup` formparser An HTML parser that extracts form information. This is intended to support functional tests that need to extract information from HTML forms returned by the publisher. See `zope.testing.formparser` loggingsupport Support for testing logging code If you want to test that your code generates proper log output, you can create and install a handler that collects output. See `zope.testing.loggingsupport` module Lets a doctest pretend to be a Python module. See `zope.testing.module` renormalizing Regular expression pattern normalizing output checker. Useful for doctests. See `zope.testing.renormalizing` setupstack A simple framework for automating doctest set-up and tear-down. See `zope.testing.setupstack` wait A small utility for dealing with timing non-determinism See `zope.testing.wait` doctestcase Support for defining doctests as methods of `unittest.TestCase` classes so that they can be more easily found by test runners, like nose, that ignore test suites. See `zope.testing.doctestcase` Getting started developing zope.testing ======================================= ``zope.testing`` uses ``tox``. To start, install ``tox`` using ``pip install tox``. Now, run ``tox`` to run the ``zope.testing`` test suite. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/buildout.cfg0000644000076600000240000000027314753613412016114 0ustar00m.howitzstaff[buildout] develop = . parts = py unzip = true [test] recipe = zc.recipe.testrunner eggs = zope.testing [py] recipe = zc.recipe.egg eggs = ${test:eggs} nose interpreter = py ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1739527947.5127888 zope_testing-5.1/docs/0000755000076600000240000000000014753613414014534 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1739527947.5129426 zope_testing-5.1/docs/api/0000755000076600000240000000000014753613414015305 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/docs/api/index.rst0000644000076600000240000000157514753613412017154 0ustar00m.howitzstaff=============== API Reference =============== zope.testing.cleanup ==================== .. automodule:: zope.testing.cleanup zope.testing.doctestcase ======================== .. automodule:: zope.testing.doctestcase zope.testing.exceptions ======================= .. automodule:: zope.testing.exceptions zope.testing.formparser ======================= .. automodule:: zope.testing.formparser zope.testing.loggingsupport =========================== .. automodule:: zope.testing.loggingsupport zope.testing.module =================== .. automodule:: zope.testing.module zope.testing.renormalizing ========================== .. automodule:: zope.testing.renormalizing zope.testing.setupstack ======================= .. automodule:: zope.testing.setupstack .. zope.testing.testrunner is deprecated, do not document zope.testing.wait ================= .. automodule:: zope.testing.wait ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/docs/changes.rst0000644000076600000240000000003414753613412016671 0ustar00m.howitzstaff.. include:: ../CHANGES.rst ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/docs/cleanup.rst0000644000076600000240000000005614753613412016714 0ustar00m.howitzstaff.. include:: ../src/zope/testing/cleanup.txt ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/docs/conf.py0000644000076600000240000002175014753613412016036 0ustar00m.howitzstaff# # 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 os import sys import pkg_resources sys.path.append(os.path.abspath('../src')) rqmt = pkg_resources.require('zope.testing')[0] # Import and document the pure-python versions of things; they tend to have # better docstrings and signatures. os.environ['PURE_PYTHON'] = '1' # 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. # 1.3 adds autodoc_mock_imports needs_sphinx = '1.3' # 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.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode', 'repoze.sphinx.autointerface', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = {'.rst': 'restructuredtext'} # The encoding of source files. # source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = 'zope.testing' copyright = '2012-2024, 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 = '%s.%s' % tuple(map(int, rqmt.version.split('.')[:2])) # The full version, including alpha/beta/rc tags. release = rqmt.version # 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 = 'obj' # 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 # " v 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 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 = 'zopetestingdoc' # -- 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': '', } # pdflatex can't handle Cyrillic out of the box, but xetext/lualatex should be # able to cope latex_engine = 'lualatex' # Grouping the document tree into LaTeX files. List of tuples (source start # file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'zopetesting.tex', 'zope.testing Documentation', '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', 'zopetesting', 'zope.testing Documentation', ['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', 'zopetesting', 'zope.testing Documentation', 'Zope Foundation contributors', 'zopetesting', 'A number of testing frameworks.', '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 = { 'python': ('https://docs.python.org/', None), 'zopetestbrowser': ('https://zopetestbrowser.readthedocs.io/en/latest/', None), } # Sphinx 1.8+ prefers this to `autodoc_default_flags`. It's documented that # either True or None mean the same thing as just setting the flag, but # only None works in 1.8 (True works in 2.0) autodoc_default_options = { 'members': None, 'show-inheritance': None, } autodoc_member_order = 'bysource' autoclass_content = 'both' doctest_global_setup = ''' from zope.testing.tests import print_ ''' ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/docs/doctestcase.rst0000644000076600000240000000006214753613412017563 0ustar00m.howitzstaff.. include:: ../src/zope/testing/doctestcase.txt ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/docs/formparser.rst0000644000076600000240000000006114753613412017441 0ustar00m.howitzstaff.. include:: ../src/zope/testing/formparser.txt ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/docs/index.rst0000644000076600000240000000070014753613412016370 0ustar00m.howitzstaff.. include:: ../README.rst .. Yes, we want just an underline for the sections here, the include above establishes the title and these need to be subordinate to it. Contents ======== .. toctree:: :maxdepth: 1 cleanup doctestcase formparser loggingsupport module renormalizing setupstack wait api/index changes Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/docs/loggingsupport.rst0000644000076600000240000000006514753613412020350 0ustar00m.howitzstaff.. include:: ../src/zope/testing/loggingsupport.txt ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/docs/module.rst0000644000076600000240000000005514753613412016551 0ustar00m.howitzstaff.. include:: ../src/zope/testing/module.txt ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/docs/renormalizing.rst0000644000076600000240000000006414753613412020144 0ustar00m.howitzstaff.. include:: ../src/zope/testing/renormalizing.txt ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/docs/requirements.txt0000644000076600000240000000006014753613412020012 0ustar00m.howitzstaffSphinx repoze.sphinx.autointerface zope.testing ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/docs/setupstack.rst0000644000076600000240000000006114753613412017447 0ustar00m.howitzstaff.. include:: ../src/zope/testing/setupstack.txt ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/docs/wait.rst0000644000076600000240000000005314753613412016226 0ustar00m.howitzstaff.. include:: ../src/zope/testing/wait.txt ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/pyproject.toml0000644000076600000240000000123114753613412016513 0ustar00m.howitzstaff# # Generated from: # https://github.com/zopefoundation/meta/tree/master/config/pure-python [build-system] requires = ["setuptools <= 75.6.0"] build-backend = "setuptools.build_meta" [tool.coverage.run] branch = true source = ["zope.testing"] omit = ["src/zope/testing/exceptions.py", "src/zope/testing/testrunner.py"] [tool.coverage.report] fail_under = 97 precision = 2 ignore_errors = true show_missing = true exclude_lines = ["pragma: no cover", "pragma: nocover", "except ImportError:", "raise NotImplementedError", "if __name__ == '__main__':", "self.fail", "raise AssertionError", "raise unittest.Skip"] [tool.coverage.html] directory = "parts/htmlcov" ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1739527947.5186424 zope_testing-5.1/setup.cfg0000644000076600000240000000073214753613414015427 0ustar00m.howitzstaff[flake8] doctests = 1 [check-manifest] ignore = .editorconfig .meta.toml docs/_build/html/_sources/* docs/_build/doctest/* docs/_build/html/_sources/api/* [isort] force_single_line = True combine_as_imports = True sections = FUTURE,STDLIB,THIRDPARTY,ZOPE,FIRSTPARTY,LOCALFOLDER known_third_party = docutils, pkg_resources, pytz known_zope = known_first_party = default_section = ZOPE line_length = 79 lines_after_imports = 2 [egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/setup.py0000644000076600000240000000575414753613412015327 0ustar00m.howitzstaff############################################################################## # # Copyright (c) 2004 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## # This package is developed by the Zope Toolkit project, documented here: # http://docs.zope.org/zopetoolkit # When developing and releasing this package, please follow the documented # Zope Toolkit policies as described by this documentation. ############################################################################## """Setup for zope.testing package """ import os from setuptools import setup def read(*rnames): with open(os.path.join(os.path.dirname(__file__), *rnames)) as f: return f.read() long_description = read('README.rst') + '\n\n' + read('CHANGES.rst') keywords = "zope testing doctest RENormalizing OutputChecker timeout logging" setup( name='zope.testing', version='5.1', url='https://github.com/zopefoundation/zope.testing', license='ZPL-2.1', description='Zope testing helpers', long_description=long_description, author='Zope Foundation and Contributors', author_email='zope-dev@zope.dev', classifiers=[ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Zope Public License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Framework :: Zope :: 3", "Framework :: Zope :: 4", "Framework :: Zope :: 5", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Testing", ], keywords=keywords, packages=[ "zope", "zope.testing", ], package_dir={'': 'src'}, namespace_packages=['zope'], python_requires='>=3.9', install_requires=[ 'setuptools', ], extras_require={ 'test': [ 'zope.testrunner', ], 'docs': [ 'sphinx', 'repoze.sphinx.autointerface', 'zope.exceptions', 'zope.interface', ], }, include_package_data=True, zip_safe=False, ) ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1739527947.509011 zope_testing-5.1/src/0000755000076600000240000000000014753613414014373 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1739527947.5130787 zope_testing-5.1/src/zope/0000755000076600000240000000000014753613414015350 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/src/zope/__init__.py0000644000076600000240000000011414753613412017453 0ustar00m.howitzstaff__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1739527947.517552 zope_testing-5.1/src/zope/testing/0000755000076600000240000000000014753613414017025 5ustar00m.howitzstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/src/zope/testing/__init__.py0000644000076600000240000000120214753613412021127 0ustar00m.howitzstaff############################################################################## # # Copyright (c) 2001, 2002 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/src/zope/testing/cleanup.py0000644000076600000240000000341014753613412021022 0ustar00m.howitzstaff############################################################################## # # Copyright (c) 2001, 2002 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Provide a standard cleanup registry Unit tests that change global data should include the `CleanUp` base class, which provides simpler `setUp` and `tearDown` methods that call global-data cleanup routines:: class Test(CleanUp, unittest.TestCase): .... If custom `setUp` or `tearDown` are needed, then the base routines should be called, as in:: def tearDown(self): super(Test, self).tearDown() .... Cleanup routines for global data should be registered by passing them to `addCleanup`:: addCleanUp(pigRegistry._clear) """ _cleanups = [] def addCleanUp(func, args=(), kw={}): """Register a cleanup routines Pass a function to be called to cleanup global data. Optional argument tuple and keyword arguments may be passed. """ _cleanups.append((func, args, kw)) class CleanUp: """Mix-in class providing clean-up setUp and tearDown routines.""" def cleanUp(self): """Clean up global data.""" cleanUp() setUp = tearDown = cleanUp def cleanUp(): """Clean up global data.""" for func, args, kw in _cleanups: func(*args, **kw) setUp = tearDown = cleanUp ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/src/zope/testing/cleanup.txt0000644000076600000240000000124314753613412021213 0ustar00m.howitzstaff================== Cleanup registry ================== .. currentmodule:: zope.testing.cleanup Unit tests that change global data should include the `CleanUp` base class, which provides simpler `setUp` and `tearDown` methods that call global-data cleanup routines. >>> def print_args(*args, **kw): ... print(args) ... print(kw) >>> from zope.testing.cleanup import addCleanUp, CleanUp >>> addCleanUp(print_args, ('1', 'foo'), {'bar': 42}) `CleanUp` calls the registered clean up functions on setup and tear down: >>> CleanUp().setUp() ('1', 'foo') {'bar': 42} >>> CleanUp().tearDown() ('1', 'foo') {'bar': 42} >>> CleanUp().cleanUp() ('1', 'foo') {'bar': 42} ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/src/zope/testing/doctestcase.py0000644000076600000240000001327714753613412021710 0ustar00m.howitzstaffr"""Doctests in TestCase classes """ import doctest import inspect import os import re import sys import types __all__ = [ 'doctestmethod', 'method', 'docteststring', 'string', 'doctestfile', 'file', 'doctestfiles', 'files', ] _parser = doctest.DocTestParser() def _testify(name): if not name.startswith('test'): name = 'test_' + name return name def doctestmethod(test=None, optionflags=0, checker=None): """Define a doctest from a method within a unittest.TestCase. The method's doc string provides the test source. Its body is called before the test and may perform test-specific setup. You can pass doctest option flags and a custon checker. Variables defined in the enclosing module are available in the test. If a test case defines a globs attribute, it must be a dictionary and its contents are added to the test globals. The test object is available as the variable ``self`` in the test. """ if test is None: return lambda test: _doctestmethod(test, optionflags, checker) return _doctestmethod(test, optionflags, checker) #: Alias of `doctestmethod` method = doctestmethod def _doctestmethod(test, optionflags, checker): doc = test.__doc__ if not doc: raise ValueError(test, "has no docstring") setup = test name = test.__name__ path = inspect.getsourcefile(test) lineno = inspect.getsourcelines(test)[1] fglobs = sys._getframe(3).f_globals def test_method(self): setup(self) _run_test(self, doc, fglobs.copy(), name, path, optionflags, checker, lineno=lineno) test_method.__name__ = _testify(name) return test_method def docteststring(test, optionflags=0, checker=None, name=None): """Define a doctest from a string within a unittest.TestCase. You can pass doctest option flags and a custon checker. Variables defined in the enclosing module are available in the test. If a test case defines a globs attribute, it must be a dictionary and its contents are added to the test globals. The test object is available as the variable ``self`` in the test. """ fglobs = sys._getframe(2).f_globals def test_string(self): _run_test(self, test, fglobs.copy(), '', '', optionflags, checker) if name: test_string.__name__ = _testify(name) return test_string #: Alias of `docteststring` string = docteststring _not_word = re.compile(r'\W') def doctestfile(path, optionflags=0, checker=None): """Define a doctest from a test file within a unittest.TestCase. The file path may be relative or absolute. If its relative (the common case), it will be interpreted relative to the directory containing the referencing module. You can pass doctest option flags and a custon checker. If a test case defines a globs attribute, it must be a dictionary and its contents are added to the test globals. The test object is available as the variable ``test`` in the test. The resulting object can be used as a function decorator. The decorated method is called before the test and may perform test-specific setup. (The decorated method's doc string is ignored.) """ base = os.path.dirname(os.path.abspath( sys._getframe(2).f_globals['__file__'] )) path = os.path.join(base, path) with open(path) as f: test = f.read() name = os.path.basename(path) def test_file(self): if isinstance(self, types.FunctionType): setup = self def test_file_w_setup(self): setup(self) _run_test(self, test, {}, name, path, optionflags, checker, 'test') test_file_w_setup.__name__ = _testify(setup.__name__) test_file_w_setup.filepath = path test_file_w_setup.filename = os.path.basename(path) return test_file_w_setup _run_test(self, test, {}, name, path, optionflags, checker, 'test') test_file.__name__ = name_from_path(path) test_file.filepath = path test_file.filename = os.path.basename(path) return test_file #: Alias of `doctestfile` file = doctestfile def doctestfiles(*paths, **kw): """Define doctests from test files in a decorated class. Multiple files can be specified. A member is added to the decorated class for each file. The file paths may be relative or absolute. If relative (the common case), they will be interpreted relative to the directory containing the referencing module. You can pass doctest option flags and a custon checker. If a test case defines a globs attribute, it must be a dictionary and its contents are added to the test globals. The test object is available as the variable ``test`` in the test. The resulting object must be used as a class decorator. """ def doctestfiles_(class_): for path in paths: name = name_from_path(path) test = doctestfile(path, **kw) test.__name__ = name setattr(class_, name, test) return class_ return doctestfiles_ #: Alias of `doctestfiles` files = doctestfiles def name_from_path(path): return _testify( _not_word.sub('_', os.path.splitext(os.path.basename(path))[0]) ) def _run_test(self, test, globs, name, path, optionflags, checker, testname='self', lineno=0): globs.update(getattr(self, 'globs', ())) globs[testname] = self optionflags |= doctest.IGNORE_EXCEPTION_DETAIL doctest.DocTestCase( _parser.get_doctest(test, globs, name, path, lineno), optionflags=optionflags, checker=checker, ).runTest() ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/src/zope/testing/doctestcase.txt0000644000076600000240000002375514753613412022101 0ustar00m.howitzstaff============================== Doctests in TestCase classes ============================== .. currentmodule:: zope.testing.doctestcase The original `doctest` unittest integration was based on `unittest` test suites, which have fallen out of favor. This module provides a way to define doctests inside of `unittest.TestCase` classes. It provides better integration with unittest test fixtures, because doctests use setup provided by the containing test case class. It provides access to unittest assertion methods. You can define doctests in multiple ways: - references to named files - strings - decorated functions with docstrings - reference to named files decorating test-specific setup functions - reference to named files decorating a test class .. some setup >>> __name__ = 'tests' Here are some examples:: >>> from zope.testing import doctestcase >>> import doctest >>> import unittest >>> g = 'global' >>> class MyTest(unittest.TestCase): ... ... def setUp(self): ... self.a = 1 ... self.globs = dict(c=9) ... ... test1 = doctestcase.file('test-1.txt', optionflags=doctest.ELLIPSIS) ... ... test2 = doctestcase.docteststring(''' ... >>> self.a, g, c ... (1, 'global', 9) ... ''') ... ... @doctestcase.doctestmethod(optionflags=doctest.ELLIPSIS) ... def test3(self): ... ''' ... >>> self.a, self.x, g, c ... (1, 3, 'global', 9) ... ''' ... self.x = 3 ... ... @doctestcase.doctestfile('test4.txt') ... def test4(self): ... self.x = 5 ... >>> class MissingDocstring(unittest.TestCase): #doctest: +ELLIPSIS ... """A doctest method has to have a docstring.""" ... ... @doctestcase.doctestmethod(optionflags=doctest.ELLIPSIS) ... def test55(self): ... pass Traceback (most recent call last): ... ValueError: (, 'has no docstring') >>> import sys >>> @doctestcase.doctestfiles('loggingsupport.txt', 'renormalizing.txt') ... class MoreTests(unittest.TestCase): ... ... def setUp(self): ... def print_(*args): ... sys.stdout.write(' '.join(map(str, args))+'\n') ... self.globs = dict(print_=print_) .. We can run these tests with the ``unittest`` test runner. >>> loader = unittest.TestLoader() >>> sys.stdout.writeln = lambda s: sys.stdout.write(s+'\n') >>> suite = loader.loadTestsFromTestCase(MyTest) >>> result = suite.run(unittest.TextTestResult(sys.stdout, True, 3)) test1 (tests.MyTest) ... ok test2 (tests.MyTest) ... ok test3 (tests.MyTest) ... ok test4 (tests.MyTest) ... ok >>> suite = loader.loadTestsFromTestCase(MoreTests) >>> result = suite.run(unittest.TextTestResult(sys.stdout, True, 3)) test_loggingsupport (tests.MoreTests) ... ok test_renormalizing (tests.MoreTests) ... ok >>> for _, e in result.errors: ... print(e); print Check meta data: >>> MyTest.test1.__name__ 'test_1' >>> import os, zope.testing >>> (MyTest.test1.filepath == ... os.path.join(os.path.dirname(zope.testing.__file__), 'test-1.txt')) True >>> MyTest.test1.filename 'test-1.txt' >>> MyTest.test3.__name__ 'test3' >>> MyTest.test4.__name__ 'test4' >>> (MyTest.test4.filepath == ... os.path.join(os.path.dirname(zope.testing.__file__), 'test4.txt')) True >>> MyTest.test4.filename 'test4.txt' >>> MoreTests.test_loggingsupport.__name__ 'test_loggingsupport' >>> MoreTests.test_loggingsupport.filename 'loggingsupport.txt' >>> (MoreTests.test_loggingsupport.filepath == ... os.path.join(os.path.dirname(zope.testing.__file__), ... 'loggingsupport.txt')) True In these examples, 4 constructors were used: doctestfile (alias: `file`) `doctestfile` makes a file-based test case. This can be used as a decorator, in which case, the decorated function is called before the test is run, to provide test-specific setup. doctestfiles (alias: `files`) `doctestfiles` makes file-based test cases and assigns them to the decorated class. Multiple files can be specified and the resulting doctests are added as members of the decorated class. docteststring (alias: `string`) `docteststring` constructs a doctest from a string. doctestmethod (alias: `method`) `doctestmethod` constructs a doctest from a method. The method's docstring provides the test. The method's body provides optional test-specific setup. Note that short aliases are provided, which maye be useful in certain import styles. Tests have access to the following data: - Tests created with the `docteststring` and `doctestmethod` constructors have access to the module globals of the defining module. - In tests created with the `docteststring` and `doctestmethod` constructors, the test case instance is available as the ``self`` variable. - In tests created with the `doctestfile` and `doctestfiles` constructor, the test case instance is available as the ``test`` variable. - If a test case defines a globs attribute, it must be a dictionary and it's contents are added to the test globals. The constructors accept standard doctest ``optionflags`` and ``checker`` arguments. Note that the doctest ``IGNORE_EXCEPTION_DETAIL`` option flag is added to optionflags. When using ``doctestfile`` and ``doctestfile``, ``filename`` and ``filepath`` attributes are available that contain the test file name and full path. ``__name__`` attributes of class members ======================================== Class members have ``__name__`` attributes set as follows: - When using ``doctestmethod`` or ``doctestfile`` with a setup function, ``__name__`` attribute is set to the name of the function. A ``test_`` prefix is added, if the name doesn't start with ``test``. - When ``doctestfile`` is used without a setup function or when ``doctestfiles`` is used, ``__name__`` is set to the last part of the file path with the extension removed and non-word characters converted to underscores. For example, with a test path of ``'/foo/bar/test-it.rst'``, the ``__name__`` attribute is set to ``'test_it'``. A ``test_`` prefix is added, if the name doesn't start with ``test``. - when using ``docteststring``, a ``name`` option can be passed in to set ``__name__``. A ``test_`` prefix is added, if the name doesn't start with ``test``. The ``__name__`` attribute is important when using nose, because nose discovers tests as class members using their ``__name__`` attributes, whereas the unittest and py.test test runners use class dictionary keys. .. Let's look at some failure cases: >>> class MyTest(unittest.TestCase): ... ... test2 = doctestcase.string(''' ... >>> 1 ... 1 ... >>> 1 + 1 ... 1 ... ''', name='test2') ... ... @doctestcase.method ... def test3(self): ... ''' ... >>> self.x ... 3 ... >>> 1 + 1 ... 1 ... ''' ... self.x = 3 ... ... @doctestcase.file('test4f.txt') ... def test4(self): ... self.x = 5 >>> suite = loader.loadTestsFromTestCase(MyTest) >>> result = suite.run(unittest.TextTestResult(sys.stdout, True, 1)) FFF >>> for c, e in result.failures: ... print(e) # doctest: +ELLIPSIS +REPORT_UDIFF Traceback (most recent call last): ... ...: Failed doctest test for File "", line 0, in ...----------... File "", line 4, in Failed example: 1 + 1 Expected: 1 Got: 2 Traceback (most recent call last): ... ...: Failed doctest test for test3 File "None", line 10, in test3 ...----------... Line 4, in test3 Failed example: 1 + 1 Expected: 1 Got: 2 Traceback (most recent call last): ... ...: Failed doctest test for test4f.txt File "...test4f.txt", line 0, in txt ...----------... File "...test4f.txt", line 3, in test4f.txt Failed example: 1 + 1 Expected: 1 Got: 2 Check string meta data: >>> MyTest.test2.__name__ 'test2' .. Verify setting optionflags and checker >>> class EasyChecker: ... def check_output(self, want, got, optionflags): ... return True ... def output_difference(self, example, got, optionflags): ... return '' >>> class MyTest(unittest.TestCase): ... ... test2 = doctestcase.string(''' ... >>> 1 ... 2 ... ''', checker=EasyChecker()) ... ... @doctestcase.method(optionflags=doctest.ELLIPSIS) ... def test3(self): ... ''' ... >>> 'Hello' ... '...' ... ''' ... ... @doctestcase.file('test4e.txt', optionflags=doctest.ELLIPSIS) ... def test4(self): ... self.x = 5 >>> suite = loader.loadTestsFromTestCase(MyTest) >>> result = suite.run(unittest.TextTestResult(sys.stdout, True, 2)) test2 (tests.MyTest) ... ok test3 (tests.MyTest) ... ok test4 (tests.MyTest) ... ok .. test __name__ variations >>> class MyTest(unittest.TestCase): ... ... foo = doctestcase.string('''>>> 1''', name='foo') ... ... @doctestcase.method ... def bar(self): ... ''' ... >>> self.x ... 3 ... ''' ... @doctestcase.file('test4f.txt') ... def baz(self): ... pass ... wait = doctestcase.file('wait.txt') >>> MyTest.foo.__name__ 'test_foo' >>> MyTest.bar.__name__ 'test_bar' >>> MyTest.baz.__name__ 'test_baz' >>> MyTest.wait.__name__ 'test_wait' ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/src/zope/testing/exceptions.py0000644000076600000240000000174314753613412021563 0ustar00m.howitzstaff############################################################################## # # Copyright (c) 2004 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Exceptions for zope.testing """ import warnings # Tell people to use the builtin module instead. warnings.warn( 'zope.testing.exceptions is deprecated in favour of ' 'zope.testrunner.exceptions', DeprecationWarning, stacklevel=2) class DocTestFailureException(AssertionError): """Use custom exception for doctest unit test failures""" ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/src/zope/testing/formparser.py0000644000076600000240000001636314753613412021566 0ustar00m.howitzstaff"""HTML parser that extracts form information. This is intended to support functional tests that need to extract information from HTML forms returned by the publisher. See :doc:`../formparser` for documentation. This isn't intended to simulate a browser session; that's provided by the `zope.testbrowser` package. .. versionchanged:: 4.10.0 Add support for Python 3. """ __docformat__ = "reStructuredText" import html.parser as HTMLParser import urllib.parse as urlparse def parse(data, base=None): """Return a form collection parsed from *data*. *base* should be the URL from which *data* was retrieved. """ parser = FormParser(data, base) return parser.parse() class FormParser: """ The parser. """ def __init__(self, data, base=None): self.data = data self.base = base self._parser = HTMLParser.HTMLParser() self._parser.handle_data = self._handle_data self._parser.handle_endtag = self._handle_endtag self._parser.handle_starttag = self._handle_starttag self._parser.handle_startendtag = self._handle_starttag self._buffer = [] self.current = None # current form self.forms = FormCollection() def parse(self): """Parse the document, returning the collection of forms.""" self._parser.feed(self.data) self._parser.close() return self.forms # HTMLParser handlers def _handle_data(self, data): self._buffer.append(data) def _handle_endtag(self, tag): if tag == "textarea": self.textarea.value = "".join(self._buffer) self.textarea = None elif tag == "select": self.select = None elif tag == "option": option = self.select.options[-1] label = "".join(self._buffer) if not option.label: option.label = label if not option.value: option.value = label if option.selected: if self.select.multiple: self.select.value.append(option.value) else: self.select.value = option.value def _handle_starttag(self, tag, attrs): del self._buffer[:] d = {} for name, value in attrs: d[name] = value name = d.get("name") id = d.get("id") or d.get("xml:id") if tag == "form": method = kwattr(d, "method", "get") action = d.get("action", "").strip() or None if self.base and action: action = urlparse.urljoin(self.base, action) enctype = kwattr(d, "enctype", "application/x-www-form-urlencoded") self.current = Form(name, id, method, action, enctype) self.forms.append(self.current) elif tag == "input": type = kwattr(d, "type", "text") checked = "checked" in d disabled = "disabled" in d readonly = "readonly" in d src = d.get("src", "").strip() or None if self.base and src: src = urlparse.urljoin(self.base, src) value = d.get("value") size = intattr(d, "size") maxlength = intattr(d, "maxlength") self._add_field( Input(name, id, type, value, checked, disabled, readonly, src, size, maxlength)) elif tag == "button": pass elif tag == "textarea": disabled = "disabled" in d readonly = "readonly" in d self.textarea = Input(name, id, "textarea", None, None, disabled, readonly, None, None, None) self.textarea.rows = intattr(d, "rows") self.textarea.cols = intattr(d, "cols") self._add_field(self.textarea) # The value will be set when the is seen. elif tag == "base": href = d.get("href", "").strip() if href and self.base: href = urlparse.urljoin(self.base, href) self.base = href elif tag == "select": disabled = "disabled" in d multiple = "multiple" in d size = intattr(d, "size") self.select = Select(name, id, disabled, multiple, size) self._add_field(self.select) elif tag == "option": disabled = "disabled" in d selected = "selected" in d value = d.get("value") label = d.get("label") option = Option(id, value, selected, label, disabled) self.select.options.append(option) # Helpers: def _add_field(self, field): if field.name in self.current: ob = self.current[field.name] if isinstance(ob, list): ob.append(field) else: self.current[field.name] = [ob, field] else: self.current[field.name] = field def kwattr(d, name, default=None): """Return attribute, converted to lowercase.""" v = d.get(name, default) if v != default and v is not None: v = v.strip().lower() v = v or default return v def intattr(d, name): """Return attribute as an integer, or None.""" if name in d: v = d[name].strip() return int(v) else: return None class FormCollection(list): """Collection of all forms from a page.""" def __getattr__(self, name): for form in self: if form.name == name: return form raise AttributeError(name) class Form(dict): """A specific form within a page.""" # This object should provide some method to prepare a dictionary # that can be passed directly as the value of the `form` argument # to the `http()` function of the Zope functional test. # # This is probably a low priority given the availability of the # `zope.testbrowser` package. def __init__(self, name, id, method, action, enctype): super().__init__() self.name = name self.id = id self.method = method self.action = action self.enctype = enctype class Input: """Input element.""" rows = None cols = None def __init__(self, name, id, type, value, checked, disabled, readonly, src, size, maxlength): super().__init__() self.name = name self.id = id self.type = type self.value = value self.checked = checked self.disabled = disabled self.readonly = readonly self.src = src self.size = size self.maxlength = maxlength class Select(Input): """Select element.""" def __init__(self, name, id, disabled, multiple, size): super().__init__(name, id, "select", None, None, disabled, None, None, size, None) self.options = [] self.multiple = multiple if multiple: self.value = [] class Option: """Individual value representation for a select element.""" def __init__(self, id, value, selected, label, disabled): super().__init__() self.id = id self.value = value self.selected = selected self.label = label self.disabled = disabled ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1739527946.0 zope_testing-5.1/src/zope/testing/formparser.txt0000644000076600000240000000764414753613412021757 0ustar00m.howitzstaff==================== Parsing HTML Forms ==================== .. currentmodule:: zope.testing.formparser Sometimes in functional tests, information from a generated form must be extracted in order to re-submit it as part of a subsequent request. The `zope.testing.formparser` module can be used for this purpose. The scanner is implemented using the `FormParser` class. The constructor arguments are the page data containing the form and (optionally) the URL from which the page was retrieved: >>> import zope.testing.formparser >>> page_text = '''\ ... ...
... ... ... ... ...
... ... Just for fun, a second form, after specifying a base: ... ...
... ... ... ... ...
... ... ''' >>> parser = zope.testing.formparser.FormParser(page_text) >>> forms = parser.parse() >>> len(forms) 2 >>> forms.form1 is forms[0] True >>> forms.form1 is forms[1] False More often, the `parse()` convenience function is all that's needed: >>> forms = zope.testing.formparser.parse( ... page_text, "http://cgi.example.com/somewhere/form.html") >>> len(forms) 2 >>> forms.form1 is forms[0] True >>> forms.form1 is forms[1] False Once we have the form we're interested in, we can check form attributes and individual field values: >>> form = forms.form1 >>> form.enctype 'application/x-www-form-urlencoded' >>> form.method 'post' >>> keys = sorted(form.keys()) >>> keys ['do-it-now', 'f1', 'not-really', 'pick-two'] >>> not_really = form["not-really"] >>> not_really.type 'image' >>> not_really.value "Don't." >>> not_really.readonly False >>> not_really.disabled False Note that relative URLs are converted to absolute URLs based on the ```` element (if present) or using the base passed in to the constructor. >>> form.action 'http://cgi.example.com/cgi-bin/foobar.py' >>> not_really.src 'http://cgi.example.com/somewhere/dont.png' >>> forms[1].action 'http://www.example.com/base/sproing/sprung.html' >>> forms[1]["action"].src 'http://www.example.com/base/else.png' Fields which are repeated are reported as lists of objects that represent each instance of the field: >>> field = forms[1]["multi"] >>> isinstance(field, list) True >>> [o.value for o in field] ['', ''] >>> [o.size for o in field] [2, 3] The ``