ftw.testing 1.5.2

Provides some testing helpers and an advanced MockTestCase
ftw.testing is a Python module that provides an advanced MockTestCase which provides bases on the plone.mocktestcase MockTestCase.

The following additional methos are available:

``self.providing_mock(interfaces, *args, **kwargs)``
      Creates a mock which provides ``interfaces``.

``self.mock_interface(interface, provides=None, *args, **kwargs)``
      Creates a mock object implementing ``interface``. The mock does not
      only provide ``interface``, but also use it as specification and
      asserts that the mocked methods do exist on the interface.

``self.stub(*args, **kwargs)``
      Creates a stub. It acts like a mock but has no assertions.

``self.providing_stub(interfaces, *args, **kwargs)``
      Creates a stub which provides ``interfaces``.

``self.stub_interface(interface, provides=None, *args, **kwargs)``
      Does the same as ``mock_interface``, but disables counting of expected
      method calls and attribute access. See "Mocking vs. stubbing" below.

``self.set_parent(context, parent_context)``
      Stubs the ``context`` so that its acquision parent is ``parent_context``.
      Expects at least context to be a mock or a stub. Returns the ``context``.

``self.stub_request(interfaces=[], stub_response=True,
                     content_type='text/html', status=200)``
      Returns a request stub which can be used for rendering templates. With the
      ``stub respones`` option, you can define if the request should stub a
      response by him self. The other optional arguments:
      ``content_type``: Defines the expected output content type of the response.
      ``status``: Defines the expected status code of the response.

``self.stub_response(request=None, content_type='text/html', status=200))``
      Returns a stub response with some headers and options. When a ``request``
      is given the response would append also to the giver request.
      The other optional arguments:
      ``content_type``: Defines the expected output content type of the response.
      ``status``: Defines the expected status code of the response.

``self.assertRaises(*args, **kwargs)``
      Uses ``unittest2`` implementation of assertRaises instead of
      ``unittest`` implementation.

It also fixes a problem in ``mock_tool``, where the ``getToolByName`` mock had assertions which is not very useful in some cases.

last updated on:
May 24th, 2012, 13:10 GMT
price:
FREE!
developed by:
Jonas Baumann
homepage:
github.com
license type:
GPL (GNU General Public License) 
category:
ROOT \ Internet \ Plone Extensions

FREE!

In a hurry? Add it to your Download Basket!

user rating

UNRATED
0.0/5
 

0/5

What's New in This Release:
  • Fix isinstance calls of freezed time in freeze context manager. [jone]
read full changelog

Add your review!

SUBMIT