Browse Source

fixes test resetpassword (different smtp exception raised between python 3.4 and python 3.5)

Damien Accorsi 7 years ago
parent
commit
b8858b1bef
1 changed files with 22 additions and 9 deletions
  1. 22 9
      tracim/tracim/tests/library/test_resetpassword.py

+ 22 - 9
tracim/tracim/tests/library/test_resetpassword.py View File

@@ -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
+            )