File: index.rst

package info (click to toggle)
python-fudge 1.1.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 744 kB
  • sloc: javascript: 3,300; python: 2,537; makefile: 82; sh: 5
file content (192 lines) | stat: -rw-r--r-- 7,526 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
===================
Fudge Documentation
===================

Fudge is a Python module for using fake objects (mocks and stubs) to test real ones.

In readable Python code, you declare what methods are available on your fake and how they should be called.  Then you inject that into your application and start testing.  This declarative approach means you don't have to record and playback actions and you don't have to inspect your fakes after running code.  If the fake object was used incorrectly then you'll see an informative exception message with a traceback that points to the culprit.

Fudge was inspired by `Mocha <http://mocha.rubyforge.org/>`_ which is a simpler version of `jMock <http://www.jmock.org/>`_.  But unlike Mocha, Fudge does not automatically hijack real objects; you explicitly :ref:`patch <using-fudge>` them in your test.  And unlike jMock, Fudge is only as strict about expectations as you want it to be.  If the type of arguments sent to the fake method aren't important then you don't have to declare an expectation for them.

Download / Install
==================

Just type::

    $ pip install fudge

You can get the `pip command here`_.  Fudge requires Python 2.5 or higher.

.. _pip command here: http://pip.openplans.org/

.. _install-for-python-3:

Installing for Python 3
=======================

As of version 0.9.5, Fudge supports Python 3.  Just install `distribute`_ and type::
    
    $ python3.x setup.py install

This step will convert the Fudge source code using the 2to3 tool.

.. _distribute: http://packages.python.org/distribute/

.. _fudge-source:

Source
======

The Fudge source can be downloaded as a tar.gz file from http://pypi.python.org/pypi/fudge

Using `Git <https://git-scm.com/>`_ you can clone the source from https://github.com/fudge-py/fudge/

Fudge is free and open for usage under the `MIT license`_.

.. _MIT license: http://en.wikipedia.org/wiki/MIT_License

Contents
========

.. toctree::
   :maxdepth: 2
   
   using-fudge
   javascript
   why-fudge
   migrating-0.9-to-1.0

.. _fudge-api:

API Reference
=============

.. toctree::
    :glob:
    
    api/*

Contributing
============

Please submit `bugs and patches <https://github.com/fudge-py/fudge/issues>`_, preferably with tests.  All contributors will be acknowledged.  Thanks!

Credits
=======

Fudge was created by `Kumar McMillan <http://farmdev.com/>`_ and contains contributions by Cristian Esquivias, Michael Williamson, Luis Fagundes and Jeremy Satterfield.

.. _fudge-changelog:

Changelog
=========

- 1.1.1

  - Fixes error when providing tuple or list to arg.isinstance

- 1.1.0

  - **Changed** `moved to github <https://github.com/fudge-py/fudge/>`_ and added maintainers
  - **Changed** remove support for python 3.1 and 3.2 in tests in lieu of 3.4
  - added :func:`fudge.Fake.has_property`
  - added :class:`IsInstance`
  - added :func:`without_args`
  - Deprecation warnings are now real warnings.

- 1.0.3

  - Added :func:`fudge.Fake.is_a_stub` :ref:`documented here <creating-a-stub>`
  - :func:`arg.any_value() <fudge.inspector.ValueInspector.any_value>`
    is **DEPRECATED** in favor of
    :func:`arg.any() <fudge.inspector.ValueInspector.any>`
  - Attributes declared by :func:`fudge.Fake.has_attr` are now settable.
    Thanks to Mike Kent for the bug report.
  - Fixes ImportError when patching certain class methods like
    smtplib.SMTP.sendmail
  - Fixes representation of chained fakes for class instances.

- 1.0.2

  - Object patching is a lot safer in many cases and now supports getter objects
    and static methods. Thanks to Michael Foord and mock._patch for ideas and code.

- 1.0.1
  
  - Fixed ImportError when a patched path traverses object attributes within a module.

- 1.0.0

  - After extensive usage and community input, the fudge interface has
    been greatly simplified!
  - There is now a :ref:`way better pattern <using-fudge>` for setting up fakes. The old way is
    still supported but you'll want to write all new code in this pattern once
    you see how much easier it is.
  - Added :func:`fudge.patch` and :func:`fudge.test`
  - Added :func:`fudge.Fake.expects_call` and :func:`fudge.Fake.is_callable`
  - **Changed**: The tests are no longer maintained in Python 2.4 although 
    Fudge probably still supports 2.4

- 0.9.6

  - Added support to patch builtin modules.  Thanks to Luis Fagundes for the 
    patch.

- 0.9.5
  
  - **Changed**: multiple calls to :func:`fudge.Fake.expects` behave just like 
    :func:`fudge.Fake.next_call`.  The same goes for :func:`fudge.Fake.provides`.
    You probably won't need to update any old code for this change, it's just 
    a convenience.
  - Added :func:`fudge.Fake.with_matching_args` so that expected 
    arguments can be declared more loosely
  - Added :ref:`support for Python 3 <install-for-python-3>`
  - Improved support for Jython

- 0.9.4
  
  - Fixed bug where __init__ would always return the Fake instance of itself.  
    Now you can return a custom object if you want.

- 0.9.3
  
  - Added ``with_args()`` to :ref:`JavaScript Fudge <javascript-fudge>`.
  - Fixed bug where argument values that overloaded __eq__ might cause declared expectations to fail (patch from Michael Williamson, Issue 9)
  - Fixed bug where :func:`fudge.Fake.raises` obscured :func:`fudge.Fake.with_args` (Issue 6)
  - Fixed ``returns_fake()`` in JavaScript Fudge.

- 0.9.2
  
  - **Changed**: values in failed comparisons are no longer shortened when too long.
  - **Changed**: :func:`fudge.Fake.calls` no longer trumps expectations 
    (i.e. :func:`fudge.Fake.with_args`)
  - **Changed**: :func:`fudge.Fake.with_args` is more strict.  You will now see an error 
    when arguments are not expected yet keyword arguments were expected and vice versa.  
    This was technically a bug but is listed under 
    changes in case you need to update your code.  Note that you can work 
    with arguments more expressively using the new :mod:`fudge.inspector` functions.
  - Added :mod:`fudge.inspector` for :ref:`working-with-arguments`.
  - Added :func:`fudge.Fake.remember_order` so that order of expected calls can be verified.
  - Added :func:`fudge.Fake.raises` for simulating exceptions
  - Added keyword :func:`fudge.Fake.next_call(for_method="other_call") <fudge.Fake.next_call>` 
    so that arbitrary methods can be modified (not just the last one).
  - Fixed: error is raised if you declare multiple :func:`fudge.Fake.provides` for the same Fake. 
    This also applies to :func:`fudge.Fake.expects`
  - Fixed bug where :func:`fudge.Fake.returns` did not work if you had replaced a call with :func:`fudge.Fake.calls`
  - Fixed bug in :func:`fudge.Fake.next_call` so that this now works: ``Fake(callable=True).next_call().returns(...)``
  - Fixed: Improved Python 2.4 compatibility.
  - Fixed bug where ``from fudge import *`` did not import proper objects.

- 0.9.1
  
  - **DEPRECATED** fudge.start() in favor of :func:`fudge.clear_calls`
  - **DEPRECATED** fudge.stop() in favor of :func:`fudge.verify`
  - Added context manager :func:`fudge.patcher.patched_context` so the with statement can be used for 
    patching (contributed by Cristian Esquivias)
  - Added :func:`fudge.Fake.times_called` to expect a certain call count (contributed by Cristian Esquivias)
  - Added :class:`Fake(expect_call=True) <fudge.Fake>` to indicate an expected callable.  Unlike 
    :class:`Fake(callable=True) <fudge.Fake>` the former will raise an error if not called.
  
- 0.9.0
  
  - first release