[TIP] (Unit | Functional) testing of imaplib apps .

Menno Smits menno at freshfoo.com
Wed Nov 10 05:39:59 PST 2010


On 11/01/2010 07:31 PM, Tom Wardill wrote:
> On Mon, 2010-11-01 at 08:46 -0500, Olemis Lang wrote:
>> Hi !
>>
>> I'm developing an IMAP4-based app using `imaplib` . I'd like to know
>> what's used to either mock (for unit tests) or launch a lightweight
>> (in-memory ?) IMAP server (for functional tests), and how to
>> setup all this at testing-time.
>>
>> Right now what I do is to use a local `hMailServer` instance on
>> Windows , but it's so «lightweight» that I even had to install
>> MySql and ... to make it work . So I'm hoping there's something
>> out there like `twill` or `wsgi_intercept` that may help under
>> these circumstances .
>>
>> Thnx in advance !
>>
>>
>
>
> Hi.
>
> In a similar situation, I created this:
>
> http://github.com/tomwardill/FakeEmail
>
> It's a standalone server, using twisted to run, so perhaps not as
> lightweight as could be, but is in memory (and multi threaded), and
> allows JSON access as well as web based for functional testing/poking.
> Has a buildout for easy installation, should work pretty much wherever
> python is available.
>
> Hope this helps, suggestions to make it better accepted eagerly.

Very interesting! I might use this to extend the functional testing of 
IMAPClient[1]. Right now I've been running automated tests against test 
accounts on various real IMAP servers. This is valuable because there's 
differences in behavior between different IMAP implementations but it 
also means that I'm not the only one who runs then functional tests 
because not many people have multiple test accounts lying around.

A little off topic but Olemis, if you're not too far down the track with 
your project you may want to consider using IMAPClient instead of 
imaplib. It will make your life a lot easier - imaplib is a real pain to 
use.

Regards,
Menno

[1] - http://imapclient.freshfoo.com/





More information about the testing-in-python mailing list