/usr/share/doc/python-fudge-doc/html/why-fudge.html is in python-fudge-doc 1.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Why Another Mock Framework? — Fudge 1.1.0 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.1.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Fudge 1.1.0 documentation" href="index.html" />
<link rel="next" title="Migrating from Fudge 0.9 to 1.0" href="migrating-0.9-to-1.0.html" />
<link rel="prev" title="Fudge For JavaScript" href="javascript.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="migrating-0.9-to-1.0.html" title="Migrating from Fudge 0.9 to 1.0"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="javascript.html" title="Fudge For JavaScript"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">Fudge 1.1.0 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="why-another-mock-framework">
<h1>Why Another Mock Framework?<a class="headerlink" href="#why-another-mock-framework" title="Permalink to this headline">ΒΆ</a></h1>
<p>Can’t you do most of this in plain old Python? If you’re just replacing methods then yes but when you need to manage expectations, it’s not so easy.</p>
<p>Fudge started when a co-worker showed me <a class="reference external" href="http://mocha.rubyforge.org/">Mocha</a> for Ruby. I liked it because it was a much simpler version of <a class="reference external" href="http://www.jmock.org/">jMock</a> and jMock allows you to do two things at once: 1) build a fake version of a real object and 2) inspect that your code uses it correctly (post mortem). Up until now, I’ve built all my mock logic in plain Python and noticed that I spent gobs of code doing these two things in separate places. The jMock approach gets rid of the need for a post mortem and the expectation code is very readable.</p>
<p>What about all the other mock frameworks for Python? I <em>really</em> didn’t want to build another mock framework, honestly. Here were my observations of the scenery:</p>
<ul class="simple">
<li><a class="reference external" href="http://pmock.sourceforge.net/">pMock</a> (based on <a class="reference external" href="http://www.jmock.org/">jMock</a>)<ul>
<li>This of course is based on the same jMock interface that I like. However, its site claims it has not been maintained since 2004 and besides that jMock is too over engineered for my tastes and pMock does not attempt to fix that.</li>
</ul>
</li>
<li><a class="reference external" href="http://pypi.python.org/pypi/MiniMock">minimock</a><ul>
<li>As far as I can tell, there is no easy, out-of-the-box way to use minimock in anything other than a doctest.</li>
<li>It doesn’t really deal with expectations, just replacements (stubbing).</li>
</ul>
</li>
<li><a class="reference external" href="http://www.voidspace.org.uk/python/mock.html">mock</a><ul>
<li>I didn’t like how mock focused on post mortem inspection.</li>
</ul>
</li>
<li><a class="reference external" href="http://theblobshop.com/pymock/">pyMock</a> (based on <a class="reference external" href="http://www.easymock.org/">EasyMock</a>)<ul>
<li>This uses a record / playback technique whereby you act upon your real objects then flip a switch and they become fake. This seems like it has some benefits for maintenance but I’m not sure that the overhead of recording with real objects is worth it. I suppose you’d need a real database, a real web service, etc.</li>
</ul>
</li>
<li><a class="reference external" href="http://code.google.com/p/pymox/">Mox</a> (based on <a class="reference external" href="http://www.easymock.org/">EasyMock</a>)<ul>
<li>This also uses the record / playback technique but with a DSL (domain specific language). It was brought to my attention after creating Fudge but thought it was worth mentioning.</li>
</ul>
</li>
<li><a class="reference external" href="http://labix.org/mocker">mocker</a> (based on <a class="reference external" href="http://www.easymock.org/">EasyMock</a> and others)<ul>
<li>This was also <a class="reference external" href="http://farmdev.com/thoughts/70/fudge-another-python-mock-framework/">pointed out to me</a> after developing Fudge.</li>
<li>Mocker is another record / playback implementation but seems to have a cleaner interface than most. I still do not see the practicality of record / playback. How do you write tests in record mode? I am probably missing it but nowhere in the docs do I see practical examples for creating test code. Instead the examples are interactive sessions which is not how I typically write tests.</li>
<li>The docs for mocker, like docs for other tools, do not focus on any real-world problem that a mock framework can solve. This is hard for my brain. It is hard for me to look at code such as obj.hello() and imagine that this would be useful for, say, mocking out sendmail().</li>
<li>However, mocker certainly looks like it has more features than Fudge so it is worth checking out.</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="javascript.html"
title="previous chapter">Fudge For JavaScript</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="migrating-0.9-to-1.0.html"
title="next chapter">Migrating from Fudge 0.9 to 1.0</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/why-fudge.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="migrating-0.9-to-1.0.html" title="Migrating from Fudge 0.9 to 1.0"
>next</a> |</li>
<li class="right" >
<a href="javascript.html" title="Fudge For JavaScript"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">Fudge 1.1.0 documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2008, Kumar McMillan.
Last updated on December 30, 2015.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3.3.
</div>
</body>
</html>
|