summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-07-11 04:09:09 (GMT)
committerTim Peters <tim.peters@gmail.com>2003-07-11 04:09:09 (GMT)
commit663d1b61cb1a69671dc5b831681d416e4b76a72d (patch)
tree5335bf9a649d3e3bbddf37ff86a99190e354c28b /Lib
parente7f343d0f1b72cffa9d8dcc123606ade769ebfd3 (diff)
downloadcpython-663d1b61cb1a69671dc5b831681d416e4b76a72d.zip
cpython-663d1b61cb1a69671dc5b831681d416e4b76a72d.tar.gz
cpython-663d1b61cb1a69671dc5b831681d416e4b76a72d.tar.bz2
Added a new randomized test.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_dumbdbm.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/test/test_dumbdbm.py b/Lib/test/test_dumbdbm.py
index 4d1bc0e..08474f7 100644
--- a/Lib/test/test_dumbdbm.py
+++ b/Lib/test/test_dumbdbm.py
@@ -86,6 +86,34 @@ class DumbDBMTestCase(unittest.TestCase):
self.assertEqual(keys, dkeys)
return keys
+ # Perform randomized operations. This doesn't make assumptions about
+ # what *might* fail.
+ def test_random(self):
+ import random
+ d = {} # mirror the database
+ for dummy in range(5):
+ f = dumbdbm.open(_fname)
+ for dummy in range(100):
+ k = random.choice('abcdefghijklm')
+ if random.random() < 0.2:
+ if k in d:
+ del d[k]
+ del f[k]
+ else:
+ v = random.choice('abc') * random.randrange(10000)
+ d[k] = v
+ f[k] = v
+ self.assertEqual(f[k], v)
+ f.close()
+
+ f = dumbdbm.open(_fname)
+ expected = d.items()
+ expected.sort()
+ got = f.items()
+ got.sort()
+ self.assertEqual(expected, got)
+ f.close()
+
def tearDown(self):
_delete_files()