mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +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.config
|
||||
|
||||
import asynchat
|
||||
import asyncore
|
||||
import codecs
|
||||
import datetime
|
||||
import errno
|
||||
import pickle
|
||||
import io
|
||||
import gc
|
||||
from http.server import HTTPServer, BaseHTTPRequestHandler
|
||||
import json
|
||||
import os
|
||||
import queue
|
||||
import re
|
||||
import select
|
||||
import smtpd
|
||||
import socket
|
||||
from socketserver import (ThreadingUDPServer, DatagramRequestHandler,
|
||||
ThreadingTCPServer, StreamRequestHandler)
|
||||
import struct
|
||||
import sys
|
||||
import tempfile
|
||||
|
@ -51,11 +44,19 @@ from test.support import TestHandler, Matcher
|
|||
import textwrap
|
||||
import time
|
||||
import unittest
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
import warnings
|
||||
import weakref
|
||||
try:
|
||||
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:
|
||||
threading = None
|
||||
try:
|
||||
|
@ -611,7 +612,8 @@ class StreamHandlerTest(BaseTest):
|
|||
# -- The following section could be moved into a server_helper.py module
|
||||
# -- 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
|
||||
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')
|
||||
|
||||
|
||||
class TestSMTPServer(smtpd.SMTPServer):
|
||||
class TestSMTPServer(smtpd.SMTPServer):
|
||||
"""
|
||||
This class implements a test SMTP server.
|
||||
|
||||
|
@ -744,7 +746,7 @@ class TestSMTPServer(smtpd.SMTPServer):
|
|||
self._thread.join(timeout)
|
||||
self._thread = None
|
||||
|
||||
class ControlMixin(object):
|
||||
class ControlMixin(object):
|
||||
"""
|
||||
This mixin is used to start a server on a separate thread, and
|
||||
shut it down programmatically. Request handling is simplified - instead
|
||||
|
@ -797,7 +799,7 @@ class ControlMixin(object):
|
|||
self.server_close()
|
||||
self.ready.clear()
|
||||
|
||||
class TestHTTPServer(ControlMixin, HTTPServer):
|
||||
class TestHTTPServer(ControlMixin, HTTPServer):
|
||||
"""
|
||||
An HTTP server which is controllable using :class:`ControlMixin`.
|
||||
|
||||
|
@ -825,7 +827,7 @@ class TestHTTPServer(ControlMixin, HTTPServer):
|
|||
HTTPServer.__init__(self, addr, DelegatingHTTPRequestHandler)
|
||||
ControlMixin.__init__(self, handler, poll_interval)
|
||||
|
||||
class TestTCPServer(ControlMixin, ThreadingTCPServer):
|
||||
class TestTCPServer(ControlMixin, ThreadingTCPServer):
|
||||
"""
|
||||
A TCP server which is controllable using :class:`ControlMixin`.
|
||||
|
||||
|
@ -856,7 +858,7 @@ class TestTCPServer(ControlMixin, ThreadingTCPServer):
|
|||
super(TestTCPServer, self).server_bind()
|
||||
self.port = self.socket.getsockname()[1]
|
||||
|
||||
class TestUDPServer(ControlMixin, ThreadingUDPServer):
|
||||
class TestUDPServer(ControlMixin, ThreadingUDPServer):
|
||||
"""
|
||||
A UDP server which is controllable using :class:`ControlMixin`.
|
||||
|
||||
|
@ -889,6 +891,7 @@ class TestUDPServer(ControlMixin, ThreadingUDPServer):
|
|||
|
||||
# - end of server_helper section
|
||||
|
||||
@unittest.skipUnless(threading, 'Threading required for this test.')
|
||||
class SMTPHandlerTest(BaseTest):
|
||||
def test_basic(self):
|
||||
sockmap = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue