bpo-40275: Use new test.support helper submodules in tests (GH-21315) · python/cpython@a089d21
@@ -2,17 +2,18 @@
2233import unittest
44import glob
5-import test.support
5+from test.support import import_helper
6+from test.support import os_helper
6778# Skip tests if dbm module doesn't exist.
8-dbm = test.support.import_module('dbm')
9+dbm = import_helper.import_module('dbm')
9101011try:
1112from dbm import ndbm
1213except ImportError:
1314ndbm = None
141515-_fname = test.support.TESTFN
16+_fname = os_helper.TESTFN
16171718#
1819# Iterates over every database module supported by dbm currently available,
@@ -34,7 +35,7 @@ def delete_files():
3435# we don't know the precise name the underlying database uses
3536# so we use glob to locate all names
3637for f in glob.glob(glob.escape(_fname) + "*"):
37-test.support.unlink(f)
38+os_helper.unlink(f)
383939404041class AnyDBMTestCase:
@@ -74,7 +75,7 @@ def test_anydbm_creation(self):
74757576def test_anydbm_creation_n_file_exists_with_invalid_contents(self):
7677# create an empty file
77-test.support.create_empty_file(_fname)
78+os_helper.create_empty_file(_fname)
7879with dbm.open(_fname, 'n') as f:
7980self.assertEqual(len(f), 0)
8081@@ -169,18 +170,18 @@ def test_whichdb_ndbm(self):
169170# Issue 17198: check that ndbm which is referenced in whichdb is defined
170171db_file = '{}_ndbm.db'.format(_fname)
171172with open(db_file, 'w'):
172-self.addCleanup(test.support.unlink, db_file)
173+self.addCleanup(os_helper.unlink, db_file)
173174self.assertIsNone(self.dbm.whichdb(db_file[:-3]))
174175175176def tearDown(self):
176177delete_files()
177178178179def setUp(self):
179180delete_files()
180-self.filename = test.support.TESTFN
181+self.filename = os_helper.TESTFN
181182self.d = dbm.open(self.filename, 'c')
182183self.d.close()
183-self.dbm = test.support.import_fresh_module('dbm')
184+self.dbm = import_helper.import_fresh_module('dbm')
184185185186def test_keys(self):
186187self.d = dbm.open(self.filename, 'c')