diff options
Diffstat (limited to 'Lib/test/test_smtplib.py')
-rw-r--r-- | Lib/test/test_smtplib.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py index 32d2d9b..d36ab0e 100644 --- a/Lib/test/test_smtplib.py +++ b/Lib/test/test_smtplib.py @@ -1,7 +1,6 @@ import asyncore import email.utils import socket -import threading import smtpd import smtplib import io @@ -9,9 +8,14 @@ import sys import time import select -from unittest import TestCase +import unittest from test import support +try: + import threading +except ImportError: + threading = None + HOST = support.HOST if sys.platform == 'darwin': @@ -44,7 +48,8 @@ def server(evt, buf, serv): serv.close() evt.set() -class GeneralTests(TestCase): +@unittest.skipUnless(threading, 'Threading required for this test.') +class GeneralTests(unittest.TestCase): def setUp(self): self._threads = support.threading_setup() @@ -146,7 +151,8 @@ MSG_END = '------------ END MESSAGE ------------\n' # test server times out, causing the test to fail. # Test behavior of smtpd.DebuggingServer -class DebuggingServerTests(TestCase): +@unittest.skipUnless(threading, 'Threading required for this test.') +class DebuggingServerTests(unittest.TestCase): def setUp(self): # temporarily replace sys.stdout to capture DebuggingServer output @@ -241,7 +247,7 @@ class DebuggingServerTests(TestCase): self.assertEqual(self.output.getvalue(), mexpect) -class NonConnectingTests(TestCase): +class NonConnectingTests(unittest.TestCase): def testNotConnected(self): # Test various operations on an unconnected SMTP object that @@ -262,7 +268,8 @@ class NonConnectingTests(TestCase): # test response of client to a non-successful HELO message -class BadHELOServerTests(TestCase): +@unittest.skipUnless(threading, 'Threading required for this test.') +class BadHELOServerTests(unittest.TestCase): def setUp(self): self.old_stdout = sys.stdout @@ -386,7 +393,8 @@ class SimSMTPServer(smtpd.SMTPServer): # Test various SMTP & ESMTP commands/behaviors that require a simulated server # (i.e., something with more features than DebuggingServer) -class SMTPSimTests(TestCase): +@unittest.skipUnless(threading, 'Threading required for this test.') +class SMTPSimTests(unittest.TestCase): def setUp(self): self._threads = support.threading_setup() |