bpo-40275: Use new test.support helper submodules in tests (GH-21743)

This commit is contained in:
Hai Shi 2020-08-06 19:51:29 +08:00 committed by GitHub
parent 52f98424a5
commit 79bb2c93f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 73 additions and 56 deletions

View file

@ -15,6 +15,7 @@ import socketserver
import test.support
from test.support import reap_children, verbose
from test.support import os_helper
from test.support import socket_helper
from test.support import threading_helper
@ -299,7 +300,7 @@ class ErrorHandlerTest(unittest.TestCase):
KeyboardInterrupt are not passed."""
def tearDown(self):
test.support.unlink(test.support.TESTFN)
os_helper.unlink(os_helper.TESTFN)
def test_sync_handled(self):
BaseErrorTestServer(ValueError)
@ -329,7 +330,7 @@ class ErrorHandlerTest(unittest.TestCase):
self.check_result(handled=False)
def check_result(self, handled):
with open(test.support.TESTFN) as log:
with open(os_helper.TESTFN) as log:
expected = 'Handler called\n' + 'Error handled\n' * handled
self.assertEqual(log.read(), expected)
@ -347,7 +348,7 @@ class BaseErrorTestServer(socketserver.TCPServer):
self.wait_done()
def handle_error(self, request, client_address):
with open(test.support.TESTFN, 'a') as log:
with open(os_helper.TESTFN, 'a') as log:
log.write('Error handled\n')
def wait_done(self):
@ -356,7 +357,7 @@ class BaseErrorTestServer(socketserver.TCPServer):
class BadHandler(socketserver.BaseRequestHandler):
def handle(self):
with open(test.support.TESTFN, 'a') as log:
with open(os_helper.TESTFN, 'a') as log:
log.write('Handler called\n')
raise self.server.exception('Test error')