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

Delta Between Two Patch Sets: Lib/test/test_dbm_gnu.py

Issue 16510: Using appropriate checks in tests
Left Patch Set: Created 5 years, 9 months ago
Right Patch Set: Created 5 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/test/test_crypt.py ('k') | Lib/test/test_dbm.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 from test import support 1 from test import support
2 gdbm = support.import_module("dbm.gnu") #skip if not supported 2 gdbm = support.import_module("dbm.gnu") #skip if not supported
3 import unittest 3 import unittest
4 import os 4 import os
5 from test.support import verbose, TESTFN, unlink 5 from test.support import verbose, TESTFN, unlink
6 6
7 7
8 filename = TESTFN 8 filename = TESTFN
9 9
10 class TestGdbm(unittest.TestCase): 10 class TestGdbm(unittest.TestCase):
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 self.assertLess(size0, size1) 74 self.assertLess(size0, size1)
75 75
76 del self.g['x'] 76 del self.g['x']
77 # 'size' is supposed to be the same even after deleting an entry. 77 # 'size' is supposed to be the same even after deleting an entry.
78 self.assertEqual(os.path.getsize(filename), size1) 78 self.assertEqual(os.path.getsize(filename), size1)
79 79
80 self.g.reorganize() 80 self.g.reorganize()
81 size2 = os.path.getsize(filename) 81 size2 = os.path.getsize(filename)
82 self.assertTrue(size1 > size2 >= size0) 82 self.assertTrue(size1 > size2 >= size0)
83 83
84 def test_context_manager(self):
85 with gdbm.open(filename, 'c') as db:
86 db["gdbm context manager"] = "context manager"
87
88 with gdbm.open(filename, 'r') as db:
89 self.assertEqual(list(db.keys()), [b"gdbm context manager"])
90
91 with self.assertRaises(gdbm.error) as cm:
92 db.keys()
93 self.assertEqual(str(cm.exception),
94 "GDBM object has already been closed")
84 95
85 if __name__ == '__main__': 96 if __name__ == '__main__':
86 unittest.main() 97 unittest.main()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+