mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-39305: Update nntplib to merge nntplib.NNTP and nntplib._NNTPBase (GH-19817)
This commit is contained in:
parent
372fa3ead5
commit
aa92a7cf21
3 changed files with 56 additions and 60 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue