mò
­fIc           @   sš   d  k  Z  d  k Z d  k Z d k l Z y d k l Z Wn  e j
 o d k l Z n Xd e i f d „  ƒ  YZ	 d „  Z
 e d j o e
 ƒ  n d  S(   N(   s   test_support(   s   StringIOt   MessageTestCasec           B   s˜   t  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   Nc         C   s   t  i t | ƒ ƒ S(   N(   t   rfc822t   Messaget   StringIOt   msg(   t   selfR   (    (    t-   /mit/python/lib/python2.4/test/test_rfc822.pyt   create_message   s    c         C   s†   |  i d ƒ } |  i | i d ƒ d j ƒ |  i | i d ƒ d j ƒ |  i | i d ƒ d  j ƒ |  i | i d d ƒ d j ƒ d  S(   Ns)   To: "last, first" <userid@foo.net>

test
t   tos   "last, first" <userid@foo.net>t   TOs   No-Such-Headers   No-Such-Value(   R   R   R   t   assert_t   gett   None(   R   R   (    (    R   t   test_get   s
    c         C   s²   |  i d ƒ } |  i | i d ƒ ƒ |  i | i d d ƒ d j ƒ |  i | i d d ƒ d j ƒ |  i | d d j ƒ |  i | i d ƒ d j ƒ |  i | d d j ƒ d  S(	   Ns)   To: "last, first" <userid@foo.net>

test
s
   New-Headers	   New-Values   Different-Values
   new-headers   Another-Headert    s   another-header(   R   R   R   R
   t   has_keyt
   setdefault(   R   R   (    (    R   t   test_setdefault   s    c   
      C   sE  |  i | ƒ } d } xü | i d ƒ | i d ƒ D]Þ \ } } y! | | d | | d } } Wn/ t j
 o# d Gt | ƒ Gt | ƒ GHq2 n X| d } |  i | | d | | f ƒ |  i | | d | | f ƒ | | j o | | j o q2 d Gt | ƒ Gt | ƒ GHq2 W| i d	 ƒ }	 |	 o |  i |	 d d ƒ n d S(   s   Check addresses and the date.i    R   t   cci   s   extra parsed address:s   Un-expected name: %s != %ss   Un-expected address: %s != %ss
   not found:t   dateiÏ  i   i   i9   i#   s   date conversion failedN(	   iÏ  i   i   i   i9   i#   i    i   i    (   R   R   R   t   mt   it   getaddrlistt   nt   at   resultst   mnt   mat
   IndexErrort   reprt   assertEqualt   getdatet   out(
   R   R   R   R   R   R   R   R   R   R    (    (    R   t   check%   s.      !
	c      	   C   s›   |  i d d g ƒ |  i d d g ƒ |  i d d d g ƒ |  i d d g ƒ |  i d
 d  d! d" d# d$ d% g ƒ |  i d d& g ƒ |  i d d' g ƒ d  S((   Ns¦   Date:    Wed, 13 Jan 1999 23:57:35 -0500
From:    Guido van Rossum <guido@CNRI.Reston.VA.US>
To:      "Guido van
	 : Rossum" <guido@python.org>
Subject: test2

test2
s   Guido van
	 : Rossums   guido@python.orgs“   From: Barry <bwarsaw@python.org
To: guido@python.org (Guido: the Barbarian)
Subject: nonsense
Date: Wednesday, January 13 1999 23:57:35 -0500

tests   Guido: the Barbariansœ   From: Barry <bwarsaw@python.org
To: guido@python.org (Guido: the Barbarian)
Cc: "Guido: the Madman" <guido@python.org>
Date:  13-Jan-1999 23:57:35 EST

tests   Guido: the Madmansw   To: "The monster with
     the very long name: Guido" <guido@python.org>
Date:    Wed, 13 Jan 1999 23:57:35 -0500

tests/   The monster with
     the very long name: Guidosô   To: "Amit J. Patel" <amitp@Theory.Stanford.EDU>
CC: Mike Fletcher <mfletch@vrtelecom.com>,
        "'string-sig@python.org'" <string-sig@python.org>
Cc: fooz@bat.com, bart@toof.com
Cc: goit@lip.com
Date:    Wed, 13 Jan 1999 23:57:35 -0500

tests   Amit J. Patels   amitp@Theory.Stanford.EDUs   Mike Fletchers   mfletch@vrtelecom.coms   'string-sig@python.org's   string-sig@python.orgR   s   fooz@bat.coms   bart@toof.coms   goit@lip.comsV   To: Some One <someone@dom.ain>
From: Anudder Persin <subuddy.else@dom.ain>
Date:

tests   Some Ones   someone@dom.ains%   To: person@dom.ain (User J. Person)

s   User J. Persons   person@dom.ain(   s   Guido van
	 : Rossums   guido@python.org(   s   Guido: the Barbarians   guido@python.org(   s   Guido: the Barbarians   guido@python.org(   s   Guido: the Madmans   guido@python.org(   s/   The monster with
     the very long name: Guidos   guido@python.org(   s   Amit J. Patels   amitp@Theory.Stanford.EDU(   s   Mike Fletchers   mfletch@vrtelecom.com(   s   'string-sig@python.org's   string-sig@python.org(   R   s   fooz@bat.com(   R   s   bart@toof.com(   R   s   goit@lip.com(   s   Some Ones   someone@dom.ain(   s   User J. Persons   person@dom.ain(   R   R!   (   R   (    (    R   t
   test_basicC   s    	
	
		
			
	c         C   s   |  i d d d g ƒ d  S(   Ns?   To: person@dom.ain ((User J. Person)), John Doe <foo@bar.com>

s   User J. Persons   person@dom.ains   John Does   foo@bar.com(   s   User J. Persons   person@dom.ain(   s   John Does   foo@bar.com(   R   R!   (   R   (    (    R   t   test_doublecommentˆ   s    	c         C   s   |  i d d d d g ƒ d  S(   Nsr   To: <[smtp:dd47@mail.xxx.edu]_at_hmhq@hdq-mdm1-imgout.companay.com>
Date:    Wed, 13 Jan 1999 23:57:35 -0500

testR   s   dd47@mail.xxx.edus%   _at_hmhq@hdq-mdm1-imgout.companay.com(   R   R   (   R   s   dd47@mail.xxx.edu(   R   s%   _at_hmhq@hdq-mdm1-imgout.companay.com(   R   R!   (   R   (    (    R   t   test_twistedŽ   s    	c         C   s   |  i d d g ƒ d  S(   Ns(   To: "last, first" <userid@foo.net>

tests   last, firsts   userid@foo.net(   s   last, firsts   userid@foo.net(   R   R!   (   R   (    (    R   t   test_commas_in_full_nameœ   s    	c         C   s   |  i d d g ƒ d  S(   Ns5   To: (Comment stuff) "Quoted name"@somewhere.com

tests   Comment stuffs   "Quoted name"@somewhere.com(   s   Comment stuffs   "Quoted name"@somewhere.com(   R   R!   (   R   (    (    R   t   test_quoted_name¦   s    	c         C   s   |  i d d g ƒ d  S(   NsE   To: :
Cc: goit@lip.com
Date:    Wed, 13 Jan 1999 23:57:35 -0500

testR   s   goit@lip.com(   R   s   goit@lip.com(   R   R!   (   R   (    (    R   t   test_bogus_to_header­   s    	c         C   s   |  i d d g ƒ d  S(   Ns   To: guido@[132.151.1.21]

fooR   s   guido@[132.151.1.21](   R   s   guido@[132.151.1.21](   R   R!   (   R   (    (    R   t   test_addr_ipquad¶   s    	c         C   s;   t  i t d ƒ ƒ } |  i t | ƒ d d d d g ƒ d  S(   Ns¦   Date:    Wed, 13 Jan 1999 23:57:35 -0500
From:    Guido van Rossum <guido@CNRI.Reston.VA.US>
To:      "Guido van
	 : Rossum" <guido@python.org>
Subject: test2

test2
R   t   fromt   subjectR   (   R   R   R   R   R   R   t   sorted(   R   R   (    (    R   t	   test_iter½   s    c         C   s   |  i d d g ƒ d  S(   Ns%   To: User J. Person <person@dom.ain>

s   User J. Persons   person@dom.ain(   s   User J. Persons   person@dom.ain(   R   R!   (   R   (    (    R   t   test_rfc2822_phrasesÈ   s    	c         C   s˜   |  i } |  i d ƒ } g  } d d d g D] } | d | f q, ~ } | i d ƒ } | i
 ƒ  | | | ƒ | i d ƒ } | i
 ƒ  | | | ƒ d  S(   Nsa   To: aperson@dom.ain
Cc: bperson@dom.ain
Cc: cperson@dom.ain
Cc: dperson@dom.ain

A test message.
s   bperson@dom.ains   cperson@dom.ains   dperson@dom.ainR   R   (   R   R   t   eqR   R   t   _[1]R   t   ccsR   t   addrst   sort(   R   R   R0   R/   R1   R   R.   (    (    R   t   test_2getaddrlistÙ   s    	0

c         C   se   |  i } | t i d ƒ d
 ƒ | t i d ƒ d ƒ | t i d ƒ d ƒ | t i d ƒ d ƒ d  S(   Ns   <>R   s   aperson@dom.ains   bperson@dom.ain (Bea A. Person)s   Bea A. Persons   bperson@dom.ains    Cynthia Person <cperson@dom.ain>s   Cynthia Persons   cperson@dom.ain(   R   R   (   R   s   aperson@dom.ain(   s   Bea A. Persons   bperson@dom.ain(   s   Cynthia Persons   cperson@dom.ain(   R   R   R.   R   t	   parseaddr(   R   R.   (    (    R   t   test_parseaddrí   s    	c         C   s9   |  i } | t i d ƒ d ƒ | t i d ƒ d ƒ d  S(   Ns   foo\wacky"names   foo\\wacky\"names   "foo\\wacky\"name"(   R   R   R.   R   t   quotet   unquote(   R   R.   (    (    R   t   test_quote_unquoteö   s    	(   t   __name__t
   __module__R   R   R   R!   R"   R#   R$   R%   R&   R'   R(   R,   R-   R3   R5   R8   (    (    (    R   R       s    						E			
									c           C   s   t  i t ƒ d  S(   N(   t   test_supportt   run_unittestR    (    (    (    R   t	   test_mainü   s    t   __main__(   R   t   syst   unittestt   testR;   t	   cStringIOR   t   ImportErrort   TestCaseR    R=   R9   (   R;   R   R@   R   R?   R=   R    (    (    R   t   ?   s   			ð	