[Patch #1520904] Fix bsddb tests to write to the temp directory instead of the Lib/bsddb/test directory
This commit is contained in:
parent
882680462c
commit
9c3a392321
|
@ -91,7 +91,7 @@ musicdata = {
|
||||||
class AssociateErrorTestCase(unittest.TestCase):
|
class AssociateErrorTestCase(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.filename = self.__class__.__name__ + '.db'
|
self.filename = self.__class__.__name__ + '.db'
|
||||||
homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
|
homeDir = os.path.join(tempfile.gettempdir(), 'db_home')
|
||||||
self.homeDir = homeDir
|
self.homeDir = homeDir
|
||||||
try:
|
try:
|
||||||
os.mkdir(homeDir)
|
os.mkdir(homeDir)
|
||||||
|
|
|
@ -54,7 +54,7 @@ class BasicTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
if self.useEnv:
|
if self.useEnv:
|
||||||
homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
|
homeDir = os.path.join(tempfile.gettempdir(), 'db_home')
|
||||||
self.homeDir = homeDir
|
self.homeDir = homeDir
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(homeDir)
|
shutil.rmtree(homeDir)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import sys, os, string
|
import sys, os, string
|
||||||
import unittest
|
import unittest
|
||||||
import glob
|
import glob
|
||||||
|
import tempfile
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# For Pythons w/distutils pybsddb
|
# For Pythons w/distutils pybsddb
|
||||||
|
@ -19,7 +20,7 @@ class dbobjTestCase(unittest.TestCase):
|
||||||
db_name = 'test-dbobj.db'
|
db_name = 'test-dbobj.db'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
|
homeDir = os.path.join(tempfile.gettempdir(), 'db_home')
|
||||||
self.homeDir = homeDir
|
self.homeDir = homeDir
|
||||||
try: os.mkdir(homeDir)
|
try: os.mkdir(homeDir)
|
||||||
except os.error: pass
|
except os.error: pass
|
||||||
|
|
|
@ -231,7 +231,7 @@ class ThreadHashShelveTestCase(BasicShelveTestCase):
|
||||||
class BasicEnvShelveTestCase(DBShelveTestCase):
|
class BasicEnvShelveTestCase(DBShelveTestCase):
|
||||||
def do_open(self):
|
def do_open(self):
|
||||||
self.homeDir = homeDir = os.path.join(
|
self.homeDir = homeDir = os.path.join(
|
||||||
os.path.dirname(sys.argv[0]), 'db_home')
|
tempfile.gettempdir(), 'db_home')
|
||||||
try: os.mkdir(homeDir)
|
try: os.mkdir(homeDir)
|
||||||
except os.error: pass
|
except os.error: pass
|
||||||
self.env = db.DBEnv()
|
self.env = db.DBEnv()
|
||||||
|
|
|
@ -26,6 +26,7 @@ try:
|
||||||
pickle = cPickle
|
pickle = cPickle
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import pickle
|
import pickle
|
||||||
|
import tempfile
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from test_all import verbose
|
from test_all import verbose
|
||||||
|
@ -46,7 +47,7 @@ class TableDBTestCase(unittest.TestCase):
|
||||||
db_name = 'test-table.db'
|
db_name = 'test-table.db'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
|
homeDir = os.path.join(tempfile.gettempdir(), 'db_home')
|
||||||
self.homeDir = homeDir
|
self.homeDir = homeDir
|
||||||
try: os.mkdir(homeDir)
|
try: os.mkdir(homeDir)
|
||||||
except os.error: pass
|
except os.error: pass
|
||||||
|
|
|
@ -33,7 +33,7 @@ else:
|
||||||
|
|
||||||
class DBEnvClosedEarlyCrash(unittest.TestCase):
|
class DBEnvClosedEarlyCrash(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
|
self.homeDir = os.path.join(tempfile.gettempdir(), 'db_home')
|
||||||
try: os.mkdir(self.homeDir)
|
try: os.mkdir(self.homeDir)
|
||||||
except os.error: pass
|
except os.error: pass
|
||||||
tempfile.tempdir = self.homeDir
|
tempfile.tempdir = self.homeDir
|
||||||
|
|
|
@ -49,7 +49,7 @@ class JoinTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.filename = self.__class__.__name__ + '.db'
|
self.filename = self.__class__.__name__ + '.db'
|
||||||
homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
|
homeDir = os.path.join(tempfile.gettempdir(), 'db_home')
|
||||||
self.homeDir = homeDir
|
self.homeDir = homeDir
|
||||||
try: os.mkdir(homeDir)
|
try: os.mkdir(homeDir)
|
||||||
except os.error: pass
|
except os.error: pass
|
||||||
|
|
|
@ -30,7 +30,7 @@ except ImportError:
|
||||||
class LockingTestCase(unittest.TestCase):
|
class LockingTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
|
homeDir = os.path.join(tempfile.gettempdir(), 'db_home')
|
||||||
self.homeDir = homeDir
|
self.homeDir = homeDir
|
||||||
try: os.mkdir(homeDir)
|
try: os.mkdir(homeDir)
|
||||||
except os.error: pass
|
except os.error: pass
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
import tempfile
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# For Pythons w/distutils pybsddb
|
# For Pythons w/distutils pybsddb
|
||||||
|
@ -17,7 +18,7 @@ except ImportError:
|
||||||
class MiscTestCase(unittest.TestCase):
|
class MiscTestCase(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.filename = self.__class__.__name__ + '.db'
|
self.filename = self.__class__.__name__ + '.db'
|
||||||
homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
|
homeDir = os.path.join(tempfile.gettempdir(), 'db_home')
|
||||||
self.homeDir = homeDir
|
self.homeDir = homeDir
|
||||||
try:
|
try:
|
||||||
os.mkdir(homeDir)
|
os.mkdir(homeDir)
|
||||||
|
|
|
@ -203,10 +203,10 @@ class SimpleRecnoTestCase(unittest.TestCase):
|
||||||
just a line in the file, but you can set a different record delimiter
|
just a line in the file, but you can set a different record delimiter
|
||||||
if needed.
|
if needed.
|
||||||
"""
|
"""
|
||||||
source = os.path.join(os.path.dirname(sys.argv[0]),
|
homeDir = os.path.join(tempfile.gettempdir(), 'db_home')
|
||||||
'db_home/test_recno.txt')
|
source = os.path.join(homeDir, 'test_recno.txt')
|
||||||
if not os.path.isdir('db_home'):
|
if not os.path.isdir(homeDir):
|
||||||
os.mkdir('db_home')
|
os.mkdir(homeDir)
|
||||||
f = open(source, 'w') # create the file
|
f = open(source, 'w') # create the file
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ class BaseThreadedTestCase(unittest.TestCase):
|
||||||
if verbose:
|
if verbose:
|
||||||
dbutils._deadlock_VerboseFile = sys.stdout
|
dbutils._deadlock_VerboseFile = sys.stdout
|
||||||
|
|
||||||
homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
|
homeDir = os.path.join(tempfile.gettempdir(), 'db_home')
|
||||||
self.homeDir = homeDir
|
self.homeDir = homeDir
|
||||||
try:
|
try:
|
||||||
os.mkdir(homeDir)
|
os.mkdir(homeDir)
|
||||||
|
|
Loading…
Reference in New Issue