mirror of
https://github.com/python/cpython.git
synced 2025-11-02 19:12:55 +00:00
Fixed test_anydbm_creates to use proper paths for the created db.
Made some stylistic fixes.
This commit is contained in:
parent
1213bdd16d
commit
065f7b8626
1 changed files with 11 additions and 5 deletions
|
|
@ -1,4 +1,9 @@
|
||||||
|
"""Tests for the bsddb185 module.
|
||||||
|
|
||||||
|
The file 185test.db found in Lib/test/ is for testing purposes with this
|
||||||
|
testing suite.
|
||||||
|
|
||||||
|
"""
|
||||||
from test.test_support import verbose, run_unittest, findfile
|
from test.test_support import verbose, run_unittest, findfile
|
||||||
import unittest
|
import unittest
|
||||||
import bsddb185
|
import bsddb185
|
||||||
|
|
@ -8,24 +13,25 @@ import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
class Bsddb185Tests(unittest.TestCase):
|
class Bsddb185Tests(unittest.TestCase):
|
||||||
|
|
||||||
def test_open_existing_hash(self):
|
def test_open_existing_hash(self):
|
||||||
"verify we can open a file known to be a hash v2 file"
|
# Verify we can open a file known to be a hash v2 file
|
||||||
db = bsddb185.hashopen(findfile("185test.db"))
|
db = bsddb185.hashopen(findfile("185test.db"))
|
||||||
self.assertEqual(db["1"], "1")
|
self.assertEqual(db["1"], "1")
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
def test_whichdb(self):
|
def test_whichdb(self):
|
||||||
"verify that whichdb correctly sniffs the known hash v2 file"
|
# Verify that whichdb correctly sniffs the known hash v2 file
|
||||||
self.assertEqual(whichdb.whichdb(findfile("185test.db")), "bsddb185")
|
self.assertEqual(whichdb.whichdb(findfile("185test.db")), "bsddb185")
|
||||||
|
|
||||||
def test_anydbm_create(self):
|
def test_anydbm_create(self):
|
||||||
"verify that anydbm.open does *not* create a bsddb185 file"
|
# Verify that anydbm.open does *not* create a bsddb185 file
|
||||||
tmpdir = tempfile.mkdtemp()
|
tmpdir = tempfile.mkdtemp()
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
dbfile = os.path.join(tmpdir, "foo.db")
|
dbfile = os.path.join(tmpdir, "foo.db")
|
||||||
anydbm.open(dbfile, "c").close()
|
anydbm.open(os.path.splitext(dbfile)[0], "c").close()
|
||||||
ftype = whichdb.whichdb(findfile("foo.db"))
|
ftype = whichdb.whichdb(dbfile)
|
||||||
self.assertNotEqual(ftype, "bsddb185")
|
self.assertNotEqual(ftype, "bsddb185")
|
||||||
finally:
|
finally:
|
||||||
os.unlink(dbfile)
|
os.unlink(dbfile)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue