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

Side by Side Diff: Lib/test/test_dbm_gnu.py

Issue 16510: Using appropriate checks in tests
Patch Set: Created 6 years, 1 month 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:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_crypt.py ('k') | Lib/test/test_dbm.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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, run_unittest, unlink 5 from test.support import verbose, TESTFN, run_unittest, unlink
6 6
7 7
8 filename = TESTFN 8 filename = TESTFN
9 9
10 class TestGdbm(unittest.TestCase): 10 class TestGdbm(unittest.TestCase):
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 for flag in flags: 63 for flag in flags:
64 self.g = gdbm.open(filename, mode + flag) 64 self.g = gdbm.open(filename, mode + flag)
65 self.g.close() 65 self.g.close()
66 66
67 def test_reorganize(self): 67 def test_reorganize(self):
68 self.g = gdbm.open(filename, 'c') 68 self.g = gdbm.open(filename, 'c')
69 size0 = os.path.getsize(filename) 69 size0 = os.path.getsize(filename)
70 70
71 self.g['x'] = 'x' * 10000 71 self.g['x'] = 'x' * 10000
72 size1 = os.path.getsize(filename) 72 size1 = os.path.getsize(filename)
73 self.assertTrue(size0 < size1) 73 self.assertLess(size0, size1)
74 74
75 del self.g['x'] 75 del self.g['x']
76 # 'size' is supposed to be the same even after deleting an entry. 76 # 'size' is supposed to be the same even after deleting an entry.
77 self.assertEqual(os.path.getsize(filename), size1) 77 self.assertEqual(os.path.getsize(filename), size1)
78 78
79 self.g.reorganize() 79 self.g.reorganize()
80 size2 = os.path.getsize(filename) 80 size2 = os.path.getsize(filename)
81 self.assertTrue(size1 > size2 >= size0) 81 self.assertTrue(size1 > size2 >= size0)
82 82
83 83
84 def test_main(): 84 def test_main():
85 run_unittest(TestGdbm) 85 run_unittest(TestGdbm)
86 86
87 if __name__ == '__main__': 87 if __name__ == '__main__':
88 test_main() 88 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_crypt.py ('k') | Lib/test/test_dbm.py » ('j') | no next file with comments »

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