bpo-40275: Use new test.support helper submodules in tests (GH-21315)
diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py
index 571da97..e02d1e1 100644
--- a/Lib/test/test_dbm.py
+++ b/Lib/test/test_dbm.py
@@ -2,17 +2,18 @@
import unittest
import glob
-import test.support
+from test.support import import_helper
+from test.support import os_helper
# Skip tests if dbm module doesn't exist.
-dbm = test.support.import_module('dbm')
+dbm = import_helper.import_module('dbm')
try:
from dbm import ndbm
except ImportError:
ndbm = None
-_fname = test.support.TESTFN
+_fname = os_helper.TESTFN
#
# Iterates over every database module supported by dbm currently available,
@@ -34,7 +35,7 @@
# we don't know the precise name the underlying database uses
# so we use glob to locate all names
for f in glob.glob(glob.escape(_fname) + "*"):
- test.support.unlink(f)
+ os_helper.unlink(f)
class AnyDBMTestCase:
@@ -74,7 +75,7 @@
def test_anydbm_creation_n_file_exists_with_invalid_contents(self):
# create an empty file
- test.support.create_empty_file(_fname)
+ os_helper.create_empty_file(_fname)
with dbm.open(_fname, 'n') as f:
self.assertEqual(len(f), 0)
@@ -169,7 +170,7 @@
# Issue 17198: check that ndbm which is referenced in whichdb is defined
db_file = '{}_ndbm.db'.format(_fname)
with open(db_file, 'w'):
- self.addCleanup(test.support.unlink, db_file)
+ self.addCleanup(os_helper.unlink, db_file)
self.assertIsNone(self.dbm.whichdb(db_file[:-3]))
def tearDown(self):
@@ -177,10 +178,10 @@
def setUp(self):
delete_files()
- self.filename = test.support.TESTFN
+ self.filename = os_helper.TESTFN
self.d = dbm.open(self.filename, 'c')
self.d.close()
- self.dbm = test.support.import_fresh_module('dbm')
+ self.dbm = import_helper.import_fresh_module('dbm')
def test_keys(self):
self.d = dbm.open(self.filename, 'c')