mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Skip some more tests in the absence of threading.
This commit is contained in:
parent
362ce37963
commit
ce7c978140
1 changed files with 251 additions and 248 deletions
|
@ -25,24 +25,17 @@ import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
import logging.config
|
import logging.config
|
||||||
|
|
||||||
import asynchat
|
|
||||||
import asyncore
|
|
||||||
import codecs
|
import codecs
|
||||||
import datetime
|
import datetime
|
||||||
import errno
|
|
||||||
import pickle
|
import pickle
|
||||||
import io
|
import io
|
||||||
import gc
|
import gc
|
||||||
from http.server import HTTPServer, BaseHTTPRequestHandler
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import queue
|
import queue
|
||||||
import re
|
import re
|
||||||
import select
|
import select
|
||||||
import smtpd
|
|
||||||
import socket
|
import socket
|
||||||
from socketserver import (ThreadingUDPServer, DatagramRequestHandler,
|
|
||||||
ThreadingTCPServer, StreamRequestHandler)
|
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -51,11 +44,19 @@ from test.support import TestHandler, Matcher
|
||||||
import textwrap
|
import textwrap
|
||||||
import time
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
from urllib.parse import urlparse, parse_qs
|
|
||||||
import warnings
|
import warnings
|
||||||
import weakref
|
import weakref
|
||||||
try:
|
try:
|
||||||
import threading
|
import threading
|
||||||
|
# The following imports are needed only for tests which
|
||||||
|
import asynchat
|
||||||
|
import asyncore
|
||||||
|
import errno
|
||||||
|
from http.server import HTTPServer, BaseHTTPRequestHandler
|
||||||
|
import smtpd
|
||||||
|
from urllib.parse import urlparse, parse_qs
|
||||||
|
from socketserver import (ThreadingUDPServer, DatagramRequestHandler,
|
||||||
|
ThreadingTCPServer, StreamRequestHandler)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
threading = None
|
threading = None
|
||||||
try:
|
try:
|
||||||
|
@ -611,7 +612,8 @@ class StreamHandlerTest(BaseTest):
|
||||||
# -- The following section could be moved into a server_helper.py module
|
# -- The following section could be moved into a server_helper.py module
|
||||||
# -- if it proves to be of wider utility than just test_logging
|
# -- if it proves to be of wider utility than just test_logging
|
||||||
|
|
||||||
class TestSMTPChannel(smtpd.SMTPChannel):
|
if threading:
|
||||||
|
class TestSMTPChannel(smtpd.SMTPChannel):
|
||||||
"""
|
"""
|
||||||
This derived class has had to be created because smtpd does not
|
This derived class has had to be created because smtpd does not
|
||||||
support use of custom channel maps, although they are allowed by
|
support use of custom channel maps, although they are allowed by
|
||||||
|
@ -644,7 +646,7 @@ class TestSMTPChannel(smtpd.SMTPChannel):
|
||||||
self.set_terminator(b'\r\n')
|
self.set_terminator(b'\r\n')
|
||||||
|
|
||||||
|
|
||||||
class TestSMTPServer(smtpd.SMTPServer):
|
class TestSMTPServer(smtpd.SMTPServer):
|
||||||
"""
|
"""
|
||||||
This class implements a test SMTP server.
|
This class implements a test SMTP server.
|
||||||
|
|
||||||
|
@ -744,7 +746,7 @@ class TestSMTPServer(smtpd.SMTPServer):
|
||||||
self._thread.join(timeout)
|
self._thread.join(timeout)
|
||||||
self._thread = None
|
self._thread = None
|
||||||
|
|
||||||
class ControlMixin(object):
|
class ControlMixin(object):
|
||||||
"""
|
"""
|
||||||
This mixin is used to start a server on a separate thread, and
|
This mixin is used to start a server on a separate thread, and
|
||||||
shut it down programmatically. Request handling is simplified - instead
|
shut it down programmatically. Request handling is simplified - instead
|
||||||
|
@ -797,7 +799,7 @@ class ControlMixin(object):
|
||||||
self.server_close()
|
self.server_close()
|
||||||
self.ready.clear()
|
self.ready.clear()
|
||||||
|
|
||||||
class TestHTTPServer(ControlMixin, HTTPServer):
|
class TestHTTPServer(ControlMixin, HTTPServer):
|
||||||
"""
|
"""
|
||||||
An HTTP server which is controllable using :class:`ControlMixin`.
|
An HTTP server which is controllable using :class:`ControlMixin`.
|
||||||
|
|
||||||
|
@ -825,7 +827,7 @@ class TestHTTPServer(ControlMixin, HTTPServer):
|
||||||
HTTPServer.__init__(self, addr, DelegatingHTTPRequestHandler)
|
HTTPServer.__init__(self, addr, DelegatingHTTPRequestHandler)
|
||||||
ControlMixin.__init__(self, handler, poll_interval)
|
ControlMixin.__init__(self, handler, poll_interval)
|
||||||
|
|
||||||
class TestTCPServer(ControlMixin, ThreadingTCPServer):
|
class TestTCPServer(ControlMixin, ThreadingTCPServer):
|
||||||
"""
|
"""
|
||||||
A TCP server which is controllable using :class:`ControlMixin`.
|
A TCP server which is controllable using :class:`ControlMixin`.
|
||||||
|
|
||||||
|
@ -856,7 +858,7 @@ class TestTCPServer(ControlMixin, ThreadingTCPServer):
|
||||||
super(TestTCPServer, self).server_bind()
|
super(TestTCPServer, self).server_bind()
|
||||||
self.port = self.socket.getsockname()[1]
|
self.port = self.socket.getsockname()[1]
|
||||||
|
|
||||||
class TestUDPServer(ControlMixin, ThreadingUDPServer):
|
class TestUDPServer(ControlMixin, ThreadingUDPServer):
|
||||||
"""
|
"""
|
||||||
A UDP server which is controllable using :class:`ControlMixin`.
|
A UDP server which is controllable using :class:`ControlMixin`.
|
||||||
|
|
||||||
|
@ -889,6 +891,7 @@ class TestUDPServer(ControlMixin, ThreadingUDPServer):
|
||||||
|
|
||||||
# - end of server_helper section
|
# - end of server_helper section
|
||||||
|
|
||||||
|
@unittest.skipUnless(threading, 'Threading required for this test.')
|
||||||
class SMTPHandlerTest(BaseTest):
|
class SMTPHandlerTest(BaseTest):
|
||||||
def test_basic(self):
|
def test_basic(self):
|
||||||
sockmap = {}
|
sockmap = {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue