|
@@ -3,17 +3,30 @@ from nose.tools import assert_raises
|
3
|
3
|
from resetpassword.lib import _plain_send_mail
|
4
|
4
|
|
5
|
5
|
from tracim.tests import TestStandard
|
6
|
|
-from smtplib import SMTPNotSupportedError
|
7
|
6
|
|
8
|
7
|
class TestSerializers(TestStandard):
|
9
|
8
|
application_under_test = 'nosmtp'
|
10
|
9
|
|
11
|
10
|
def test_unit__plain_send_mail__ok(self):
|
12
|
|
- assert_raises(
|
13
|
|
- (ConnectionRefusedError, SMTPNotSupportedError),
|
14
|
|
- _plain_send_mail,
|
15
|
|
- 'Name of sender <email@sender.local>',
|
16
|
|
- 'Recipient name <recipient@recipient.local>',
|
17
|
|
- 'hello',
|
18
|
|
- 'How are you ?',
|
19
|
|
- )
|
|
11
|
+ import sys
|
|
12
|
+ if sys.version_info >= (3, 5):
|
|
13
|
+ from smtplib import SMTPNotSupportedError
|
|
14
|
+
|
|
15
|
+ assert_raises(
|
|
16
|
+ (ConnectionRefusedError, SMTPNotSupportedError),
|
|
17
|
+ _plain_send_mail,
|
|
18
|
+ 'Name of sender <email@sender.local>',
|
|
19
|
+ 'Recipient name <recipient@recipient.local>',
|
|
20
|
+ 'hello',
|
|
21
|
+ 'How are you ?',
|
|
22
|
+ )
|
|
23
|
+ else:
|
|
24
|
+ from smtplib import SMTPException
|
|
25
|
+ assert_raises(
|
|
26
|
+ (SMTPException, ConnectionRefusedError),
|
|
27
|
+ _plain_send_mail,
|
|
28
|
+ 'Name of sender <email@sender.local>',
|
|
29
|
+ 'Recipient name <recipient@recipient.local>',
|
|
30
|
+ 'hello',
|
|
31
|
+ 'How are you ?',
|
|
32
|
+ )
|