bpo-40275: Use new test.support helper submodules in tests (GH-21315) · python/cpython@a089d21

@@ -2,17 +2,18 @@

2233

import unittest

44

import 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')

9101011

try:

1112

from dbm import ndbm

1213

except ImportError:

1314

ndbm = 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

3637

for f in glob.glob(glob.escape(_fname) + "*"):

37-

test.support.unlink(f)

38+

os_helper.unlink(f)

383939404041

class AnyDBMTestCase:

@@ -74,7 +75,7 @@ def test_anydbm_creation(self):

74757576

def 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)

7879

with dbm.open(_fname, 'n') as f:

7980

self.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

170171

db_file = '{}_ndbm.db'.format(_fname)

171172

with open(db_file, 'w'):

172-

self.addCleanup(test.support.unlink, db_file)

173+

self.addCleanup(os_helper.unlink, db_file)

173174

self.assertIsNone(self.dbm.whichdb(db_file[:-3]))

174175175176

def tearDown(self):

176177

delete_files()

177178178179

def setUp(self):

179180

delete_files()

180-

self.filename = test.support.TESTFN

181+

self.filename = os_helper.TESTFN

181182

self.d = dbm.open(self.filename, 'c')

182183

self.d.close()

183-

self.dbm = test.support.import_fresh_module('dbm')

184+

self.dbm = import_helper.import_fresh_module('dbm')

184185185186

def test_keys(self):

186187

self.d = dbm.open(self.filename, 'c')