Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(358)

Unified Diff: Lib/test/test_dbm_ndbm.py

Issue 4185044: Improve dbm modules — Python #9523 Base URL: http://svn.python.org/view/*checkout*/python/branches/py3k/
Patch Set:   Created 13 years, 1 month ago , Downloaded from: http://bugs.python.org/file20783/issue_9523.diff
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_dbm_gnu.py ('k') | Modules/_dbmmodule.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Lib/test/test_dbm_ndbm.py
===================================================================
--- Lib/test/test_dbm_ndbm.py (revision 88435)
+++ Lib/test/test_dbm_ndbm.py (working copy)
@@ -1,41 +1,27 @@
from test import support
-support.import_module("dbm.ndbm") #skip if not supported
+ndbm = support.import_module("dbm.ndbm") #skip if not supported
import unittest
-import os
-import random
-import dbm.ndbm
-from dbm.ndbm import error
+import test.test_dbm_base as test_dbm_base
-class DbmTestCase(unittest.TestCase):
- def setUp(self):
- self.filename = support.TESTFN
- self.d = dbm.ndbm.open(self.filename, 'c')
- self.d.close()
+filename = test_dbm_base.filename
- def tearDown(self):
- for suffix in ['', '.pag', '.dir', '.db']:
- support.unlink(self.filename + suffix)
- def test_keys(self):
- self.d = dbm.ndbm.open(self.filename, 'c')
- self.assertTrue(self.d.keys() == [])
- self.d['a'] = 'b'
- self.d[b'bytes'] = b'data'
- self.d['12345678910'] = '019237410982340912840198242'
- self.d.keys()
- self.assertIn(b'a', self.d)
- self.assertEqual(self.d[b'bytes'], b'data')
- self.d.close()
+class DbmTestCase(test_dbm_base.TestDbmBase):
+ _module = ndbm
+
def test_modes(self):
- for mode in ['r', 'rw', 'w', 'n']:
+ # Here the order is important, put the 'c' flags at the first make sure
+ # that 'r' won't raise file-not-exists error.
+ for mode in ['c', 'r', 'rw', 'w', 'n']:
try:
- self.d = dbm.ndbm.open(self.filename, mode)
+ self.d = self._module.open(filename, mode)
self.d.close()
except error:
self.fail()
+
def test_main():
support.run_unittest(DbmTestCase)
« no previous file with comments | « Lib/test/test_dbm_gnu.py ('k') | Modules/_dbmmodule.c » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b