@@ -108,7 +108,8 @@ def test_should_return_email_index(self, mock_imap):
108
108
self .library ._imap .search .return_value = ['OK' , ['0' ]]
109
109
index = self .library .wait_for_email (sender = self .sender )
110
110
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 )
112
113
self .assertEqual (index , '0' )
113
114
114
115
@mock .patch ('ImapLibrary.IMAP4_SSL' )
@@ -122,15 +123,18 @@ def test_should_return_email_index_with_sender_filter(self, mock_imap):
122
123
self .library ._imap .search .return_value = ['OK' , ['0' ]]
123
124
index = self .library .wait_for_email (sender = self .sender )
124
125
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 )
126
128
self .assertEqual (index , '0' )
127
129
index = self .library .wait_for_email (from_email = self .sender )
128
130
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 )
130
133
self .assertEqual (index , '0' )
131
134
index = self .library .wait_for_email (fromEmail = self .sender )
132
135
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 )
134
138
self .assertEqual (index , '0' )
135
139
136
140
@mock .patch ('ImapLibrary.IMAP4_SSL' )
@@ -144,15 +148,18 @@ def test_should_return_email_index_with_recipient_filter(self, mock_imap):
144
148
self .library ._imap .search .return_value = ['OK' , ['0' ]]
145
149
index = self .library .wait_for_email (recipient = self .recipient )
146
150
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 )
148
153
self .assertEqual (index , '0' )
149
154
index = self .library .wait_for_email (to_email = self .recipient )
150
155
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 )
152
158
self .assertEqual (index , '0' )
153
159
index = self .library .wait_for_email (toEmail = self .recipient )
154
160
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 )
156
163
self .assertEqual (index , '0' )
157
164
158
165
@mock .patch ('ImapLibrary.IMAP4_SSL' )
@@ -166,7 +173,8 @@ def test_should_return_email_index_with_subject_filter(self, mock_imap):
166
173
self .library ._imap .search .return_value = ['OK' , ['0' ]]
167
174
index = self .library .wait_for_email (subject = self .subject )
168
175
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 )
170
178
self .assertEqual (index , '0' )
171
179
172
180
@mock .patch ('ImapLibrary.IMAP4_SSL' )
@@ -178,7 +186,8 @@ def test_should_return_email_index_with_text_filter(self, mock_imap):
178
186
self .library ._imap .search .return_value = ['OK' , ['0' ]]
179
187
index = self .library .wait_for_email (text = self .text )
180
188
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 )
182
191
self .assertEqual (index , '0' )
183
192
184
193
@mock .patch ('ImapLibrary.IMAP4_SSL' )
@@ -217,7 +226,8 @@ def test_should_return_email_index_from_deprecated_keyword(self, mock_imap):
217
226
self .library ._imap .search .return_value = ['OK' , ['0' ]]
218
227
index = self .library .wait_for_mail (sender = self .sender )
219
228
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 )
221
231
self .assertEqual (index , '0' )
222
232
223
233
@mock .patch ('ImapLibrary.IMAP4_SSL' )
@@ -229,7 +239,8 @@ def test_should_return_email_index_after_delay(self, mock_imap):
229
239
self .library ._imap .search .side_effect = [['OK' , ['' ]], ['OK' , ['0' ]]]
230
240
index = self .library .wait_for_email (sender = self .sender , poll_frequency = 0.2 )
231
241
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 )
233
244
self .assertEqual (index , '0' )
234
245
235
246
@mock .patch ('ImapLibrary.IMAP4_SSL' )
@@ -268,7 +279,8 @@ def test_should_raise_exception_on_search_error(self, mock_imap):
268
279
self .assertTrue ("imap.search error: NOK, [''], criteria=['FROM', '%s']" %
269
280
self .sender in context .exception )
270
281
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 )
272
284
273
285
@mock .patch ('ImapLibrary.IMAP4_SSL' )
274
286
def test_should_delete_all_emails (self , mock_imap ):
0 commit comments