summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2020-07-06 12:29:49 (GMT)
committerGitHub <noreply@github.com>2020-07-06 12:29:49 (GMT)
commitdeb016224cc506503fb05e821a60158c83918ed4 (patch)
tree21b683e93134e016806477e15df1211567441301 /Lib/test
parentb4a9263708cc67c98c4d53b16933f6e5dd07990f (diff)
downloadcpython-deb016224cc506503fb05e821a60158c83918ed4.zip
cpython-deb016224cc506503fb05e821a60158c83918ed4.tar.gz
cpython-deb016224cc506503fb05e821a60158c83918ed4.tar.bz2
bpo-40275: Use new test.support helper submodules in tests (GH-21317)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_dbm_gnu.py3
-rw-r--r--Lib/test/test_eof.py3
-rw-r--r--Lib/test/test_hashlib.py3
-rw-r--r--Lib/test/test_idle.py2
-rw-r--r--Lib/test/test_imaplib.py3
-rw-r--r--Lib/test/test_marshal.py73
-rw-r--r--Lib/test/test_py_compile.py2
-rw-r--r--Lib/test/test_set.py3
-rwxr-xr-xLib/test/test_socket.py57
-rw-r--r--Lib/test/test_sysconfig.py8
-rw-r--r--Lib/test/test_traceback.py3
-rw-r--r--Lib/test/test_unicode.py12
-rw-r--r--Lib/test/test_xml_etree.py21
-rw-r--r--Lib/test/test_zipfile.py7
14 files changed, 109 insertions, 91 deletions
diff --git a/Lib/test/test_dbm_gnu.py b/Lib/test/test_dbm_gnu.py
index f1c7d34..078bf0e 100644
--- a/Lib/test/test_dbm_gnu.py
+++ b/Lib/test/test_dbm_gnu.py
@@ -1,5 +1,6 @@
from test import support
-gdbm = support.import_module("dbm.gnu") #skip if not supported
+from test.support import import_helper
+gdbm = import_helper.import_module("dbm.gnu") #skip if not supported
import unittest
import os
from test.support import TESTFN, TESTFN_NONASCII, unlink
diff --git a/Lib/test/test_eof.py b/Lib/test/test_eof.py
index 51cbbd8..2cf263d 100644
--- a/Lib/test/test_eof.py
+++ b/Lib/test/test_eof.py
@@ -2,6 +2,7 @@
import sys
from test import support
+from test.support import os_helper
from test.support import script_helper
import unittest
@@ -48,7 +49,7 @@ class EOFTestCase(unittest.TestCase):
@unittest.skipIf(not sys.executable, "sys.executable required")
def test_line_continuation_EOF_from_file_bpo2180(self):
"""Ensure tok_nextc() does not add too many ending newlines."""
- with support.temp_dir() as temp_dir:
+ with os_helper.temp_dir() as temp_dir:
file_name = script_helper.make_script(temp_dir, 'foo', '\\')
rc, out, err = script_helper.assert_python_failure(file_name)
self.assertIn(b'unexpected EOF while parsing', err)
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
index ba90298..4551011 100644
--- a/Lib/test/test_hashlib.py
+++ b/Lib/test/test_hashlib.py
@@ -18,7 +18,8 @@ import threading
import unittest
import warnings
from test import support
-from test.support import _4G, bigmemtest, import_fresh_module
+from test.support import _4G, bigmemtest
+from test.support.import_helper import import_fresh_module
from test.support import threading_helper
from http.client import HTTPException
diff --git a/Lib/test/test_idle.py b/Lib/test/test_idle.py
index 8bc01de..b205d35 100644
--- a/Lib/test/test_idle.py
+++ b/Lib/test/test_idle.py
@@ -1,5 +1,5 @@
import unittest
-from test.support import import_module
+from test.support.import_helper import import_module
# Skip test_idle if _tkinter wasn't built, if tkinter is missing,
# if tcl/tk is not the 8.5+ needed for ttk widgets,
diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py
index b8ab677..96bcb09 100644
--- a/Lib/test/test_imaplib.py
+++ b/Lib/test/test_imaplib.py
@@ -14,6 +14,7 @@ from test.support import (verbose,
run_with_tz, run_with_locale, cpython_only)
from test.support import hashlib_helper
from test.support import threading_helper
+from test.support import warnings_helper
import unittest
from unittest import mock
from datetime import datetime, timezone, timedelta
@@ -575,7 +576,7 @@ class NewIMAPSSLTests(NewIMAPTestsMixin, unittest.TestCase):
# to CPython stdlib
@cpython_only
def test_certfile_arg_warn(self):
- with support.check_warnings(('', DeprecationWarning)):
+ with warnings_helper.check_warnings(('', DeprecationWarning)):
with mock.patch.object(self.imap_class, 'open'):
with mock.patch.object(self.imap_class, '_connect'):
self.imap_class('localhost', 143, certfile=CERTFILE)
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py
index b7f4dbb..7bcf8e8 100644
--- a/Lib/test/test_marshal.py
+++ b/Lib/test/test_marshal.py
@@ -1,4 +1,5 @@
from test import support
+from test.support import os_helper
import array
import io
import marshal
@@ -17,13 +18,13 @@ class HelperMixin:
new = marshal.loads(marshal.dumps(sample, *extra))
self.assertEqual(sample, new)
try:
- with open(support.TESTFN, "wb") as f:
+ with open(os_helper.TESTFN, "wb") as f:
marshal.dump(sample, f, *extra)
- with open(support.TESTFN, "rb") as f:
+ with open(os_helper.TESTFN, "rb") as f:
new = marshal.load(f)
self.assertEqual(sample, new)
finally:
- support.unlink(support.TESTFN)
+ os_helper.unlink(os_helper.TESTFN)
class IntTestCase(unittest.TestCase, HelperMixin):
def test_ints(self):
@@ -281,20 +282,20 @@ class BugsTestCase(unittest.TestCase):
ilen = len(interleaved)
positions = []
try:
- with open(support.TESTFN, 'wb') as f:
+ with open(os_helper.TESTFN, 'wb') as f:
for d in data:
marshal.dump(d, f)
if ilen:
f.write(interleaved)
positions.append(f.tell())
- with open(support.TESTFN, 'rb') as f:
+ with open(os_helper.TESTFN, 'rb') as f:
for i, d in enumerate(data):
self.assertEqual(d, marshal.load(f))
if ilen:
f.read(ilen)
self.assertEqual(positions[i], f.tell())
finally:
- support.unlink(support.TESTFN)
+ os_helper.unlink(os_helper.TESTFN)
def test_loads_reject_unicode_strings(self):
# Issue #14177: marshal.loads() should not accept unicode strings
@@ -516,81 +517,81 @@ class CAPI_TestCase(unittest.TestCase, HelperMixin):
def test_write_long_to_file(self):
for v in range(marshal.version + 1):
- _testcapi.pymarshal_write_long_to_file(0x12345678, support.TESTFN, v)
- with open(support.TESTFN, 'rb') as f:
+ _testcapi.pymarshal_write_long_to_file(0x12345678, os_helper.TESTFN, v)
+ with open(os_helper.TESTFN, 'rb') as f:
data = f.read()
- support.unlink(support.TESTFN)
+ os_helper.unlink(os_helper.TESTFN)
self.assertEqual(data, b'\x78\x56\x34\x12')
def test_write_object_to_file(self):
obj = ('\u20ac', b'abc', 123, 45.6, 7+8j, 'long line '*1000)
for v in range(marshal.version + 1):
- _testcapi.pymarshal_write_object_to_file(obj, support.TESTFN, v)
- with open(support.TESTFN, 'rb') as f:
+ _testcapi.pymarshal_write_object_to_file(obj, os_helper.TESTFN, v)
+ with open(os_helper.TESTFN, 'rb') as f:
data = f.read()
- support.unlink(support.TESTFN)
+ os_helper.unlink(os_helper.TESTFN)
self.assertEqual(marshal.loads(data), obj)
def test_read_short_from_file(self):
- with open(support.TESTFN, 'wb') as f:
+ with open(os_helper.TESTFN, 'wb') as f:
f.write(b'\x34\x12xxxx')
- r, p = _testcapi.pymarshal_read_short_from_file(support.TESTFN)
- support.unlink(support.TESTFN)
+ r, p = _testcapi.pymarshal_read_short_from_file(os_helper.TESTFN)
+ os_helper.unlink(os_helper.TESTFN)
self.assertEqual(r, 0x1234)
self.assertEqual(p, 2)
- with open(support.TESTFN, 'wb') as f:
+ with open(os_helper.TESTFN, 'wb') as f:
f.write(b'\x12')
with self.assertRaises(EOFError):
- _testcapi.pymarshal_read_short_from_file(support.TESTFN)
- support.unlink(support.TESTFN)
+ _testcapi.pymarshal_read_short_from_file(os_helper.TESTFN)
+ os_helper.unlink(os_helper.TESTFN)
def test_read_long_from_file(self):
- with open(support.TESTFN, 'wb') as f:
+ with open(os_helper.TESTFN, 'wb') as f:
f.write(b'\x78\x56\x34\x12xxxx')
- r, p = _testcapi.pymarshal_read_long_from_file(support.TESTFN)
- support.unlink(support.TESTFN)
+ r, p = _testcapi.pymarshal_read_long_from_file(os_helper.TESTFN)
+ os_helper.unlink(os_helper.TESTFN)
self.assertEqual(r, 0x12345678)
self.assertEqual(p, 4)
- with open(support.TESTFN, 'wb') as f:
+ with open(os_helper.TESTFN, 'wb') as f:
f.write(b'\x56\x34\x12')
with self.assertRaises(EOFError):
- _testcapi.pymarshal_read_long_from_file(support.TESTFN)
- support.unlink(support.TESTFN)
+ _testcapi.pymarshal_read_long_from_file(os_helper.TESTFN)
+ os_helper.unlink(os_helper.TESTFN)
def test_read_last_object_from_file(self):
obj = ('\u20ac', b'abc', 123, 45.6, 7+8j)
for v in range(marshal.version + 1):
data = marshal.dumps(obj, v)
- with open(support.TESTFN, 'wb') as f:
+ with open(os_helper.TESTFN, 'wb') as f:
f.write(data + b'xxxx')
- r, p = _testcapi.pymarshal_read_last_object_from_file(support.TESTFN)
- support.unlink(support.TESTFN)
+ r, p = _testcapi.pymarshal_read_last_object_from_file(os_helper.TESTFN)
+ os_helper.unlink(os_helper.TESTFN)
self.assertEqual(r, obj)
- with open(support.TESTFN, 'wb') as f:
+ with open(os_helper.TESTFN, 'wb') as f:
f.write(data[:1])
with self.assertRaises(EOFError):
- _testcapi.pymarshal_read_last_object_from_file(support.TESTFN)
- support.unlink(support.TESTFN)
+ _testcapi.pymarshal_read_last_object_from_file(os_helper.TESTFN)
+ os_helper.unlink(os_helper.TESTFN)
def test_read_object_from_file(self):
obj = ('\u20ac', b'abc', 123, 45.6, 7+8j)
for v in range(marshal.version + 1):
data = marshal.dumps(obj, v)
- with open(support.TESTFN, 'wb') as f:
+ with open(os_helper.TESTFN, 'wb') as f:
f.write(data + b'xxxx')
- r, p = _testcapi.pymarshal_read_object_from_file(support.TESTFN)
- support.unlink(support.TESTFN)
+ r, p = _testcapi.pymarshal_read_object_from_file(os_helper.TESTFN)
+ os_helper.unlink(os_helper.TESTFN)
self.assertEqual(r, obj)
self.assertEqual(p, len(data))
- with open(support.TESTFN, 'wb') as f:
+ with open(os_helper.TESTFN, 'wb') as f:
f.write(data[:1])
with self.assertRaises(EOFError):
- _testcapi.pymarshal_read_object_from_file(support.TESTFN)
- support.unlink(support.TESTFN)
+ _testcapi.pymarshal_read_object_from_file(os_helper.TESTFN)
+ os_helper.unlink(os_helper.TESTFN)
if __name__ == "__main__":
diff --git a/Lib/test/test_py_compile.py b/Lib/test/test_py_compile.py
index 11b579c..d8ba009 100644
--- a/Lib/test/test_py_compile.py
+++ b/Lib/test/test_py_compile.py
@@ -102,7 +102,7 @@ class PyCompileTestsBase:
self.assertTrue(os.path.exists(self.cache_path))
def test_cwd(self):
- with support.change_cwd(self.directory):
+ with os_helper.change_cwd(self.directory):
py_compile.compile(os.path.basename(self.source_path),
os.path.basename(self.pyc_path))
self.assertTrue(os.path.exists(self.pyc_path))
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py
index 68d4942..e45f018 100644
--- a/Lib/test/test_set.py
+++ b/Lib/test/test_set.py
@@ -1,5 +1,6 @@
import unittest
from test import support
+from test.support import warnings_helper
import gc
import weakref
import operator
@@ -953,7 +954,7 @@ class TestBasicOpsBytes(TestBasicOps, unittest.TestCase):
class TestBasicOpsMixedStringBytes(TestBasicOps, unittest.TestCase):
def setUp(self):
- self._warning_filters = support.check_warnings()
+ self._warning_filters = warnings_helper.check_warnings()
self._warning_filters.__enter__()
warnings.simplefilter('ignore', BytesWarning)
self.case = "string and bytes set"
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index cff07b4..67ac045 100755
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -1,5 +1,6 @@
import unittest
from test import support
+from test.support import os_helper
from test.support import socket_helper
from test.support import threading_helper
@@ -697,7 +698,7 @@ class UnixSocketTestBase(SocketTestBase):
def bindSock(self, sock):
path = tempfile.mktemp(dir=self.dir_path)
socket_helper.bind_unix_socket(sock, path)
- self.addCleanup(support.unlink, path)
+ self.addCleanup(os_helper.unlink, path)
class UnixStreamBase(UnixSocketTestBase):
"""Base class for Unix-domain SOCK_STREAM tests."""
@@ -1917,14 +1918,14 @@ class GeneralModuleTests(unittest.TestCase):
def test_socket_fileno_requires_valid_fd(self):
WSAENOTSOCK = 10038
with self.assertRaises(OSError) as cm:
- socket.socket(fileno=support.make_bad_fd())
+ socket.socket(fileno=os_helper.make_bad_fd())
self.assertIn(cm.exception.errno, (errno.EBADF, WSAENOTSOCK))
with self.assertRaises(OSError) as cm:
socket.socket(
socket.AF_INET,
socket.SOCK_STREAM,
- fileno=support.make_bad_fd())
+ fileno=os_helper.make_bad_fd())
self.assertIn(cm.exception.errno, (errno.EBADF, WSAENOTSOCK))
def test_socket_fileno_requires_socket_fd(self):
@@ -5458,35 +5459,35 @@ class TestUnixDomain(unittest.TestCase):
def testStrAddr(self):
# Test binding to and retrieving a normal string pathname.
- path = os.path.abspath(support.TESTFN)
+ path = os.path.abspath(os_helper.TESTFN)
self.bind(self.sock, path)
- self.addCleanup(support.unlink, path)
+ self.addCleanup(os_helper.unlink, path)
self.assertEqual(self.sock.getsockname(), path)
def testBytesAddr(self):
# Test binding to a bytes pathname.
- path = os.path.abspath(support.TESTFN)
+ path = os.path.abspath(os_helper.TESTFN)
self.bind(self.sock, self.encoded(path))
- self.addCleanup(support.unlink, path)
+ self.addCleanup(os_helper.unlink, path)
self.assertEqual(self.sock.getsockname(), path)
def testSurrogateescapeBind(self):
# Test binding to a valid non-ASCII pathname, with the
# non-ASCII bytes supplied using surrogateescape encoding.
- path = os.path.abspath(support.TESTFN_UNICODE)
+ path = os.path.abspath(os_helper.TESTFN_UNICODE)
b = self.encoded(path)
self.bind(self.sock, b.decode("ascii", "surrogateescape"))
- self.addCleanup(support.unlink, path)
+ self.addCleanup(os_helper.unlink, path)
self.assertEqual(self.sock.getsockname(), path)
def testUnencodableAddr(self):
# Test binding to a pathname that cannot be encoded in the
# file system encoding.
- if support.TESTFN_UNENCODABLE is None:
+ if os_helper.TESTFN_UNENCODABLE is None:
self.skipTest("No unencodable filename available")
- path = os.path.abspath(support.TESTFN_UNENCODABLE)
+ path = os.path.abspath(os_helper.TESTFN_UNENCODABLE)
self.bind(self.sock, path)
- self.addCleanup(support.unlink, path)
+ self.addCleanup(os_helper.unlink, path)
self.assertEqual(self.sock.getsockname(), path)
@@ -5960,16 +5961,16 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest):
chunk = b"".join([random.choice(string.ascii_letters).encode()
for i in range(cls.BUFSIZE)])
- with open(support.TESTFN, 'wb') as f:
+ with open(os_helper.TESTFN, 'wb') as f:
for csize in chunks(cls.FILESIZE, cls.BUFSIZE):
f.write(chunk)
- with open(support.TESTFN, 'rb') as f:
+ with open(os_helper.TESTFN, 'rb') as f:
cls.FILEDATA = f.read()
assert len(cls.FILEDATA) == cls.FILESIZE
@classmethod
def tearDownClass(cls):
- support.unlink(support.TESTFN)
+ os_helper.unlink(os_helper.TESTFN)
def accept_conn(self):
self.serv.settimeout(support.LONG_TIMEOUT)
@@ -5996,7 +5997,7 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest):
def _testRegularFile(self):
address = self.serv.getsockname()
- file = open(support.TESTFN, 'rb')
+ file = open(os_helper.TESTFN, 'rb')
with socket.create_connection(address) as sock, file as file:
meth = self.meth_from_sock(sock)
sent = meth(file)
@@ -6031,9 +6032,9 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest):
def _testEmptyFileSend(self):
address = self.serv.getsockname()
- filename = support.TESTFN + "2"
+ filename = os_helper.TESTFN + "2"
with open(filename, 'wb'):
- self.addCleanup(support.unlink, filename)
+ self.addCleanup(os_helper.unlink, filename)
file = open(filename, 'rb')
with socket.create_connection(address) as sock, file as file:
meth = self.meth_from_sock(sock)
@@ -6050,7 +6051,7 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest):
def _testOffset(self):
address = self.serv.getsockname()
- file = open(support.TESTFN, 'rb')
+ file = open(os_helper.TESTFN, 'rb')
with socket.create_connection(address) as sock, file as file:
meth = self.meth_from_sock(sock)
sent = meth(file, offset=5000)
@@ -6067,7 +6068,7 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest):
def _testCount(self):
address = self.serv.getsockname()
- file = open(support.TESTFN, 'rb')
+ file = open(os_helper.TESTFN, 'rb')
sock = socket.create_connection(address,
timeout=support.LOOPBACK_TIMEOUT)
with sock, file:
@@ -6088,7 +6089,7 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest):
def _testCountSmall(self):
address = self.serv.getsockname()
- file = open(support.TESTFN, 'rb')
+ file = open(os_helper.TESTFN, 'rb')
sock = socket.create_connection(address,
timeout=support.LOOPBACK_TIMEOUT)
with sock, file:
@@ -6109,7 +6110,7 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest):
def _testCountWithOffset(self):
address = self.serv.getsockname()
- file = open(support.TESTFN, 'rb')
+ file = open(os_helper.TESTFN, 'rb')
with socket.create_connection(address, timeout=2) as sock, file as file:
count = 100007
meth = self.meth_from_sock(sock)
@@ -6128,7 +6129,7 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest):
def _testNonBlocking(self):
address = self.serv.getsockname()
- file = open(support.TESTFN, 'rb')
+ file = open(os_helper.TESTFN, 'rb')
with socket.create_connection(address) as sock, file as file:
sock.setblocking(False)
meth = self.meth_from_sock(sock)
@@ -6144,7 +6145,7 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest):
def _testWithTimeout(self):
address = self.serv.getsockname()
- file = open(support.TESTFN, 'rb')
+ file = open(os_helper.TESTFN, 'rb')
sock = socket.create_connection(address,
timeout=support.LOOPBACK_TIMEOUT)
with sock, file:
@@ -6162,7 +6163,7 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest):
def _testWithTimeoutTriggeredSend(self):
address = self.serv.getsockname()
- with open(support.TESTFN, 'rb') as file:
+ with open(os_helper.TESTFN, 'rb') as file:
with socket.create_connection(address) as sock:
sock.settimeout(0.01)
meth = self.meth_from_sock(sock)
@@ -6178,17 +6179,17 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest):
pass
def test_errors(self):
- with open(support.TESTFN, 'rb') as file:
+ with open(os_helper.TESTFN, 'rb') as file:
with socket.socket(type=socket.SOCK_DGRAM) as s:
meth = self.meth_from_sock(s)
self.assertRaisesRegex(
ValueError, "SOCK_STREAM", meth, file)
- with open(support.TESTFN, 'rt') as file:
+ with open(os_helper.TESTFN, 'rt') as file:
with socket.socket() as s:
meth = self.meth_from_sock(s)
self.assertRaisesRegex(
ValueError, "binary mode", meth, file)
- with open(support.TESTFN, 'rb') as file:
+ with open(os_helper.TESTFN, 'rb') as file:
with socket.socket() as s:
meth = self.meth_from_sock(s)
self.assertRaisesRegex(TypeError, "positive integer",
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
index 44e44bf..d07d28d 100644
--- a/Lib/test/test_sysconfig.py
+++ b/Lib/test/test_sysconfig.py
@@ -5,9 +5,11 @@ import subprocess
import shutil
from copy import copy
-from test.support import (import_module, TESTFN, unlink, check_warnings,
- captured_stdout, skip_unless_symlink, change_cwd,
- PythonSymlink)
+from test.support import (captured_stdout, PythonSymlink)
+from test.support.import_helper import import_module
+from test.support.os_helper import (TESTFN, unlink, skip_unless_symlink,
+ change_cwd)
+from test.support.warnings_helper import check_warnings
import sysconfig
from sysconfig import (get_paths, get_platform, get_config_vars,
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 925a6bc..c5fbd87 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -7,7 +7,8 @@ import sys
import unittest
import re
from test import support
-from test.support import TESTFN, Error, captured_output, unlink, cpython_only, ALWAYS_EQ
+from test.support import Error, captured_output, cpython_only, ALWAYS_EQ
+from test.support.os_helper import TESTFN, unlink
from test.support.script_helper import assert_python_ok
import textwrap
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 5969793..afc9555 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -15,6 +15,8 @@ import textwrap
import unicodedata
import unittest
import warnings
+from test.support import import_helper
+from test.support import warnings_helper
from test import support, string_tests
from test.support.script_helper import assert_python_failure
@@ -504,7 +506,7 @@ class UnicodeTest(string_tests.CommonTest,
self.assertIs(text.replace(pattern, pattern), text)
def test_bytes_comparison(self):
- with support.check_warnings():
+ with warnings_helper.check_warnings():
warnings.simplefilter('ignore', BytesWarning)
self.assertEqual('abc' == b'abc', False)
self.assertEqual('abc' != b'abc', True)
@@ -725,7 +727,7 @@ class UnicodeTest(string_tests.CommonTest,
import _testcapi
u = 'π–€π–“π–Žπ–ˆπ–”π–‰π–Š'
self.assertTrue(u.isidentifier())
- with support.check_warnings():
+ with warnings_helper.check_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
self.assertTrue(_testcapi.unicode_legacy_string(u).isidentifier())
@@ -2507,7 +2509,7 @@ class CAPITest(unittest.TestCase):
# Test PyUnicode_FromFormat()
def test_from_format(self):
- support.import_module('ctypes')
+ import_helper.import_module('ctypes')
from ctypes import (
pythonapi, py_object, sizeof,
c_int, c_long, c_longlong, c_ssize_t,
@@ -2748,7 +2750,7 @@ class CAPITest(unittest.TestCase):
@support.cpython_only
def test_aswidechar(self):
from _testcapi import unicode_aswidechar
- support.import_module('ctypes')
+ import_helper.import_module('ctypes')
from ctypes import c_wchar, sizeof
wchar, size = unicode_aswidechar('abcdef', 2)
@@ -2786,7 +2788,7 @@ class CAPITest(unittest.TestCase):
@support.cpython_only
def test_aswidecharstring(self):
from _testcapi import unicode_aswidecharstring
- support.import_module('ctypes')
+ import_helper.import_module('ctypes')
from ctypes import c_wchar, sizeof
wchar, size = unicode_aswidecharstring('abc')
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index d01649d..63f9b92 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -24,7 +24,12 @@ import weakref
from functools import partial
from itertools import product, islice
from test import support
-from test.support import TESTFN, findfile, import_fresh_module, gc_collect, swap_attr
+from test.support import os_helper
+from test.support import warnings_helper
+from test.support import findfile, gc_collect, swap_attr
+from test.support.import_helper import import_fresh_module
+from test.support.os_helper import TESTFN
+
# pyET is the pure-Python implementation.
#
@@ -601,7 +606,7 @@ class ElementTreeTest(unittest.TestCase):
self.assertFalse(f.closed)
self.assertEqual(str(cm.exception), "unknown event 'bogus'")
- with support.check_no_resource_warning(self):
+ with warnings_helper.check_no_resource_warning(self):
with self.assertRaises(ValueError) as cm:
iterparse(SIMPLE_XMLFILE, events)
self.assertEqual(str(cm.exception), "unknown event 'bogus'")
@@ -627,13 +632,13 @@ class ElementTreeTest(unittest.TestCase):
self.assertEqual(str(cm.exception),
'junk after document element: line 1, column 12')
- self.addCleanup(support.unlink, TESTFN)
+ self.addCleanup(os_helper.unlink, TESTFN)
with open(TESTFN, "wb") as f:
f.write(b"<document />junk")
it = iterparse(TESTFN)
action, elem = next(it)
self.assertEqual((action, elem.tag), ('end', 'document'))
- with support.check_no_resource_warning(self):
+ with warnings_helper.check_no_resource_warning(self):
with self.assertRaises(ET.ParseError) as cm:
next(it)
self.assertEqual(str(cm.exception),
@@ -3641,14 +3646,14 @@ class IOTest(unittest.TestCase):
"<tag key=\"Γ₯ΓΆΓΆ&lt;&gt;\" />" % enc).encode(enc))
def test_write_to_filename(self):
- self.addCleanup(support.unlink, TESTFN)
+ self.addCleanup(os_helper.unlink, TESTFN)
tree = ET.ElementTree(ET.XML('''<site />'''))
tree.write(TESTFN)
with open(TESTFN, 'rb') as f:
self.assertEqual(f.read(), b'''<site />''')
def test_write_to_text_file(self):
- self.addCleanup(support.unlink, TESTFN)
+ self.addCleanup(os_helper.unlink, TESTFN)
tree = ET.ElementTree(ET.XML('''<site />'''))
with open(TESTFN, 'w', encoding='utf-8') as f:
tree.write(f, encoding='unicode')
@@ -3657,7 +3662,7 @@ class IOTest(unittest.TestCase):
self.assertEqual(f.read(), b'''<site />''')
def test_write_to_binary_file(self):
- self.addCleanup(support.unlink, TESTFN)
+ self.addCleanup(os_helper.unlink, TESTFN)
tree = ET.ElementTree(ET.XML('''<site />'''))
with open(TESTFN, 'wb') as f:
tree.write(f)
@@ -3666,7 +3671,7 @@ class IOTest(unittest.TestCase):
self.assertEqual(f.read(), b'''<site />''')
def test_write_to_binary_file_with_bom(self):
- self.addCleanup(support.unlink, TESTFN)
+ self.addCleanup(os_helper.unlink, TESTFN)
tree = ET.ElementTree(ET.XML('''<site />'''))
# test BOM writing to buffered file
with open(TESTFN, 'wb') as f:
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index b7bc218..2851051 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -19,9 +19,10 @@ from tempfile import TemporaryFile
from random import randint, random, randbytes
from test.support import script_helper
-from test.support import (TESTFN, findfile, unlink, rmtree, temp_dir, temp_cwd,
- requires_zlib, requires_bz2, requires_lzma,
- captured_stdout)
+from test.support import (findfile, requires_zlib, requires_bz2,
+ requires_lzma, captured_stdout)
+from test.support.os_helper import TESTFN, unlink, rmtree, temp_dir, temp_cwd
+
TESTFN2 = TESTFN + "2"
TESTFNDIR = TESTFN + "d"