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

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

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 years, 7 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:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_dbm_gnu.py ('k') | Lib/test/test_epoll.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 """Test script for the dbm.open function based on testdumbdbm.py""" 1 """Test script for the dbm.open function based on testdumbdbm.py"""
2 2
3 import os 3 import os
4 import unittest 4 import unittest
5 import glob 5 import glob
6 import test.support 6 import test.support
7 7
8 # Skip tests if dbm module doesn't exist. 8 # Skip tests if dbm module doesn't exist.
9 dbm = test.support.import_module('dbm') 9 dbm = test.support.import_module('dbm')
10 10
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 delete_files() 134 delete_files()
135 f = module.open(_fname, 'c') 135 f = module.open(_fname, 'c')
136 f.close() 136 f.close()
137 self.assertEqual(name, self.dbm.whichdb(_fname)) 137 self.assertEqual(name, self.dbm.whichdb(_fname))
138 # Now add a key 138 # Now add a key
139 f = module.open(_fname, 'w') 139 f = module.open(_fname, 'w')
140 f[b"1"] = b"1" 140 f[b"1"] = b"1"
141 # and test that we can find it 141 # and test that we can find it
142 self.assertIn(b"1", f) 142 self.assertIn(b"1", f)
143 # and read it 143 # and read it
144 self.assertTrue(f[b"1"] == b"1") 144 self.assertEqual(f[b"1"], b"1")
145 f.close() 145 f.close()
146 self.assertEqual(name, self.dbm.whichdb(_fname)) 146 self.assertEqual(name, self.dbm.whichdb(_fname))
147 147
148 @unittest.skipUnless(ndbm, reason='Test requires ndbm') 148 @unittest.skipUnless(ndbm, reason='Test requires ndbm')
149 def test_whichdb_ndbm(self): 149 def test_whichdb_ndbm(self):
150 # Issue 17198: check that ndbm which is referenced in whichdb is defined 150 # Issue 17198: check that ndbm which is referenced in whichdb is defined
151 db_file = '{}_ndbm.db'.format(_fname) 151 db_file = '{}_ndbm.db'.format(_fname)
152 with open(db_file, 'w'): 152 with open(db_file, 'w'):
153 self.addCleanup(test.support.unlink, db_file) 153 self.addCleanup(test.support.unlink, db_file)
154 self.assertIsNone(self.dbm.whichdb(db_file[:-3])) 154 self.assertIsNone(self.dbm.whichdb(db_file[:-3]))
(...skipping 29 matching lines...) Expand all
184 classes.append(type("TestCase-" + mod.__name__, 184 classes.append(type("TestCase-" + mod.__name__,
185 (AnyDBMTestCase, unittest.TestCase), 185 (AnyDBMTestCase, unittest.TestCase),
186 {'module': mod})) 186 {'module': mod}))
187 suites = [unittest.makeSuite(c) for c in classes] 187 suites = [unittest.makeSuite(c) for c in classes]
188 188
189 tests.addTests(suites) 189 tests.addTests(suites)
190 return tests 190 return tests
191 191
192 if __name__ == "__main__": 192 if __name__ == "__main__":
193 unittest.main() 193 unittest.main()
OLDNEW
« no previous file with comments | « Lib/test/test_dbm_gnu.py ('k') | Lib/test/test_epoll.py » ('j') | no next file with comments »

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