bpo-39305: Update nntplib to merge nntplib.NNTP and nntplib._NNTPBase (GH-19817)

This commit is contained in:
Dong-hee Na 2020-05-16 19:31:54 +09:00 committed by GitHub
parent 372fa3ead5
commit aa92a7cf21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 60 deletions

View file

@ -5,6 +5,7 @@ import textwrap
import unittest
import functools
import contextlib
import nntplib
import os.path
import re
import threading
@ -12,7 +13,6 @@ import threading
from test import support
from test.support import socket_helper
from nntplib import NNTP, GroupInfo
import nntplib
from unittest.mock import patch
try:
import ssl
@ -411,6 +411,18 @@ def make_mock_file(handler):
return (sio, file)
class NNTPServer(nntplib.NNTP):
def __init__(self, f, host, readermode=None):
self.file = f
self.host = host
self._base_init(readermode)
def _close(self):
self.file.close()
del self.file
class MockedNNTPTestsMixin:
# Override in derived classes
handler_class = None
@ -426,7 +438,7 @@ class MockedNNTPTestsMixin:
def make_server(self, *args, **kwargs):
self.handler = self.handler_class()
self.sio, file = make_mock_file(self.handler)
self.server = nntplib._NNTPBase(file, 'test.server', *args, **kwargs)
self.server = NNTPServer(file, 'test.server', *args, **kwargs)
return self.server