Based on upstream commit 43fc626bff3e by Jesus Cea https://hg.jcea.es/pybsddb/rev/43fc626bff3e Ported to v6.2.9 by Arthur Zamarin --- a/Lib3/bsddb/test/test_all.py +++ b/Lib3/bsddb/test/test_all.py @@ -473,11 +473,15 @@ if sys.version_info[0] >= 3 : from bsddb3 import db, dbtables, dbutils, dbshelve, \ hashopen, btopen, rnopen, dbobj -if sys.version_info[0] < 3 : - from test import test_support -else : - from test import support as test_support +if sys.version_info >= (3, 9): + from test.support.socket_helper import find_unused_port +else: + from test.support import find_unused_port +if sys.version_info >= (3, 10): + from test.support.os_helper import rmtree, unlink +else: + from test.support import rmtree, unlink try: if sys.version_info[0] < 3 : @@ -540,7 +544,7 @@ def get_new_environment_path() : try: os.makedirs(path,mode=0o700) except os.error: - test_support.rmtree(path) + rmtree(path) os.makedirs(path) return path @@ -565,7 +569,7 @@ def set_test_path_prefix(path) : get_new_path.prefix=path def remove_test_path_directory() : - test_support.rmtree(get_new_path.prefix) + rmtree(get_new_path.prefix) if have_threads : import threading --- a/Lib3/bsddb/test/test_associate.py +++ b/Lib3/bsddb/test/test_associate.py @@ -42,7 +42,7 @@ import time from pprint import pprint import unittest -from .test_all import db, dbshelve, test_support, verbose, have_threads, \ +from .test_all import db, dbshelve, rmtree, verbose, have_threads, \ get_new_environment_path @@ -120,7 +120,7 @@ class AssociateErrorTestCase(unittest.TestCase): def tearDown(self): self.env.close() self.env = None - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) def test00_associateDBError(self): if verbose: @@ -170,7 +170,7 @@ class AssociateTestCase(unittest.TestCase): self.closeDB() self.env.close() self.env = None - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) def addDataToDB(self, d, txn=None): for key, value in list(musicdata.items()): --- a/Lib3/bsddb/test/test_basics.py +++ b/Lib3/bsddb/test/test_basics.py @@ -46,7 +46,7 @@ import unittest import time import sys -from .test_all import db, test_support, verbose, get_new_environment_path, \ +from .test_all import db, rmtree, verbose, get_new_environment_path, \ get_new_database_path DASH = '-' @@ -94,7 +94,7 @@ class BasicTestCase(unittest.TestCase): self.filename = "test" # Yes, a bare except is intended, since we're re-raising the exc. except: - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) raise else: self.env = None @@ -131,7 +131,7 @@ class BasicTestCase(unittest.TestCase): self.d.close() if self.env is not None: self.env.close() - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) else: os.remove(self.filename) --- a/Lib3/bsddb/test/test_compare.py +++ b/Lib3/bsddb/test/test_compare.py @@ -43,7 +43,7 @@ from io import StringIO import unittest -from .test_all import db, dbshelve, test_support, \ +from .test_all import db, dbshelve, rmtree, \ get_new_environment_path, get_new_database_path @@ -119,7 +119,7 @@ class AbstractBtreeKeyCompareTestCase(unittest.TestCase) : if self.env is not None: self.env.close() self.env = None - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) def addDataToDB(self, data) : i = 0 @@ -304,7 +304,7 @@ class AbstractDuplicateCompareTestCase(unittest.TestCase) : if self.env is not None: self.env.close() self.env = None - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) def addDataToDB(self, data) : for item in data: --- a/Lib3/bsddb/test/test_cursor_pget_bug.py +++ b/Lib3/bsddb/test/test_cursor_pget_bug.py @@ -36,7 +36,7 @@ are met: import unittest import os, glob -from .test_all import db, test_support, get_new_environment_path, \ +from .test_all import db, rmtree, get_new_environment_path, \ get_new_database_path #---------------------------------------------------------------------- @@ -67,7 +67,7 @@ class pget_bugTestCase(unittest.TestCase): del self.secondary_db del self.primary_db del self.env - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) def test_pget(self): cursor = self.secondary_db.cursor() --- a/Lib3/bsddb/test/test_db.py +++ b/Lib3/bsddb/test/test_db.py @@ -36,7 +36,7 @@ are met: import unittest import os, glob -from .test_all import db, test_support, get_new_environment_path, \ +from .test_all import db, rmtree, unlink, get_new_environment_path, \ get_new_database_path #---------------------------------------------------------------------- @@ -49,7 +49,7 @@ class DB(unittest.TestCase): def tearDown(self): self.db.close() del self.db - test_support.unlink(self.path) + unlink(self.path) class DB_general(DB) : def test_get_open_flags(self) : @@ -133,7 +133,7 @@ class DB_txn(DB) : del self.db self.env.close() del self.env - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) def test_flags(self) : self.db.set_flags(db.DB_CHKSUM) --- a/Lib3/bsddb/test/test_dbenv.py +++ b/Lib3/bsddb/test/test_dbenv.py @@ -36,7 +36,7 @@ are met: import unittest import os, glob -from .test_all import db, test_support, get_new_environment_path, \ +from .test_all import db, rmtree, get_new_environment_path, \ get_new_database_path #---------------------------------------------------------------------- @@ -49,7 +49,7 @@ class DBEnv(unittest.TestCase): def tearDown(self): self.env.close() del self.env - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) class DBEnv_general(DBEnv) : def test_get_open_flags(self) : --- a/Lib3/bsddb/test/test_dbobj.py +++ b/Lib3/bsddb/test/test_dbobj.py @@ -37,7 +37,7 @@ are met: import os, string import unittest -from .test_all import db, dbobj, test_support, get_new_environment_path, \ +from .test_all import db, dbobj, rmtree, get_new_environment_path, \ get_new_database_path #---------------------------------------------------------------------- @@ -54,7 +54,7 @@ class dbobjTestCase(unittest.TestCase): del self.db if hasattr(self, 'env'): del self.env - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) def test01_both(self): class TestDBEnv(dbobj.DBEnv): pass --- a/Lib3/bsddb/test/test_dbshelve.py +++ b/Lib3/bsddb/test/test_dbshelve.py @@ -42,7 +42,7 @@ import random import unittest -from .test_all import db, dbshelve, test_support, verbose, \ +from .test_all import db, dbshelve, rmtree, unlink, verbose, \ get_new_environment_path, get_new_database_path @@ -82,7 +82,7 @@ class DBShelveTestCase(unittest.TestCase): from .test_all import do_proxy_db_py3k do_proxy_db_py3k(self._flag_proxy_db_py3k) self.do_close() - test_support.unlink(self.filename) + unlink(self.filename) def mk(self, key): """Turn key into an appropriate key type for this db""" @@ -338,7 +338,7 @@ class BasicEnvShelveTestCase(DBShelveTestCase): from .test_all import do_proxy_db_py3k do_proxy_db_py3k(self._flag_proxy_db_py3k) self.do_close() - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) class EnvBTreeShelveTestCase(BasicEnvShelveTestCase): --- a/Lib3/bsddb/test/test_dbtables.py +++ b/Lib3/bsddb/test/test_dbtables.py @@ -31,7 +31,7 @@ else : import pickle import unittest -from .test_all import db, dbtables, test_support, verbose, \ +from .test_all import db, dbtables, rmtree, verbose, \ get_new_environment_path, get_new_database_path #---------------------------------------------------------------------- @@ -55,7 +55,7 @@ class TableDBTestCase(unittest.TestCase): if sys.version_info[0] >= 3 : from .test_all import do_proxy_db_py3k do_proxy_db_py3k(self._flag_proxy_db_py3k) - test_support.rmtree(self.testHomeDir) + rmtree(self.testHomeDir) def test01(self): tabname = "test01" --- a/Lib3/bsddb/test/test_distributed_transactions.py +++ b/Lib3/bsddb/test/test_distributed_transactions.py @@ -39,7 +39,7 @@ are met: import os import unittest -from .test_all import db, test_support, get_new_environment_path, \ +from .test_all import db, rmtree, get_new_environment_path, \ get_new_database_path from .test_all import verbose @@ -84,7 +84,7 @@ class DBTxn_distributed(unittest.TestCase): def tearDown(self): self._destroy_env() - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) def _recreate_env(self,must_open_db) : self._destroy_env() --- a/Lib3/bsddb/test/test_early_close.py +++ b/Lib3/bsddb/test/test_early_close.py @@ -40,7 +40,7 @@ is closed before its DB objects. import os, sys import unittest -from .test_all import db, test_support, verbose, get_new_environment_path, get_new_database_path +from .test_all import db, rmtree, verbose, get_new_environment_path, get_new_database_path # We're going to get warnings in this module about trying to close the db when # its env is already closed. Let's just ignore those. @@ -62,7 +62,7 @@ class DBEnvClosedEarlyCrash(unittest.TestCase): self.filename = "test" def tearDown(self): - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) def test01_close_dbenv_before_db(self): dbenv = db.DBEnv() --- a/Lib3/bsddb/test/test_fileid.py +++ b/Lib3/bsddb/test/test_fileid.py @@ -40,7 +40,7 @@ import os import shutil import unittest -from .test_all import db, test_support, get_new_environment_path, get_new_database_path +from .test_all import db, rmtree, unlink, get_new_environment_path, get_new_database_path class FileidResetTestCase(unittest.TestCase): def setUp(self): @@ -82,9 +82,9 @@ class FileidResetTestCase(unittest.TestCase): self.db_env.close() def tearDown(self): - test_support.unlink(self.db_path_1) - test_support.unlink(self.db_path_2) - test_support.rmtree(self.db_env_path) + unlink(self.db_path_1) + unlink(self.db_path_2) + rmtree(self.db_env_path) def test_suite(): suite = unittest.TestSuite() --- a/Lib3/bsddb/test/test_join.py +++ b/Lib3/bsddb/test/test_join.py @@ -40,7 +40,7 @@ import os import unittest -from .test_all import db, dbshelve, test_support, verbose, \ +from .test_all import db, dbshelve, rmtree, verbose, \ get_new_environment_path, get_new_database_path #---------------------------------------------------------------------- @@ -75,7 +75,7 @@ class JoinTestCase(unittest.TestCase): def tearDown(self): self.env.close() - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) def test01_join(self): if verbose: --- a/Lib3/bsddb/test/test_lock.py +++ b/Lib3/bsddb/test/test_lock.py @@ -40,7 +40,7 @@ TestCases for testing the locking sub-system. import time import unittest -from .test_all import db, test_support, verbose, have_threads, \ +from .test_all import db, rmtree, verbose, have_threads, \ get_new_environment_path, get_new_database_path if have_threads : @@ -63,7 +63,7 @@ class LockingTestCase(unittest.TestCase): def tearDown(self): self.env.close() - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) def test01_simple(self): --- a/Lib3/bsddb/test/test_misc.py +++ b/Lib3/bsddb/test/test_misc.py @@ -39,7 +39,7 @@ are met: import os, sys import unittest -from .test_all import db, dbshelve, hashopen, test_support, get_new_environment_path, get_new_database_path +from .test_all import db, dbshelve, hashopen, rmtree, unlink, get_new_environment_path, get_new_database_path #---------------------------------------------------------------------- @@ -49,8 +49,8 @@ class MiscTestCase(unittest.TestCase): self.homeDir = get_new_environment_path() def tearDown(self): - test_support.unlink(self.filename) - test_support.rmtree(self.homeDir) + unlink(self.filename) + rmtree(self.homeDir) def test01_badpointer(self): dbs = dbshelve.open(self.filename) @@ -104,7 +104,7 @@ class MiscTestCase(unittest.TestCase): # double free happened during exit from DBC_get finally: db1.close() - test_support.unlink(self.filename) + unlink(self.filename) def test06_key_with_null_bytes(self): try: @@ -123,7 +123,7 @@ class MiscTestCase(unittest.TestCase): self.assertEqual(db1['aaa'], 'eh eh eh!') finally: db1.close() - test_support.unlink(self.filename) + unlink(self.filename) def test07_DB_set_flags_persists(self): try: @@ -147,7 +147,7 @@ class MiscTestCase(unittest.TestCase): self.assertEqual([('a', 'new A')], list(db1.items())) finally: db1.close() - test_support.unlink(self.filename) + unlink(self.filename) def test08_ExceptionTypes(self) : --- a/Lib3/bsddb/test/test_pickle.py +++ b/Lib3/bsddb/test/test_pickle.py @@ -47,7 +47,7 @@ else : import unittest -from .test_all import db, test_support, get_new_environment_path, get_new_database_path +from .test_all import db, rmtree, get_new_environment_path, get_new_database_path #---------------------------------------------------------------------- @@ -63,7 +63,7 @@ class pickleTestCase(unittest.TestCase): del self.db if hasattr(self, 'env'): del self.env - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) def _base_test_pickle_DBError(self, pickle): self.env = db.DBEnv() --- a/Lib3/bsddb/test/test_recno.py +++ b/Lib3/bsddb/test/test_recno.py @@ -42,7 +42,7 @@ from pprint import pprint import string import unittest -from .test_all import db, test_support, verbose, get_new_environment_path, get_new_database_path +from .test_all import db, rmtree, unlink, verbose, get_new_environment_path, get_new_database_path #---------------------------------------------------------------------- @@ -60,9 +60,9 @@ class SimpleRecnoTestCase(unittest.TestCase): self.homeDir = None def tearDown(self): - test_support.unlink(self.filename) + unlink(self.filename) if self.homeDir: - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) def test01_basic(self): d = db.DB() --- a/Lib3/bsddb/test/test_replication.py +++ b/Lib3/bsddb/test/test_replication.py @@ -41,7 +41,7 @@ import time import unittest import sys -from .test_all import db, test_support, have_threads, verbose, \ +from .test_all import db, rmtree, find_unused_port, have_threads, verbose, \ get_new_environment_path, get_new_database_path @@ -101,15 +101,11 @@ class DBReplication(unittest.TestCase) : self.dbenvClient.close() self.dbenvMaster.close() - test_support.rmtree(self.homeDirClient) - test_support.rmtree(self.homeDirMaster) + rmtree(self.homeDirClient) + rmtree(self.homeDirMaster) class DBReplicationManager(DBReplication) : def test01_basic_replication(self) : - if sys.version_info < (3, 9): - find_unused_port = test_support.find_unused_port - else: - from test.support.socket_helper import find_unused_port master_port = find_unused_port() client_port = find_unused_port() @@ -373,8 +369,8 @@ class DBBaseReplication(DBReplication) : self.dbenvClient.close() self.dbenvMaster.close() - test_support.rmtree(self.homeDirClient) - test_support.rmtree(self.homeDirMaster) + rmtree(self.homeDirClient) + rmtree(self.homeDirMaster) def basic_rep_threading(self) : self.dbenvMaster.rep_start(flags=db.DB_REP_MASTER) --- a/Lib3/bsddb/test/test_sequence.py +++ b/Lib3/bsddb/test/test_sequence.py @@ -36,7 +36,7 @@ are met: import unittest import os -from .test_all import db, test_support, get_new_environment_path, get_new_database_path +from .test_all import db, rmtree, get_new_environment_path, get_new_database_path class DBSequenceTest(unittest.TestCase): @@ -61,7 +61,7 @@ class DBSequenceTest(unittest.TestCase): self.dbenv.close() del self.dbenv - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) def test_get(self): self.seq = db.DBSequence(self.d, flags=0) --- a/Lib3/bsddb/test/test_thread.py +++ b/Lib3/bsddb/test/test_thread.py @@ -51,7 +51,7 @@ except NameError: pass import unittest -from .test_all import db, dbutils, test_support, verbose, have_threads, \ +from .test_all import db, dbutils, rmtree, verbose, have_threads, \ get_new_environment_path, get_new_database_path if have_threads : @@ -88,7 +88,7 @@ class BaseThreadedTestCase(unittest.TestCase): def tearDown(self): self.d.close() self.env.close() - test_support.rmtree(self.homeDir) + rmtree(self.homeDir) def setEnvOpts(self): pass