Mock unit test case based on ``mocker``
Project description
Introduction
============
This package contains a unittest test class based on the one from the
``Mocker`` mock library (http://labix.org/mocker).
This class provides support for registering Zope 3 components (utilities,
adapters, subscription adapters and event handlers) from mocks and tearing
down the global component registry during test tear-down.
There are also a few convenience methods and parameter checkers that are
useful to Zope and Plone testing.
Please see the Mocker documentation for more detail:
http://labix.org/mocker
See testcase.py for more detail on the mock helper methods.
A test case that mocks a utility may look like this::
from plone.mocktestcase import MockTestCase
from my.package.interfaces import IMyInterface
from my.package.foo import testable_method
class MyTestCase(MockTestCase):
def test_something(self):
utility_mock = self.mocker.mock()
self.expect(utility_mock.do_something()).result("foo")
self.mock_utility(utility_mock, IMyInterface)
# Put mocker into replay mode
self.replay()
# Verify that testable_method() looks up a utility for
# IMyInterface and calls do_something() on it, which returns
# "foo".
testable_method()
Changelog
=========
1.0b1 - Unreleased
----------------
* Initial release
============
This package contains a unittest test class based on the one from the
``Mocker`` mock library (http://labix.org/mocker).
This class provides support for registering Zope 3 components (utilities,
adapters, subscription adapters and event handlers) from mocks and tearing
down the global component registry during test tear-down.
There are also a few convenience methods and parameter checkers that are
useful to Zope and Plone testing.
Please see the Mocker documentation for more detail:
http://labix.org/mocker
See testcase.py for more detail on the mock helper methods.
A test case that mocks a utility may look like this::
from plone.mocktestcase import MockTestCase
from my.package.interfaces import IMyInterface
from my.package.foo import testable_method
class MyTestCase(MockTestCase):
def test_something(self):
utility_mock = self.mocker.mock()
self.expect(utility_mock.do_something()).result("foo")
self.mock_utility(utility_mock, IMyInterface)
# Put mocker into replay mode
self.replay()
# Verify that testable_method() looks up a utility for
# IMyInterface and calls do_something() on it, which returns
# "foo".
testable_method()
Changelog
=========
1.0b1 - Unreleased
----------------
* Initial release
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.
Source Distribution
File details
Details for the file plone.mocktestcase-1.0b1.tar.gz
.
File metadata
- Download URL: plone.mocktestcase-1.0b1.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
6a553516d53274d4b487c6c39ca40d3ab3a309b2a786413aacb7874dd40a83df
|
|
MD5 |
80a334f1988e4bea69448044bb11eb53
|
|
BLAKE2b-256 |
45370717ebbc099867602feaadd800831ca97f8e6c14b14c63769dac5dd5a65a
|