Hi Chris,<div><br></div><div>Thanks for that. I'll give it a go.</div><div><br></div><div>Cheers,</div><div><br></div><div>Jack<br><br><div class="gmail_quote">On Fri, Jan 14, 2011 at 2:49 PM, Chris Withers <span dir="ltr"><<a href="mailto:chris@simplistix.co.uk">chris@simplistix.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Jack,<div class="im"><br>
<br>
On 14/01/2011 14:39, Jack Keegan wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
objects. In particular, at the moment, testing some code that needs to<br>
access hardware IOs using DLLs. I do this using Ctypes.<br>
However, on my dev machine, I don't have the same hardware so calling<br>
the DLL functions will not work as expected. Therefore I'd like to mock<br>
out the ctypes dll calls. Can you give me an indication of how you would<br></div>
go about doing this with TestFixtures? Just so you know, I use py.test for<br>
unit testing.<br>
</blockquote>
<br>
I've not used ctypes myself so let me know if things don't work ;-)<br>
<br>
I'd suggest developing mock objects to work in place of your ctypes objects. You may well find that if you're just wanting to test that the right calls are made you can use an existing mock objects such as:<br>
<br>
<a href="http://pypi.python.org/pypi/mock/" target="_blank">http://pypi.python.org/pypi/mock/</a><br>
<br>
...and then compare the method_calls attribute of the mock with what you expect it to be.<br>
<br>
TestFixtures provides some handy tools for managing the insertion and removal of mock objects, read here:<br>
<br>
<a href="http://packages.python.org/testfixtures/mocking.html" target="_blank">http://packages.python.org/testfixtures/mocking.html</a><div><div></div><div class="h5"><br>
<br>
cheers,<br>
<br>
Chris<br>
<br>
-- <br>
Simplistix - Content Management, Batch Processing & Python Consulting<br>
- <a href="http://www.simplistix.co.uk" target="_blank">http://www.simplistix.co.uk</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>The earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that in glory and in triumph they could become the momentary masters of a fraction of a dot.<br>
- Carl Sagan [Pale Blue Dot]<br>
</div>