[Python-checkins] bpo-31664: Fix test_crypt for the openwall implementation of crypt. (#4116)

Serhiy Storchaka webhook-mailer at python.org
Wed Oct 25 09:30:19 EDT 2017


https://github.com/python/cpython/commit/0f261583bae7e60e410709ed96398dd1b14c5454
commit: 0f261583bae7e60e410709ed96398dd1b14c5454
branch: master
author: Serhiy Storchaka <storchaka at gmail.com>
committer: GitHub <noreply at github.com>
date: 2017-10-25T16:30:13+03:00
summary:

bpo-31664: Fix test_crypt for the openwall implementation of crypt. (#4116)

files:
M Lib/test/test_crypt.py

diff --git a/Lib/test/test_crypt.py b/Lib/test/test_crypt.py
index 8db1aefdf1e..796fd076c6a 100644
--- a/Lib/test/test_crypt.py
+++ b/Lib/test/test_crypt.py
@@ -57,7 +57,13 @@ def test_log_rounds(self):
     def test_invalid_log_rounds(self):
         for log_rounds in (1, -1, 999):
             salt = crypt.mksalt(crypt.METHOD_BLOWFISH, log_rounds=log_rounds)
-            self.assertIsNone(crypt.crypt('mypassword', salt))
+            cr = crypt.crypt('mypassword', salt)
+            if cr is not None:
+                # On failure the openwall implementation returns a magic
+                # string that is shorter than 13 characters and is guaranteed
+                # to differ from a salt.
+                self.assertNotEqual(cr, salt)
+                self.assertLess(len(cr), 13)
 
 
 if __name__ == "__main__":



More information about the Python-checkins mailing list