zope.testing-4.5.0/ 0000755 0000766 0000024 00000000000 12571700474 014063 5 ustar jim staff 0000000 0000000 zope.testing-4.5.0/bootstrap.py 0000644 0000766 0000024 00000014545 12542324437 016462 0 ustar jim staff 0000000 0000000 ##############################################################################
#
# Copyright (c) 2006 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.
#
##############################################################################
"""Bootstrap a buildout-based project
Simply run this script in a directory containing a buildout.cfg.
The script accepts buildout command-line options, so you can
use the -c option to specify an alternate configuration file.
"""
import os
import shutil
import sys
import tempfile
from optparse import OptionParser
tmpeggs = tempfile.mkdtemp()
usage = '''\
[DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options]
Bootstraps a buildout-based project.
Simply run this script in a directory containing a buildout.cfg, using the
Python that you want bin/buildout to use.
Note that by using --find-links to point to local resources, you can keep
this script from going over the network.
'''
parser = OptionParser(usage=usage)
parser.add_option("-v", "--version", help="use a specific zc.buildout version")
parser.add_option("-t", "--accept-buildout-test-releases",
dest='accept_buildout_test_releases',
action="store_true", default=False,
help=("Normally, if you do not specify a --version, the "
"bootstrap script and buildout gets the newest "
"*final* versions of zc.buildout and its recipes and "
"extensions for you. If you use this flag, "
"bootstrap and buildout will get the newest releases "
"even if they are alphas or betas."))
parser.add_option("-c", "--config-file",
help=("Specify the path to the buildout configuration "
"file to be used."))
parser.add_option("-f", "--find-links",
help=("Specify a URL to search for buildout releases"))
parser.add_option("--allow-site-packages",
action="store_true", default=False,
help=("Let bootstrap.py use existing site packages"))
parser.add_option("--setuptools-version",
help="use a specific setuptools version")
options, args = parser.parse_args()
######################################################################
# load/install setuptools
try:
if options.allow_site_packages:
import setuptools
import pkg_resources
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
ez = {}
exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez)
if not options.allow_site_packages:
# ez_setup imports site, which adds site packages
# this will remove them from the path to ensure that incompatible versions
# of setuptools are not in the path
import site
# inside a virtualenv, there is no 'getsitepackages'.
# We can't remove these reliably
if hasattr(site, 'getsitepackages'):
for sitepackage_path in site.getsitepackages():
sys.path[:] = [x for x in sys.path if sitepackage_path not in x]
setup_args = dict(to_dir=tmpeggs, download_delay=0)
if options.setuptools_version is not None:
setup_args['version'] = options.setuptools_version
ez['use_setuptools'](**setup_args)
import setuptools
import pkg_resources
# This does not (always?) update the default working set. We will
# do it.
for path in sys.path:
if path not in pkg_resources.working_set.entries:
pkg_resources.working_set.add_entry(path)
######################################################################
# Install buildout
ws = pkg_resources.working_set
cmd = [sys.executable, '-c',
'from setuptools.command.easy_install import main; main()',
'-mZqNxd', tmpeggs]
find_links = os.environ.get(
'bootstrap-testing-find-links',
options.find_links or
('http://downloads.buildout.org/'
if options.accept_buildout_test_releases else None)
)
if find_links:
cmd.extend(['-f', find_links])
setuptools_path = ws.find(
pkg_resources.Requirement.parse('setuptools')).location
requirement = 'zc.buildout'
version = options.version
if version is None and not options.accept_buildout_test_releases:
# Figure out the most recent final version of zc.buildout.
import setuptools.package_index
_final_parts = '*final-', '*final'
def _final_version(parsed_version):
try:
return not parsed_version.is_prerelease
except AttributeError:
# Older setuptools
for part in parsed_version:
if (part[:1] == '*') and (part not in _final_parts):
return False
return True
index = setuptools.package_index.PackageIndex(
search_path=[setuptools_path])
if find_links:
index.add_find_links((find_links,))
req = pkg_resources.Requirement.parse(requirement)
if index.obtain(req) is not None:
best = []
bestv = None
for dist in index[req.project_name]:
distv = dist.parsed_version
if _final_version(distv):
if bestv is None or distv > bestv:
best = [dist]
bestv = distv
elif distv == bestv:
best.append(dist)
if best:
best.sort()
version = best[-1].version
if version:
requirement = '=='.join((requirement, version))
cmd.append(requirement)
import subprocess
if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0:
raise Exception(
"Failed to execute command:\n%s" % repr(cmd)[1:-1])
######################################################################
# Import and run buildout
ws.add_entry(tmpeggs)
ws.require(requirement)
import zc.buildout.buildout
if not [a for a in args if '=' not in a]:
args.append('bootstrap')
# if -c was provided, we push it back into args for buildout' main function
if options.config_file is not None:
args[0:0] = ['-c', options.config_file]
zc.buildout.buildout.main(args)
shutil.rmtree(tmpeggs)
zope.testing-4.5.0/buildout.cfg 0000644 0000766 0000024 00000000273 12551555115 016373 0 ustar jim staff 0000000 0000000 [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
zope.testing-4.5.0/CHANGES.rst 0000644 0000766 0000024 00000032113 12571700222 015654 0 ustar jim staff 0000000 0000000 Changes
=======
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.
zope.testing-4.5.0/COPYRIGHT.txt 0000644 0000766 0000024 00000000040 12542324437 016165 0 ustar jim staff 0000000 0000000 Zope Foundation and Contributors zope.testing-4.5.0/LICENSE.txt 0000644 0000766 0000024 00000004026 12542324437 015707 0 ustar jim staff 0000000 0000000 Zope 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.
zope.testing-4.5.0/MANIFEST.in 0000644 0000766 0000024 00000000157 12542324437 015623 0 ustar jim staff 0000000 0000000 include *.rst
include *.txt
include bootstrap.py
include buildout.cfg
include tox.ini
recursive-include src *
zope.testing-4.5.0/PKG-INFO 0000644 0000766 0000024 00000176575 12571700474 015205 0 ustar jim staff 0000000 0000000 Metadata-Version: 1.1
Name: zope.testing
Version: 4.5.0
Summary: Zope testing helpers
Home-page: http://pypi.python.org/pypi/zope.testing
Author: Zope Foundation and Contributors
Author-email: zope-dev@zope.org
License: ZPL 2.1
Description: =================
``zope.testing``
=================
.. image:: https://pypip.in/version/zope.testing/badge.svg?style=flat
:target: https://pypi.python.org/pypi/zope.testing/
:alt: Latest Version
.. image:: https://travis-ci.org/zopefoundation/zope.testing.png?branch=master
:target: https://travis-ci.org/zopefoundation/zope.testing
.. 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.
cleanup
Provides a mixin class for cleaning up after tests that
make global changes.
formparser
An HTML parser that extracts form information.
**Python 2 only**
This is intended to support functional tests that need to extract
information from HTML forms returned by the publisher.
See formparser.txt.
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.
loghandler
Logging handler for tests that check logging output.
module
Lets a doctest pretend to be a Python module.
See module.txt.
renormalizing
Regular expression pattern normalizing output checker.
Useful for doctests.
server
Provides a simple HTTP server compatible with the zope.app.testing
functional testing API. Lets you interactively play with the system
under test. Helpful in debugging functional doctest failures.
**Python 2 only**
setupstack
A simple framework for automating doctest set-up and tear-down.
See setupstack.txt.
wait
A small utility for dealing with timing non-determinism
See wait.txt.
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.
.. contents::
Getting started developing zope.testing
=======================================
zope.testing uses buildout. To start, run ``python bootstrap.py``. It will
create a number of directories and the ``bin/buildout`` script. Next, run
``bin/buildout``. It will create a test script for you. Now, run ``bin/test``
to run the zope.testing test suite.
Parsing HTML Forms
==================
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.
NOTE
formparser doesn't support Python 3.
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 = form.keys()
>>> keys.sort()
>>> 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 ``