Hi Chris, Thanks for that. I'll give it a go.
Cheers, Jack On Fri, Jan 14, 2011 at 2:49 PM, Chris Withers <ch...@simplistix.co.uk>wrote: > Hi Jack, > > > On 14/01/2011 14:39, Jack Keegan wrote: > >> objects. In particular, at the moment, testing some code that needs to >> access hardware IOs using DLLs. I do this using Ctypes. >> However, on my dev machine, I don't have the same hardware so calling >> the DLL functions will not work as expected. Therefore I'd like to mock >> out the ctypes dll calls. Can you give me an indication of how you would >> go about doing this with TestFixtures? Just so you know, I use py.test for >> unit testing. >> > > I've not used ctypes myself so let me know if things don't work ;-) > > 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: > > http://pypi.python.org/pypi/mock/ > > ...and then compare the method_calls attribute of the mock with what you > expect it to be. > > TestFixtures provides some handy tools for managing the insertion and > removal of mock objects, read here: > > http://packages.python.org/testfixtures/mocking.html > > > cheers, > > Chris > > -- > Simplistix - Content Management, Batch Processing & Python Consulting > - http://www.simplistix.co.uk > -- 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. - Carl Sagan [Pale Blue Dot]
-- http://mail.python.org/mailman/listinfo/python-list