{ "info": { "author": "Zope Foundation and Contributors", "author_email": "zope-dev@zope.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Framework :: Zope3", "Intended Audience :: Developers", "License :: OSI Approved :: Zope Public License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Testing" ], "description": "=================\n``zope.testing``\n=================\n\n.. image:: https://img.shields.io/pypi/v/zope.testing.svg\n :target: https://pypi.python.org/pypi/zope.testing/\n :alt: Latest Version\n\n.. image:: https://travis-ci.org/zopefoundation/zope.testing.svg?branch=master\n :target: https://travis-ci.org/zopefoundation/zope.testing\n\n.. image:: https://readthedocs.org/projects/zopetesting/badge/?version=latest\n :target: http://zopetesting.readthedocs.org/en/latest/\n :alt: Documentation Status\n\nThis package provides a number of testing frameworks.\n\ncleanup\n Provides a mixin class for cleaning up after tests that\n make global changes.\n\nformparser\n An HTML parser that extracts form information.\n\n **Python 2 only**\n\n This is intended to support functional tests that need to extract\n information from HTML forms returned by the publisher.\n\n See formparser.txt.\n\nloggingsupport\n Support for testing logging code\n\n If you want to test that your code generates proper log output, you\n can create and install a handler that collects output.\n\nloghandler\n Logging handler for tests that check logging output.\n\nmodule\n Lets a doctest pretend to be a Python module.\n\n See module.txt.\n\nrenormalizing\n Regular expression pattern normalizing output checker.\n Useful for doctests.\n\nserver\n Provides a simple HTTP server compatible with the zope.app.testing\n functional testing API. Lets you interactively play with the system\n under test. Helpful in debugging functional doctest failures.\n\n **Python 2 only**\n\nsetupstack\n A simple framework for automating doctest set-up and tear-down.\n See setupstack.txt.\n\nwait\n A small utility for dealing with timing non-determinism\n See wait.txt.\n\ndoctestcase\n Support for defining doctests as methods of ``unittest.TestCase``\n classes so that they can be more easily found by test runners, like\n nose, that ignore test suites.\n\n.. contents::\n\nGetting started developing zope.testing\n=======================================\n\nzope.testing uses buildout. To start, run ``python bootstrap.py``. It will\ncreate a number of directories and the ``bin/buildout`` script. Next, run\n``bin/buildout``. It will create a test script for you. Now, run ``bin/test``\nto run the zope.testing test suite.\n\n\nParsing HTML Forms\n==================\n\nSometimes in functional tests, information from a generated form must\nbe extracted in order to re-submit it as part of a subsequent request.\nThe `zope.testing.formparser` module can be used for this purpose.\n\nNOTE\n formparser doesn't support Python 3.\n\nThe scanner is implemented using the `FormParser` class. The\nconstructor arguments are the page data containing the form and\n(optionally) the URL from which the page was retrieved:\n\n >>> import zope.testing.formparser\n\n >>> page_text = '''\\\n ... \n ...
\n ... \n ... \n ... \n ... \n ...
\n ...\n ... Just for fun, a second form, after specifying a base:\n ... \n ...
\n ... \n ... \n ... \n ... \n ...
\n ... \n ... '''\n\n >>> parser = zope.testing.formparser.FormParser(page_text)\n >>> forms = parser.parse()\n\n >>> len(forms)\n 2\n >>> forms.form1 is forms[0]\n True\n >>> forms.form1 is forms[1]\n False\n\nMore often, the `parse()` convenience function is all that's needed:\n\n >>> forms = zope.testing.formparser.parse(\n ... page_text, \"http://cgi.example.com/somewhere/form.html\")\n\n >>> len(forms)\n 2\n >>> forms.form1 is forms[0]\n True\n >>> forms.form1 is forms[1]\n False\n\nOnce we have the form we're interested in, we can check form\nattributes and individual field values:\n\n >>> form = forms.form1\n >>> form.enctype\n 'application/x-www-form-urlencoded'\n >>> form.method\n 'post'\n\n >>> keys = form.keys()\n >>> keys.sort()\n >>> keys\n ['do-it-now', 'f1', 'not-really', 'pick-two']\n\n >>> not_really = form[\"not-really\"]\n >>> not_really.type\n 'image'\n >>> not_really.value\n \"Don't.\"\n >>> not_really.readonly\n False\n >>> not_really.disabled\n False\n\nNote that relative URLs are converted to absolute URLs based on the\n```` element (if present) or using the base passed in to the\nconstructor.\n\n >>> form.action\n 'http://cgi.example.com/cgi-bin/foobar.py'\n >>> not_really.src\n 'http://cgi.example.com/somewhere/dont.png'\n\n >>> forms[1].action\n 'http://www.example.com/base/sproing/sprung.html'\n >>> forms[1][\"action\"].src\n 'http://www.example.com/base/else.png'\n\nFields which are repeated are reported as lists of objects that\nrepresent each instance of the field::\n\n >>> field = forms[1][\"multi\"]\n >>> isinstance(field, list)\n True\n >>> [o.value for o in field]\n ['', '']\n >>> [o.size for o in field]\n [2, 3]\n\nThe ``