[Python-checkins] bpo-40275: Use new test.support helper submodules in tests (GH-21772)

Hai Shi webhook-mailer at python.org
Fri Aug 7 17:55:43 EDT 2020


https://github.com/python/cpython/commit/fcce8c649a14f7a81fae82f9f203bb5b5ee0c205
commit: fcce8c649a14f7a81fae82f9f203bb5b5ee0c205
branch: master
author: Hai Shi <shihai1992 at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020年08月07日T23:55:35+02:00
summary:
bpo-40275: Use new test.support helper submodules in tests (GH-21772)
files:
M Lib/sqlite3/test/dbapi.py
M Lib/test/libregrtest/refleak.py
M Lib/test/libregrtest/win_utils.py
M Lib/test/test_audit.py
M Lib/test/test_bytes.py
M Lib/test/test_dbm_ndbm.py
M Lib/test/test_descr.py
M Lib/test/test_xml_etree.py
diff --git a/Lib/sqlite3/test/dbapi.py b/Lib/sqlite3/test/dbapi.py
index be11337154bdd..119da12170331 100644
--- a/Lib/sqlite3/test/dbapi.py
+++ b/Lib/sqlite3/test/dbapi.py
@@ -25,7 +25,7 @@
 import unittest
 import sqlite3 as sqlite
 
-from test.support import TESTFN, unlink
+from test.support.os_helper import TESTFN, unlink
 
 
 class ModuleTests(unittest.TestCase):
diff --git a/Lib/test/libregrtest/refleak.py b/Lib/test/libregrtest/refleak.py
index 8d221232eb6ce..77298d318898d 100644
--- a/Lib/test/libregrtest/refleak.py
+++ b/Lib/test/libregrtest/refleak.py
@@ -4,6 +4,8 @@
 import warnings
 from inspect import isabstract
 from test import support
+from test.support import os_helper
+
 try:
 from _abc import _get_dump
 except ImportError:
@@ -61,7 +63,7 @@ def get_pooled_int(value):
 return int_pool.setdefault(value, value)
 
 nwarmup, ntracked, fname = ns.huntrleaks
- fname = os.path.join(support.SAVEDCWD, fname)
+ fname = os.path.join(os_helper.SAVEDCWD, fname)
 repcount = nwarmup + ntracked
 
 # Pre-allocate to ensure that the loop doesn't allocate anything new
@@ -71,7 +73,7 @@ def get_pooled_int(value):
 fd_deltas = [0] * repcount
 getallocatedblocks = sys.getallocatedblocks
 gettotalrefcount = sys.gettotalrefcount
- fd_count = support.fd_count
+ fd_count = os_helper.fd_count
 
 # initialize variables to make pyflakes quiet
 rc_before = alloc_before = fd_before = 0
diff --git a/Lib/test/libregrtest/win_utils.py b/Lib/test/libregrtest/win_utils.py
index 028c01106dee0..a1cc2201147db 100644
--- a/Lib/test/libregrtest/win_utils.py
+++ b/Lib/test/libregrtest/win_utils.py
@@ -5,7 +5,7 @@
 import subprocess
 import uuid
 import winreg
-from test import support
+from test.support import os_helper
 from test.libregrtest.utils import print_warning
 
 
@@ -69,7 +69,9 @@ def start(self):
 # Spawn off the load monitor
 counter_name = self._get_counter_name()
 command = ['typeperf', counter_name, '-si', str(SAMPLING_INTERVAL)]
- self._popen = subprocess.Popen(' '.join(command), stdout=command_stdout, cwd=support.SAVEDCWD)
+ self._popen = subprocess.Popen(' '.join(command),
+ stdout=command_stdout,
+ cwd=os_helper.SAVEDCWD)
 
 # Close our copy of the write end of the pipe
 os.close(command_stdout)
diff --git a/Lib/test/test_audit.py b/Lib/test/test_audit.py
index f79edbc4bd0d9..4f8d06a3ebcbe 100644
--- a/Lib/test/test_audit.py
+++ b/Lib/test/test_audit.py
@@ -5,6 +5,9 @@
 import sys
 import unittest
 from test import support
+from test.support import import_helper
+from test.support import os_helper
+
 
 if not hasattr(sys, "addaudithook") or not hasattr(sys, "audit"):
 raise unittest.SkipTest("test only relevant when sys.audit is available")
@@ -52,7 +55,7 @@ def test_block_add_hook_baseexception(self):
 self.do_test("test_block_add_hook_baseexception")
 
 def test_pickle(self):
- support.import_module("pickle")
+ import_helper.import_module("pickle")
 
 self.do_test("test_pickle")
 
@@ -60,7 +63,7 @@ def test_monkeypatch(self):
 self.do_test("test_monkeypatch")
 
 def test_open(self):
- self.do_test("test_open", support.TESTFN)
+ self.do_test("test_open", os_helper.TESTFN)
 
 def test_cantrace(self):
 self.do_test("test_cantrace")
@@ -89,7 +92,7 @@ def test_unraisablehook(self):
 )
 
 def test_winreg(self):
- support.import_module("winreg")
+ import_helper.import_module("winreg")
 returncode, events, stderr = self.run_python("test_winreg")
 if returncode:
 self.fail(stderr)
@@ -103,7 +106,7 @@ def test_winreg(self):
 self.assertSequenceEqual(["winreg.PyHKEY.Detach", " ", expected], events[4])
 
 def test_socket(self):
- support.import_module("socket")
+ import_helper.import_module("socket")
 returncode, events, stderr = self.run_python("test_socket")
 if returncode:
 self.fail(stderr)
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index 61b4b9162ccc5..e61228d1a266f 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -17,6 +17,7 @@
 
 import test.support
 from test.support import import_helper
+from test.support import warnings_helper
 import test.string_tests
 import test.list_tests
 from test.support import bigaddrspacetest, MAX_Py_ssize_t
@@ -27,7 +28,7 @@
 def check_bytes_warnings(func):
 @functools.wraps(func)
 def wrapper(*args, **kw):
- with test.support.check_warnings(('', BytesWarning)):
+ with warnings_helper.check_warnings(('', BytesWarning)):
 return func(*args, **kw)
 return wrapper
 else:
@@ -1769,7 +1770,7 @@ def test_return_self(self):
 "BytesWarning is needed for this test: use -bb option")
 def test_compare(self):
 def bytes_warning():
- return test.support.check_warnings(('', BytesWarning))
+ return warnings_helper.check_warnings(('', BytesWarning))
 with bytes_warning():
 b'' == ''
 with bytes_warning():
diff --git a/Lib/test/test_dbm_ndbm.py b/Lib/test/test_dbm_ndbm.py
index 278fca2cf2315..e17a1d9eca931 100644
--- a/Lib/test/test_dbm_ndbm.py
+++ b/Lib/test/test_dbm_ndbm.py
@@ -1,5 +1,6 @@
 from test import support
 from test.support import import_helper
+from test.support import os_helper
 import_helper.import_module("dbm.ndbm") #skip if not supported
 import os
 import unittest
@@ -9,7 +10,7 @@
 class DbmTestCase(unittest.TestCase):
 
 def setUp(self):
- self.filename = support.TESTFN
+ self.filename = os_helper.TESTFN
 self.d = dbm.ndbm.open(self.filename, 'c')
 self.d.close()
 
@@ -102,10 +103,10 @@ def test_write_readonly_file(self):
 with self.assertRaises(error):
 db[b'not exist key'] = b'not exist value'
 
- @unittest.skipUnless(support.TESTFN_NONASCII,
+ @unittest.skipUnless(os_helper.TESTFN_NONASCII,
 'requires OS support of non-ASCII encodings')
 def test_nonascii_filename(self):
- filename = support.TESTFN_NONASCII
+ filename = os_helper.TESTFN_NONASCII
 for suffix in ['', '.pag', '.dir', '.db']:
 self.addCleanup(support.unlink, filename + suffix)
 with dbm.ndbm.open(filename, 'c') as db:
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 9738fb52a04bf..307416c3300ae 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -2975,12 +2975,12 @@ class sublist(list):
 ## self.ateof = 1
 ## return s
 ##
- ## f = file(name=support.TESTFN, mode='w')
+ ## f = file(name=os_helper.TESTFN, mode='w')
 ## lines = ['a\n', 'b\n', 'c\n']
 ## try:
 ## f.writelines(lines)
 ## f.close()
- ## f = CountedInput(support.TESTFN)
+ ## f = CountedInput(os_helper.TESTFN)
 ## for (i, expected) in zip(range(1, 5) + [4], lines + 2 * [""]):
 ## got = f.readline()
 ## self.assertEqual(expected, got)
@@ -2992,7 +2992,7 @@ class sublist(list):
 ## f.close()
 ## except:
 ## pass
- ## support.unlink(support.TESTFN)
+ ## os_helper.unlink(os_helper.TESTFN)
 
 def test_keywords(self):
 # Testing keyword args to basic type constructors ...
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 63f9b92a83de2..c7d446185cfe4 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -111,7 +111,7 @@
 def checkwarnings(*filters, quiet=False):
 def decorator(test):
 def newtest(*args, **kwargs):
- with support.check_warnings(*filters, quiet=quiet):
+ with warnings_helper.check_warnings(*filters, quiet=quiet):
 test(*args, **kwargs)
 functools.update_wrapper(newtest, test)
 return newtest


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /