@@ -108,7 +108,8 @@ def test_should_return_email_index(self, mock_imap):
108108 self .library ._imap .search .return_value = ['OK' , ['0' ]]
109109 index = self .library .wait_for_email (sender = self .sender )
110110 self .library ._imap .select .assert_called_with ()
111- self .library ._imap .search .assert_called_with (None , 'FROM' , self .sender )
111+ self .library ._imap .search .assert_called_with (None , 'FROM' , '"%s"' %
112+ self .sender )
112113 self .assertEqual (index , '0' )
113114
114115 @mock .patch ('ImapLibrary.IMAP4_SSL' )
@@ -122,15 +123,18 @@ def test_should_return_email_index_with_sender_filter(self, mock_imap):
122123 self .library ._imap .search .return_value = ['OK' , ['0' ]]
123124 index = self .library .wait_for_email (sender = self .sender )
124125 self .library ._imap .select .assert_called_with ()
125- self .library ._imap .search .assert_called_with (None , 'FROM' , self .sender )
126+ self .library ._imap .search .assert_called_with (None , 'FROM' , '"%s"' %
127+ self .sender )
126128 self .assertEqual (index , '0' )
127129 index = self .library .wait_for_email (from_email = self .sender )
128130 self .library ._imap .select .assert_called_with ()
129- self .library ._imap .search .assert_called_with (None , 'FROM' , self .sender )
131+ self .library ._imap .search .assert_called_with (None , 'FROM' , '"%s"' %
132+ self .sender )
130133 self .assertEqual (index , '0' )
131134 index = self .library .wait_for_email (fromEmail = self .sender )
132135 self .library ._imap .select .assert_called_with ()
133- self .library ._imap .search .assert_called_with (None , 'FROM' , self .sender )
136+ self .library ._imap .search .assert_called_with (None , 'FROM' , '"%s"' %
137+ self .sender )
134138 self .assertEqual (index , '0' )
135139
136140 @mock .patch ('ImapLibrary.IMAP4_SSL' )
@@ -144,15 +148,18 @@ def test_should_return_email_index_with_recipient_filter(self, mock_imap):
144148 self .library ._imap .search .return_value = ['OK' , ['0' ]]
145149 index = self .library .wait_for_email (recipient = self .recipient )
146150 self .library ._imap .select .assert_called_with ()
147- self .library ._imap .search .assert_called_with (None , 'TO' , self .recipient )
151+ self .library ._imap .search .assert_called_with (None , 'TO' , '"%s"' %
152+ self .recipient )
148153 self .assertEqual (index , '0' )
149154 index = self .library .wait_for_email (to_email = self .recipient )
150155 self .library ._imap .select .assert_called_with ()
151- self .library ._imap .search .assert_called_with (None , 'TO' , self .recipient )
156+ self .library ._imap .search .assert_called_with (None , 'TO' , '"%s"' %
157+ self .recipient )
152158 self .assertEqual (index , '0' )
153159 index = self .library .wait_for_email (toEmail = self .recipient )
154160 self .library ._imap .select .assert_called_with ()
155- self .library ._imap .search .assert_called_with (None , 'TO' , self .recipient )
161+ self .library ._imap .search .assert_called_with (None , 'TO' , '"%s"' %
162+ self .recipient )
156163 self .assertEqual (index , '0' )
157164
158165 @mock .patch ('ImapLibrary.IMAP4_SSL' )
@@ -166,7 +173,8 @@ def test_should_return_email_index_with_subject_filter(self, mock_imap):
166173 self .library ._imap .search .return_value = ['OK' , ['0' ]]
167174 index = self .library .wait_for_email (subject = self .subject )
168175 self .library ._imap .select .assert_called_with ()
169- self .library ._imap .search .assert_called_with (None , 'SUBJECT' , self .subject )
176+ self .library ._imap .search .assert_called_with (None , 'SUBJECT' , '"%s"' %
177+ self .subject )
170178 self .assertEqual (index , '0' )
171179
172180 @mock .patch ('ImapLibrary.IMAP4_SSL' )
@@ -178,7 +186,8 @@ def test_should_return_email_index_with_text_filter(self, mock_imap):
178186 self .library ._imap .search .return_value = ['OK' , ['0' ]]
179187 index = self .library .wait_for_email (text = self .text )
180188 self .library ._imap .select .assert_called_with ()
181- self .library ._imap .search .assert_called_with (None , 'TEXT' , self .text )
189+ self .library ._imap .search .assert_called_with (None , 'TEXT' , '"%s"' %
190+ self .text )
182191 self .assertEqual (index , '0' )
183192
184193 @mock .patch ('ImapLibrary.IMAP4_SSL' )
@@ -217,7 +226,8 @@ def test_should_return_email_index_from_deprecated_keyword(self, mock_imap):
217226 self .library ._imap .search .return_value = ['OK' , ['0' ]]
218227 index = self .library .wait_for_mail (sender = self .sender )
219228 self .library ._imap .select .assert_called_with ()
220- self .library ._imap .search .assert_called_with (None , 'FROM' , self .sender )
229+ self .library ._imap .search .assert_called_with (None , 'FROM' , '"%s"' %
230+ self .sender )
221231 self .assertEqual (index , '0' )
222232
223233 @mock .patch ('ImapLibrary.IMAP4_SSL' )
@@ -229,7 +239,8 @@ def test_should_return_email_index_after_delay(self, mock_imap):
229239 self .library ._imap .search .side_effect = [['OK' , ['' ]], ['OK' , ['0' ]]]
230240 index = self .library .wait_for_email (sender = self .sender , poll_frequency = 0.2 )
231241 self .library ._imap .select .assert_called_with ()
232- self .library ._imap .search .assert_called_with (None , 'FROM' , self .sender )
242+ self .library ._imap .search .assert_called_with (None , 'FROM' , '"%s"' %
243+ self .sender )
233244 self .assertEqual (index , '0' )
234245
235246 @mock .patch ('ImapLibrary.IMAP4_SSL' )
@@ -268,7 +279,8 @@ def test_should_raise_exception_on_search_error(self, mock_imap):
268279 self .assertTrue ("imap.search error: NOK, [''], criteria=['FROM', '%s']" %
269280 self .sender in context .exception )
270281 self .library ._imap .select .assert_called_with ()
271- self .library ._imap .search .assert_called_with (None , 'FROM' , self .sender )
282+ self .library ._imap .search .assert_called_with (None , 'FROM' , '"%s"' %
283+ self .sender )
272284
273285 @mock .patch ('ImapLibrary.IMAP4_SSL' )
274286 def test_should_delete_all_emails (self , mock_imap ):
0 commit comments