[Python-checkins] Use more specific asserts in dbm tests. (GH-7786)

Serhiy Storchaka webhook-mailer at python.org
Tue Jun 19 06:31:59 EDT 2018


https://github.com/python/cpython/commit/22525de737679ace1488e63b7ed289bdb253ffc7
commit: 22525de737679ace1488e63b7ed289bdb253ffc7
branch: master
author: Serhiy Storchaka <storchaka at gmail.com>
committer: GitHub <noreply at github.com>
date: 2018-06-19T13:31:48+03:00
summary:

Use more specific asserts in dbm tests. (GH-7786)

This may help to investigate bpo-33901.

files:
M Lib/test/test_dbm.py
M Lib/test/test_dbm_gnu.py

diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py
index 1884b5c683ef..1db3bef6f413 100644
--- a/Lib/test/test_dbm.py
+++ b/Lib/test/test_dbm.py
@@ -160,7 +160,7 @@ def test_whichdb(self):
             # and test that we can find it
             self.assertIn(b"1", f)
             # and read it
-            self.assertTrue(f[b"1"] == b"1")
+            self.assertEqual(f[b"1"], b"1")
             f.close()
             self.assertEqual(name, self.dbm.whichdb(_fname))
 
diff --git a/Lib/test/test_dbm_gnu.py b/Lib/test/test_dbm_gnu.py
index 463d34341155..50b8a192e55c 100644
--- a/Lib/test/test_dbm_gnu.py
+++ b/Lib/test/test_dbm_gnu.py
@@ -74,7 +74,7 @@ def test_reorganize(self):
 
         self.g['x'] = 'x' * 10000
         size1 = os.path.getsize(filename)
-        self.assertTrue(size0 < size1)
+        self.assertGreater(size1, size0)
 
         del self.g['x']
         # 'size' is supposed to be the same even after deleting an entry.
@@ -82,7 +82,8 @@ def test_reorganize(self):
 
         self.g.reorganize()
         size2 = os.path.getsize(filename)
-        self.assertTrue(size1 > size2 >= size0)
+        self.assertLess(size2, size1)
+        self.assertGreaterEqual(size2, size0)
 
     def test_context_manager(self):
         with gdbm.open(filename, 'c') as db:



More information about the Python-checkins mailing list