Skip to main content

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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zope_fixtures-0.0.3.tar.gz (11.1 kB view details)

Uploaded Source

File details

Details for the file zope_fixtures-0.0.3.tar.gz.

File metadata

File hashes

Hashes for zope_fixtures-0.0.3.tar.gz
Algorithm Hash digest
SHA256 f426db92ac1f6d812711ff08b6f7486821a96e7978f7efac6117f3f884121e55
MD5 4f2a14b0590dd793002a2bf88d7d9b9c
BLAKE2b-256 2bc90b29e397eb383390e3b964b9d44eabe5604dd746e2875ccf4a37a55147c5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page