Fix the cleanup so that we're not left with shelftemp.db.* files.

This does nothing to fix the tests though...
This commit is contained in:
Guido van Rossum 2007-05-18 21:57:09 +00:00
parent b5b2270afb
commit 8d9db047d2
1 changed files with 10 additions and 12 deletions

View File

@ -8,35 +8,33 @@ class TestCase(unittest.TestCase):
fn = "shelftemp" + os.extsep + "db" fn = "shelftemp" + os.extsep + "db"
def tearDown(self):
for f in glob.glob(self.fn+"*"):
os.unlink(f)
def test_ascii_file_shelf(self): def test_ascii_file_shelf(self):
s = shelve.open(self.fn, protocol=0)
try: try:
s = shelve.open(self.fn, protocol=0)
s['key1'] = (1,2,3,4) s['key1'] = (1,2,3,4)
self.assertEqual(s['key1'], (1,2,3,4)) self.assertEqual(s['key1'], (1,2,3,4))
s.close()
finally: finally:
for f in glob.glob(self.fn+"*"): s.close()
os.unlink(f)
def test_binary_file_shelf(self): def test_binary_file_shelf(self):
s = shelve.open(self.fn, protocol=1)
try: try:
s = shelve.open(self.fn, protocol=1)
s['key1'] = (1,2,3,4) s['key1'] = (1,2,3,4)
self.assertEqual(s['key1'], (1,2,3,4)) self.assertEqual(s['key1'], (1,2,3,4))
s.close()
finally: finally:
for f in glob.glob(self.fn+"*"): s.close()
os.unlink(f)
def test_proto2_file_shelf(self): def test_proto2_file_shelf(self):
s = shelve.open(self.fn, protocol=2)
try: try:
s = shelve.open(self.fn, protocol=2)
s['key1'] = (1,2,3,4) s['key1'] = (1,2,3,4)
self.assertEqual(s['key1'], (1,2,3,4)) self.assertEqual(s['key1'], (1,2,3,4))
s.close()
finally: finally:
for f in glob.glob(self.fn+"*"): s.close()
os.unlink(f)
def test_in_memory_shelf(self): def test_in_memory_shelf(self):
d1 = {} d1 = {}