Zope fixtures, support for testing Zope environments.
Project description
Copyright (c) 2011, Robert Collins <robertc@robertcollins.net>
Licensed under either the Apache License, Version 2.0 or the BSD 3-clause license at the users choice. A copy of both licenses are available in the project source as Apache-2.0 and BSD. You may not use this file except in compliance with one of these two licences.
Unless required by applicable law or agreed to in writing, software distributed under these licenses is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the license you chose for the specific language governing permissions and limitations under that license.
Zope fixtures provides Fixtures (http://pypi.python.org/pypi/fixtures) for use with Zope tests. These permit easy unit testing in Zope environments.
Dependencies
Python 2.4+ This is the base language fixtures is written in and for.
zope.interfaces.
Fixtures (http://pypi.python.org/pypi/fixtures).
For use in a unit test suite using the included glue, one of:
Python 2.7
unittest2
bzrlib.tests
Or any other test environment that supports TestCase.addCleanup.
Writing your own glue code is easy, or you can simply use the fixtures directly without any support code.
To run the test suite for zope_fixtures, testtools is needed.
See the Fixtures documentation for overview and design information.
Stock Fixtures
ComponentsFixture
This permits overlaying registrations in the zope registry. While the fixture is setup any registrations made are local to the fixture, and will be thrown away when the fixture is torn down.
>>> from zope_fixtures import ComponentsFixture >>> from zope.interface import Interface, implements >>> from zope.component import getSiteManager >>> class ITestUtility(Interface):pass >>> class TestUtility(object): ... implements(ITestUtility) >>> with ComponentsFixture(): ... getSiteManager().registerUtility(TestUtility())
UtilityFixture
This permits simple replacement of a single utility.
>>> from zope_fixtures import UtilityFixture >>> with UtilityFixture(TestUtility()): ... pass
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.