Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e20a2c1

Browse files
committed
stop leaving log.0000001 __db.00* and xxx.db turds in developer
sandboxes when bsddb3 tests are run.
1 parent d5a5f5d commit e20a2c1

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

Lib/bsddb/test/test_1413192.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,27 @@
44
# This test relies on the variable names, see the bug report for details.
55
# The problem was that the env was deallocated prior to the txn.
66

7+
import shutil
8+
import tempfile
79
try:
810
# For Pythons w/distutils and add-on pybsddb
911
from bsddb3 import db
1012
except ImportError:
1113
# For Python >= 2.3 builtin bsddb distribution
1214
from bsddb import db
1315

14-
env_name = '.'
16+
env_name = tempfile.mkdtemp()
1517

1618
env = db.DBEnv()
1719
env.open(env_name, db.DB_CREATE | db.DB_INIT_TXN | db.DB_INIT_MPOOL)
1820
the_txn = env.txn_begin()
1921

2022
map = db.DB(env)
21-
map.open('xxx.db', "p", db.DB_HASH, db.DB_CREATE, 0o666, txn=the_txn)
23+
map.open('xxx.db',
24+
"p", db.DB_HASH, db.DB_CREATE, 0o666, txn=the_txn)
25+
26+
# try not to leave a turd (won't help Windows since files are still open)
27+
try:
28+
shutil.rmtree(env_name)
29+
except EnvironmentError:
30+
pass

0 commit comments

Comments
 (0)