summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_nntplib.py
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2020-05-16 10:31:54 (GMT)
committerGitHub <noreply@github.com>2020-05-16 10:31:54 (GMT)
commitaa92a7cf210c98ad94229f282221136d846942db (patch)
tree7597182daa81b9f209cd8f5869b218bd723bffcd /Lib/test/test_nntplib.py
parent372fa3ead584876a975a61936b376259be636d27 (diff)
downloadcpython-aa92a7cf210c98ad94229f282221136d846942db.zip
cpython-aa92a7cf210c98ad94229f282221136d846942db.tar.gz
cpython-aa92a7cf210c98ad94229f282221136d846942db.tar.bz2
bpo-39305: Update nntplib to merge nntplib.NNTP and nntplib._NNTPBase (GH-19817)
Diffstat (limited to 'Lib/test/test_nntplib.py')
-rw-r--r--Lib/test/test_nntplib.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/Lib/test/test_nntplib.py b/Lib/test/test_nntplib.py
index 8d29681..1df64fa 100644
--- a/Lib/test/test_nntplib.py
+++ b/Lib/test/test_nntplib.py
@@ -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