@@ -988,6 +988,34 @@ def assertMailboxEmpty(self):
988
988
with open (self ._path ) as f :
989
989
self .assertEqual (f .readlines (), [])
990
990
991
+ def test_get_bytes_from (self ):
992
+ # Get bytes representations of messages with _unixfrom.
993
+ unixfrom = 'From foo@bar blah\n '
994
+ key0 = self ._box .add (unixfrom + self ._template % 0 )
995
+ key1 = self ._box .add (unixfrom + _sample_message )
996
+ self .assertEqual (self ._box .get_bytes (key0 , from_ = False ),
997
+ (self ._template % 0 ).encode ('ascii' ))
998
+ self .assertEqual (self ._box .get_bytes (key1 , from_ = False ),
999
+ _bytes_sample_message )
1000
+ self .assertEqual (self ._box .get_bytes (key0 , from_ = True ),
1001
+ (unixfrom + self ._template % 0 ).encode ('ascii' ))
1002
+ self .assertEqual (self ._box .get_bytes (key1 , from_ = True ),
1003
+ unixfrom .encode ('ascii' ) + _bytes_sample_message )
1004
+
1005
+ def test_get_string_from (self ):
1006
+ # Get string representations of messages with _unixfrom.
1007
+ unixfrom = 'From foo@bar blah\n '
1008
+ key0 = self ._box .add (unixfrom + self ._template % 0 )
1009
+ key1 = self ._box .add (unixfrom + _sample_message )
1010
+ self .assertEqual (self ._box .get_string (key0 , from_ = False ),
1011
+ self ._template % 0 )
1012
+ self .assertEqual (self ._box .get_string (key1 , from_ = False ).split ('\n ' ),
1013
+ _sample_message .split ('\n ' ))
1014
+ self .assertEqual (self ._box .get_string (key0 , from_ = True ),
1015
+ unixfrom + self ._template % 0 )
1016
+ self .assertEqual (self ._box .get_string (key1 , from_ = True ).split ('\n ' ),
1017
+ (unixfrom + _sample_message ).split ('\n ' ))
1018
+
991
1019
def test_add_from_string (self ):
992
1020
# Add a string starting with 'From ' to the mailbox
993
1021
key = self ._box .add ('From foo@bar blah\n From: foo\n \n 0\n ' )
0 commit comments