summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dumbdbm.py
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2005-06-07 19:36:10 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2005-06-07 19:36:10 (GMT)
commitecdad8575ea0825f6cf6057906afd0fc94a375fc (patch)
tree86b21a4f8fe484b1f7730fb868464de9a4fecdb0 /Lib/test/test_dumbdbm.py
parenteb2608415ee4eb8aaea746f6a313937e264d0cda (diff)
downloadcpython-ecdad8575ea0825f6cf6057906afd0fc94a375fc.zip
cpython-ecdad8575ea0825f6cf6057906afd0fc94a375fc.tar.gz
cpython-ecdad8575ea0825f6cf6057906afd0fc94a375fc.tar.bz2
[Bug #1172763] dumbdbm uses eval() on lines, so it chokes if there's an extra \r on the end of a line; fixed by stripping off trailing whitespace.
Diffstat (limited to 'Lib/test/test_dumbdbm.py')
-rw-r--r--Lib/test/test_dumbdbm.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_dumbdbm.py b/Lib/test/test_dumbdbm.py
index 12df673..d320110 100644
--- a/Lib/test/test_dumbdbm.py
+++ b/Lib/test/test_dumbdbm.py
@@ -74,6 +74,24 @@ class DumbDBMTestCase(unittest.TestCase):
self.assertEqual(f['1'], 'hello2')
f.close()
+ def test_line_endings(self):
+ # test for bug #1172763: dumbdbm would die if the line endings
+ # weren't what was expected.
+ f = dumbdbm.open(_fname)
+ f['1'] = 'hello'
+ f['2'] = 'hello2'
+ f.close()
+
+ # Mangle the file by adding \r before each newline
+ data = open(_fname + '.dir').read()
+ data = data.replace('\n', '\r\n')
+ open(_fname + '.dir', 'wb').write(data)
+
+ f = dumbdbm.open(_fname)
+ self.assertEqual(f['1'], 'hello')
+ self.assertEqual(f['2'], 'hello2')
+
+
def read_helper(self, f):
keys = self.keys_helper(f)
for key in self._dict: