Index: livetest.py
===================================================================
--- livetest.py	(revision 134:9ae0c002f903)
+++ livetest.py	(revision 136:5ea0fc2ddb18)
@@ -11,7 +11,32 @@
 import imapclient
 
-#TODO: more fetch() testing
 
 SIMPLE_MESSAGE = 'Subject: something\r\n\r\nFoo\r\n'
+
+MULTIPART_MESSAGE = """\
+From: Bob Smith <bob@smith.com>
+To: Some One <some@one.com>
+Date: Tue, 16 Mar 2010 16:45:32 +0000
+Message-ID: <1A472770E042064698CB5ADC83A12ACD39455AAB@ABC>
+MIME-Version: 1.0
+Subject: A multipart message
+Content-Type: multipart/mixed; boundary="===============1534046211=="
+
+--===============1534046211==
+Content-Type: text/html; charset="us-ascii"
+Content-Transfer-Encoding: quoted-printable
+
+<html><body>
+Here is the first part.
+</body></html>
+
+--===============1534046211==
+Content-Type: text/plain; charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+
+Here is the second part.
+
+--===============1534046211==--
+""".replace('\n', '\r\n')
 
 def is_gmail(client):
@@ -273,4 +298,32 @@
 
 
+def test_fetch(client):
+    clear_folder(client, 'INBOX')
+
+    client.select_folder('INBOX')
+    client.append('INBOX', MULTIPART_MESSAGE)
+
+    fields = ['RFC822', 'FLAGS', 'INTERNALDATE', 'ENVELOPE']
+    msg_id = client.search()[0]
+    resp = client.fetch(msg_id, fields)
+
+    assert len(resp) == 1
+    msginfo = resp[msg_id]
+
+    assert set(msginfo.keys()) == set(fields + ['SEQ'])
+    assert msginfo['SEQ'] == 1
+    assert msginfo['RFC822'] == MULTIPART_MESSAGE
+    assert isinstance(msginfo['INTERNALDATE'], datetime)
+    assert isinstance(msginfo['FLAGS'], tuple)
+    assert msginfo['ENVELOPE'] == ('Tue, 16 Mar 2010 16:45:32 +0000',
+                                   'A multipart message',
+                                   (('Bob Smith', None, 'bob', 'smith.com'),),
+                                   (('Bob Smith', None, 'bob', 'smith.com'),),
+                                   (('Bob Smith', None, 'bob', 'smith.com'),),
+                                   (('Some One', None, 'some', 'one.com'),),
+                                   None, None, None,
+                                   '<1A472770E042064698CB5ADC83A12ACD39455AAB@ABC>')
+    
+
 def assert_raises(exception_class, func, *args, **kwargs):
     try:
@@ -286,5 +339,5 @@
     '''Run a sequence of tests against the IMAP server
     '''
-    # The ordering of these tests is important
+    # The ordering of these tests is important (but shouldn't be!)
     test_capabilities(client)
     test_list_folders(client)
@@ -296,4 +349,5 @@
     test_flags(client)
     test_search(client)
+    test_fetch(client)
     test_copy(client)
 
