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

This commit is contained in:
Hai Shi 2020-06-25 20:15:40 +08:00 committed by GitHub
parent 91698d8caa
commit 06a40d7359
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 29 additions and 21 deletions

View file

@ -16,6 +16,7 @@ from asyncio import constants
from test.test_asyncio import utils as test_utils
from test import support
from test.support.script_helper import assert_python_ok
from test.support import os_helper
from test.support import socket_helper
@ -1983,14 +1984,14 @@ class BaseLoopSockSendfileTests(test_utils.TestCase):
def setUpClass(cls):
cls.__old_bufsize = constants.SENDFILE_FALLBACK_READBUFFER_SIZE
constants.SENDFILE_FALLBACK_READBUFFER_SIZE = 1024 * 16
with open(support.TESTFN, 'wb') as fp:
with open(os_helper.TESTFN, 'wb') as fp:
fp.write(cls.DATA)
super().setUpClass()
@classmethod
def tearDownClass(cls):
constants.SENDFILE_FALLBACK_READBUFFER_SIZE = cls.__old_bufsize
support.unlink(support.TESTFN)
os_helper.unlink(os_helper.TESTFN)
super().tearDownClass()
def setUp(self):
@ -1998,7 +1999,7 @@ class BaseLoopSockSendfileTests(test_utils.TestCase):
# BaseSelectorEventLoop() has no native implementation
self.loop = BaseSelectorEventLoop()
self.set_event_loop(self.loop)
self.file = open(support.TESTFN, 'rb')
self.file = open(os_helper.TESTFN, 'rb')
self.addCleanup(self.file.close)
super().setUp()
@ -2095,7 +2096,7 @@ class BaseLoopSockSendfileTests(test_utils.TestCase):
def test_nonbinary_file(self):
sock = self.make_socket()
with open(support.TESTFN, 'r') as f:
with open(os_helper.TESTFN, 'r') as f:
with self.assertRaisesRegex(ValueError, "binary mode"):
self.run_loop(self.loop.sock_sendfile(sock, f))